Skip to content

BxDF tests #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3668d99
check util functions
keptsecret Jan 15, 2025
a66dc44
reciprocity test
keptsecret Jan 15, 2025
b5d9778
negative value checks
keptsecret Jan 15, 2025
48cc64c
Merge branch 'bxdf_unit_tests' of github.com:Devsh-Graphics-Programmi…
Przemog1 Jan 15, 2025
5df264a
fix test orders
keptsecret Jan 16, 2025
983efc3
Merge branch 'bxdf_unit_tests' of github.com:Devsh-Graphics-Programmi…
keptsecret Jan 16, 2025
e6e434a
use new param structs for bxdf funcs
keptsecret Jan 17, 2025
d494e3d
print more info on error
keptsecret Jan 20, 2025
3305441
Merge branch 'master' into bxdf_unit_tests
keptsecret Jan 20, 2025
3625ad2
fix reciprocity test, adjust comparison
keptsecret Jan 21, 2025
839d42c
fixed reciprocity test
keptsecret Jan 22, 2025
a40ba94
test buckets of inf
keptsecret Jan 23, 2025
d0d5d93
bucket by polar coords
keptsecret Jan 23, 2025
c8f8dae
chi2 test
keptsecret Jan 24, 2025
8ea1538
Merge branch 'master' into bxdf_unit_tests
keptsecret Jan 24, 2025
dcc2927
Merge branch 'master' into bxdf_unit_tests
keptsecret Jan 27, 2025
8781cb0
fix chi2 test, beckmann still error
keptsecret Jan 27, 2025
724acd5
add visualization option for chi2 samples
keptsecret Jan 28, 2025
e1cbc1a
fixed exr visualization
keptsecret Jan 29, 2025
9387298
use bxdf traits in test, better chi2 vis
keptsecret Jan 29, 2025
df07bfd
test config with json
keptsecret Jan 30, 2025
de11fe2
Merge branch 'master' into bxdf_unit_tests
keptsecret Jan 30, 2025
da1a4ad
fixed json config bugs
keptsecret Jan 30, 2025
d7f7a87
smooth dielectric tests
keptsecret Jan 31, 2025
111c11b
fix pcg usage
keptsecret Feb 12, 2025
83d8a92
Merge branch 'master' into bxdf_unit_tests
keptsecret Feb 12, 2025
db74fad
update with master
keptsecret Feb 21, 2025
f3144f1
refactor according to changes with bxdf
keptsecret Feb 27, 2025
5a9e8b5
added a compile shader test
keptsecret Feb 28, 2025
a133452
fix compile test
keptsecret Feb 28, 2025
1bbc59a
expand compile test
keptsecret Feb 28, 2025
800534f
Merge branch 'master' into bxdf_unit_tests
keptsecret Mar 3, 2025
98bd4e4
fix typo bug
keptsecret Mar 3, 2025
4a68b75
added test for arccos sum
keptsecret Mar 3, 2025
631f7f1
added more to shader compile test
keptsecret Mar 5, 2025
222dc24
update infinity usage
keptsecret Mar 7, 2025
a490635
updated tests
keptsecret Mar 11, 2025
a2c84c2
Merge branch 'master' into bxdf_unit_tests
keptsecret Mar 17, 2025
01bfc9b
Merge branch 'master' into bxdf_unit_tests
keptsecret Apr 2, 2025
3732687
refactor changes in bxdf, sampling
keptsecret Apr 2, 2025
4864a45
use getters for interaction, samples
keptsecret Apr 3, 2025
9dc93dd
use microfacet cache getters
keptsecret Apr 4, 2025
6f3706a
use new rng wrapper
keptsecret Apr 4, 2025
6d298fd
refactor uniform2d usage
keptsecret Apr 14, 2025
dd7c0c7
refactor quotient_pdf usage
keptsecret Apr 14, 2025
9b071a6
refactor changes to aniso cache
keptsecret Apr 16, 2025
61757af
added checking concepts work
keptsecret Apr 16, 2025
2ae583f
uncommented shader compile test
keptsecret Apr 16, 2025
d4d94e6
refactor tests to quotient pdf changes
keptsecret Apr 17, 2025
cf2dbcf
refactor typedef changes in bxdfs
keptsecret Apr 17, 2025
c4a9602
refactor changes to using bxdf params struct
keptsecret Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 62_CAD/Hatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool Hatch::Segment::isStraightLineConstantMajor() const
p1 = originalBezier->P1[major],
p2 = originalBezier->P2[major];
//assert(p0 <= p1 && p1 <= p2); (PRECISION ISSUES ARISE ONCE MORE)
return abs(p1 - p0) <= core::exp2(-24.0) && abs(p2 - p0) <= exp(-24);
return abs(p1 - p0) <= core::exp2(-24.0) && abs(p2 - p0) <= hlsl::exp(-24.0f);
}

std::array<double, 2> Hatch::Segment::intersect(const Segment& other) const
Expand Down
110 changes: 109 additions & 1 deletion 62_CAD/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ using namespace video;
#include "HatchGlyphBuilder.h"
#include "GeoTexture.h"

#include <nbl/builtin/hlsl/tgmath.hlsl>

//TODO: remove
#include <nbl/builtin/hlsl/concepts/core.hlsl>
#include <nbl/builtin/hlsl/concepts/vector.hlsl>
#include <nbl/builtin/hlsl/concepts/matrix.hlsl>

#include <chrono>
#define BENCHMARK_TILL_FIRST_FRAME

Expand Down Expand Up @@ -66,7 +73,7 @@ constexpr std::array<float, (uint32_t)ExampleMode::CASE_COUNT> cameraExtents =
600.0, // CASE_8
};

constexpr ExampleMode mode = ExampleMode::CASE_5;
constexpr ExampleMode mode = ExampleMode::CASE_4;

class Camera2D
{
Expand Down Expand Up @@ -637,6 +644,107 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu

inline bool onAppInitialized(smart_refctd_ptr<ISystem>&& system) override
{
{
using ef64 = hlsl::emulated_float64_t<true, true>;
using NormalVec = hlsl::vector<float, 3>;
using EmulatedVec = hlsl::emulated_vector_t3<ef64>;
using NormalMatrix = hlsl::matrix<float, 3, 3>;
using EmulatedMatrix = hlsl::emulated_matrix_t3x3<ef64>;

auto createNormalVec = [](float x, float y, float z) -> NormalVec
{
NormalVec output;
output.x = x;
output.y = y;
output.z = z;

return output;
};
auto createEmulatedVec = [](float x, float y, float z) -> EmulatedVec
{
EmulatedVec output;
output.x = hlsl::emulated_float64_t<true, true>::create(x);
output.y = hlsl::emulated_float64_t<true, true>::create(y);
output.z = hlsl::emulated_float64_t<true, true>::create(z);

return output;
};

auto createNormalMat = [](float a0, float a1, float a2, float b0, float b1, float b2, float c0, float c1, float c2) -> NormalMatrix
{
NormalMatrix output;
output[0][0] = a0;
output[0][1] = a1;
output[0][2] = a2;

output[1][0] = b0;
output[1][1] = b1;
output[1][2] = b2;

output[2][0] = c0;
output[2][1] = c1;
output[2][2] = c2;

return output;
};

auto createEmulatedMat = [](float a0, float a1, float a2, float b0, float b1, float b2, float c0, float c1, float c2) -> EmulatedMatrix
{
EmulatedMatrix output;
output.rows[0].x = ef64::create(a0);
output.rows[0].y = ef64::create(a1);
output.rows[0].z = ef64::create(a2);

output.rows[1].x = ef64::create(b0);
output.rows[1].y = ef64::create(b1);
output.rows[1].z = ef64::create(b2);

output.rows[2].x = ef64::create(c0);
output.rows[2].y = ef64::create(c1);
output.rows[2].z = ef64::create(c2);

return output;
};

{
/*NormalVec a = createNormalVec(1, 2, 3);
NormalVec b = createNormalVec(4, 5, 6);

auto c = hlsl::findMSB(a);
__debugbreak();*/
}

{
/*EmulatedVec a = createEmulatedVec(1, 2, 3);
EmulatedVec b = createEmulatedVec(4, 5, 6);

auto c = hlsl::findMSB(a);
__debugbreak();*/
}

{
/*NormalMatrix a = createNormalMat(1, 2, 3, 4, 5, 6, 7, 8, 9);

hlsl::matrix_traits<NormalMatrix> asdf;

auto c = hlsl::determinant(a);
__debugbreak();*/
}

{
/*auto a = createEmulatedMat(1, 2, 3, 4, 5, 6, 7, 8, 9);
auto b = createEmulatedMat(10, 11, 12, 13, 14, 15, 16, 17, 18);

auto c = nbl::hlsl::mul(a, b);

NormalVec r0 = nbl::hlsl::_static_cast<NormalVec>(c.rows[0]);
NormalVec r1 = nbl::hlsl::_static_cast<NormalVec>(c.rows[1]);
NormalVec r2 = nbl::hlsl::_static_cast<NormalVec>(c.rows[2]);

__debugbreak();*/
}
}

m_inputSystem = make_smart_refctd_ptr<InputSystem>(logger_opt_smart_ptr(smart_refctd_ptr(m_logger)));

// Remember to call the base class initialization!
Expand Down
1 change: 1 addition & 0 deletions 62_CAD/shaders/globals.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <nbl/builtin/hlsl/cpp_compat/basic.h>
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>
#include <nbl/builtin/hlsl/shapes/beziers.hlsl>
#include <nbl/builtin/hlsl/tgmath.hlsl>

#ifdef __HLSL_VERSION
#include <nbl/builtin/hlsl/math/equations/quadratic.hlsl>
Expand Down
2 changes: 1 addition & 1 deletion 62_CAD/shaders/main_pipeline/vertex_shader.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ PSInput main(uint vertexID : SV_VertexID)
// Ok, brainfart, a vertex can belong to multiple triangles, I was thinking of AA but triangles share vertices, nevermind my comment above.

const uint vertexIdx = vertexID & 0x3u;
const uint objectID = vertexID >> 2;
const uint objectID = (vertexID >> 2) * a;

DrawObject drawObj = drawObjects[objectID];

Expand Down
32 changes: 32 additions & 0 deletions 66_HLSLBxDFTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
set(NBL_INCLUDE_SEARCH_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

include(common RESULT_VARIABLE RES)
if(NOT RES)
message(FATAL_ERROR "common.cmake not found. Should be in {repo_root}/cmake directory")
endif()

nbl_create_executable_project("" "" "${NBL_INCLUDE_SEARCH_DIRECTORIES}" "" "${NBL_EXECUTABLE_PROJECT_CREATION_PCH_TARGET}")

if(NBL_EMBED_BUILTIN_RESOURCES)
set(_BR_TARGET_ ${EXECUTABLE_NAME}_builtinResourceData)
set(RESOURCE_DIR "app_resources")

get_filename_component(_SEARCH_DIRECTORIES_ "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_SOURCE_ "${CMAKE_CURRENT_BINARY_DIR}/src" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_HEADER_ "${CMAKE_CURRENT_BINARY_DIR}/include" ABSOLUTE)

file(GLOB_RECURSE BUILTIN_RESOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}" CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}/*")
foreach(RES_FILE ${BUILTIN_RESOURCE_FILES})
LIST_BUILTIN_RESOURCE(RESOURCES_TO_EMBED "${RES_FILE}")
endforeach()

ADD_CUSTOM_BUILTIN_RESOURCES(${_BR_TARGET_} RESOURCES_TO_EMBED "${_SEARCH_DIRECTORIES_}" "${RESOURCE_DIR}" "nbl::this_example::builtin" "${_OUTPUT_DIRECTORY_HEADER_}" "${_OUTPUT_DIRECTORY_SOURCE_}")

LINK_BUILTIN_RESOURCES_TO_TARGET(${EXECUTABLE_NAME} ${_BR_TARGET_})
endif()

add_dependencies(${EXECUTABLE_NAME} OpenEXR)
target_link_libraries(${EXECUTABLE_NAME} PRIVATE OpenEXR)
target_include_directories(${EXECUTABLE_NAME} PUBLIC $<TARGET_PROPERTY:OpenEXR,INCLUDE_DIRECTORIES>)
20 changes: 20 additions & 0 deletions 66_HLSLBxDFTests/app_resources/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"logInfo": false,
"TestJacobian": {
"runs": 10
},
"TestReciprocity": {
"runs": 10
},
"TestBucket": {
"runs": 10,
"samples": 500
},
"TestChi2": {
"runs": 5,
"samples": 1000000,
"thetaSplits": 80,
"phiSplits": 160,
"writeFrequencies": false
}
}
Loading