Skip to content
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

BxDF tests #165

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ba9fde5
hlsl bxdf test dir
keptsecret Dec 17, 2024
4f9dc9f
test bxdf compiles
keptsecret Dec 17, 2024
2091701
minor namespace changes
keptsecret Dec 17, 2024
385bcec
added bsdf test
keptsecret Dec 19, 2024
5ba4dfd
Merge branch 'master' into bxdf_unit_tests
keptsecret Dec 19, 2024
9212b65
fix namespace
keptsecret Dec 20, 2024
32f959d
Example 62 fix
Przemog1 Dec 20, 2024
8128422
Merge branch 'master' into bxdf_unit_tests
keptsecret Dec 23, 2024
70b28d8
working? test
keptsecret Dec 23, 2024
f177090
rng test util struct
keptsecret Dec 25, 2024
382c862
beckmann dielectric test
keptsecret Dec 25, 2024
e0bde55
Updated examples
Przemog1 Dec 28, 2024
46c80dc
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
Przemog1 Dec 28, 2024
677323b
Fixes
Przemog1 Dec 30, 2024
1bc825d
Merge branch 'bxdf_unit_tests' of github.com:Devsh-Graphics-Programmi…
Przemog1 Dec 30, 2024
76db120
Merge branch 'master' into bxdf_unit_tests
keptsecret Jan 3, 2025
9de6ae8
fix syntax
keptsecret Jan 3, 2025
6dbc89a
more tests (all brdfs) and utils
keptsecret Jan 6, 2025
9c379eb
template tests
keptsecret Jan 7, 2025
5140f85
all existing tests into templates
keptsecret Jan 7, 2025
fb7b31b
simplify test template and usage
keptsecret Jan 8, 2025
3c415fd
diff v test
keptsecret Jan 8, 2025
3524449
test metadata struct for more info
keptsecret Jan 8, 2025
ef188ba
smooth dielectric bsdf tests
keptsecret Jan 8, 2025
17b253c
improve rng function
keptsecret Jan 9, 2025
59d14c3
fix bugs in rng
keptsecret Jan 9, 2025
fac1ed1
fix tests, use uniform sampling
keptsecret Jan 10, 2025
1ecd0c0
use new sampling
keptsecret Jan 10, 2025
c983141
hash to uint2 seed
keptsecret Jan 10, 2025
c02c9f0
use glm quaternions instead
keptsecret Jan 10, 2025
0c3d657
callbacks on detect error
keptsecret Jan 13, 2025
01d4799
fix callback usage bugs
keptsecret Jan 13, 2025
887c3a0
changed ior, spectral_type usage in bxdf
keptsecret Jan 13, 2025
9ab4e8e
use new pcg hlsl
keptsecret Jan 14, 2025
c8859c0
callback reruns bxdf compute
keptsecret Jan 14, 2025
414f961
added bxdf names for debugging
keptsecret Jan 14, 2025
fe23efc
Saving work
Przemog1 Jan 14, 2025
cdff4c6
Merge branch 'bxdf_unit_tests' of github.com:Devsh-Graphics-Programmi…
Przemog1 Jan 14, 2025
3668d99
check util functions
keptsecret Jan 15, 2025
a66dc44
reciprocity test
keptsecret Jan 15, 2025
b5d9778
negative value checks
keptsecret Jan 15, 2025
55362eb
Saving work
Przemog1 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
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
51 changes: 25 additions & 26 deletions 66_HLSLBxDFTests/app_resources/tests.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ using iso_cache = bxdf::SIsotropicMicrofacetCache<float>;
using aniso_cache = bxdf::SAnisotropicMicrofacetCache<float>;
using quotient_pdf_t = bxdf::quotient_and_pdf<float32_t3, float>;

uint32_t pcg_hash(uint32_t v)
{
uint32_t state = v * 747796405u + 2891336453u;
uint32_t word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
return (word >> 22u) ^ word;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is useful in its own header like xoroshiro is


uint32_t2 pcg2d_hash(uint32_t v)
{
return uint32_t2(pcg_hash(v), pcg_hash(v+1));
}

namespace impl
{

Expand Down Expand Up @@ -68,7 +80,6 @@ struct SBxDFTestResources
static SBxDFTestResources create(uint32_t2 seed)
{
SBxDFTestResources retval;

retval.rng = nbl::hlsl::Xoroshiro64Star::construct(seed);
retval.u = float32_t3(rngUniformDist<float32_t2>(retval.rng), 0.0);

Expand All @@ -92,24 +103,12 @@ struct SBxDFTestResources

retval.alpha.x = rngUniformDist<float>(retval.rng);
retval.alpha.y = rngUniformDist<float>(retval.rng);
retval.eta = 1.3;// rngFloat01(retval.rng) + 1.0;
retval.ior = float32_t3x2(1.02, 1.0, // randomize at some point?
1.3, 2.0,
1.02, 1.0);
retval.eta2 = float32_t3(1.02, 1.3, 1.02); // TODO: check correctness?
retval.eta = 1.3;
retval.ior = float32_t2(1.3, 2.0);
retval.luma_coeff = float32_t3(0.2126, 0.7152, 0.0722); // luma coefficients for Rec. 709
return retval;
}

ray_dir_info_t dV(int axis)
{
float32_t3 d = (float32_t3)0.0;
d[axis] += h;
ray_dir_info_t retval;
retval.direction = V.direction + d;
return retval;
}

float h = 0.001;

nbl::hlsl::Xoroshiro64Star rng;
Expand All @@ -121,9 +120,7 @@ struct SBxDFTestResources
float32_t3 u;
float32_t2 alpha;
float eta;
float32_t3x2 ior;

float32_t3 eta2; // what is this?
float32_t2 ior;
float32_t3 luma_coeff;
};

Expand Down Expand Up @@ -195,14 +192,14 @@ struct TestBxDF<bxdf::reflection::SBeckmannBxDF<sample_t, iso_cache, aniso_cache
{
if (aniso)
{
base_t::bxdf = bxdf::reflection::SBeckmannBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,rc.alpha.y,rc.ior);
base_t::bxdf = bxdf::reflection::SBeckmannBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,rc.alpha.y,float32_t3x2(rc.ior,rc.ior,rc.ior));
#ifndef __HLSL_VERSION
base_t::meta.bxdfName = "BeckmannBRDF Aniso";
#endif
}
else
{
base_t::bxdf = bxdf::reflection::SBeckmannBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,rc.ior);
base_t::bxdf = bxdf::reflection::SBeckmannBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,float32_t3x2(rc.ior,rc.ior,rc.ior));
#ifndef __HLSL_VERSION
base_t::meta.bxdfName = "BeckmannBRDF";
#endif
Expand All @@ -220,14 +217,14 @@ struct TestBxDF<bxdf::reflection::SGGXBxDF<sample_t, iso_cache, aniso_cache>> :
{
if (aniso)
{
base_t::bxdf = bxdf::reflection::SGGXBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,rc.alpha.y,rc.ior);
base_t::bxdf = bxdf::reflection::SGGXBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,rc.alpha.y,float32_t3x2(rc.ior,rc.ior,rc.ior));
#ifndef __HLSL_VERSION
base_t::meta.bxdfName = "GGXBRDF Aniso";
#endif
}
else
{
base_t::bxdf = bxdf::reflection::SGGXBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,rc.ior);
base_t::bxdf = bxdf::reflection::SGGXBxDF<sample_t, iso_cache, aniso_cache>::create(rc.alpha.x,float32_t3x2(rc.ior,rc.ior,rc.ior));
#ifndef __HLSL_VERSION
base_t::meta.bxdfName = "GGXBRDF";
#endif
Expand Down Expand Up @@ -256,7 +253,7 @@ struct TestBxDF<bxdf::transmission::SSmoothDielectricBxDF<sample_t, iso_cache, a

void initBxDF(SBxDFTestResources _rc)
{
base_t::bxdf = bxdf::transmission::SSmoothDielectricBxDF<sample_t, iso_cache, aniso_cache, true>::create(rc.eta2,rc.luma_coeff);
base_t::bxdf = bxdf::transmission::SSmoothDielectricBxDF<sample_t, iso_cache, aniso_cache, true>::create(float32_t3(rc.eta * rc.eta),rc.luma_coeff);
#ifndef __HLSL_VERSION
base_t::meta.bxdfName = "ThinSmoothDielectricBSDF";
#endif
Expand Down Expand Up @@ -415,13 +412,15 @@ struct TestUOffset : TestBxDF<BxDF>
float32_t2x2 m = float32_t2x2(sx.TdotL - s.TdotL, sy.TdotL - s.TdotL, sx.BdotL - s.BdotL, sy.BdotL - s.BdotL);
float det = nbl::hlsl::determinant<float32_t2x2>(m);

return float32_t4(nbl::hlsl::abs<float32_t3>(pdf.value() - brdf), nbl::hlsl::abs<float>(det*pdf.pdf/s.NdotL) * 0.5);
return float32_t4(nbl::hlsl::abs<float32_t3>(pdf.value() - brdf), nbl::hlsl::abs<float>(det*pdf.pdf/s.NdotL));
}

static STestMeta run(uint32_t2 seed)
static STestMeta run(uint32_t seed)
{
uint32_t2 state = pcg2d_hash(seed);

this_t t;
t.init(seed);
t.init(state);
if NBL_CONSTEXPR_FUNC (is_microfacet_brdf_v<BxDF> || is_microfacet_bsdf_v<BxDF>)
t.template initBxDF<aniso>(t.rc);
else
Expand Down
2 changes: 1 addition & 1 deletion 66_HLSLBxDFTests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main(int argc, char** argv)

using bool32_t4 = vector<bool, 4>;

const uint32_t2 state = uint32_t2(10u, 42u); // (12u, 69u)
const uint32_t state = 69u;

// test u offset, 2 axis
printResult((TestUOffset<bxdf::reflection::SLambertianBxDF<sample_t, iso_interaction, aniso_interaction>>::run(state)));
Expand Down