Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5218545
changes to dual measure quant, old stuff commented out for now
keptsecret Sep 4, 2025
f7525af
create query structs in beckmann ndf, removed query concepts, funcs r…
keptsecret Sep 5, 2025
c50db68
did the same for ggx ndf, some fixes to beckmann
keptsecret Sep 5, 2025
c49bedb
Merge branch 'master' into bxdf_fixes_cook_torrance
keptsecret Sep 8, 2025
319c954
fixes to ndf concept
keptsecret Sep 8, 2025
4eeacf1
moved eval, quotient/pdf into cook torrance base
keptsecret Sep 9, 2025
e7bc784
moved generate H into ndfs, generate impl in cook torrance base
keptsecret Sep 9, 2025
72226bb
use new cook torrance base in microfacet bxdfs
keptsecret Sep 9, 2025
f34b348
Merge branch 'master' into bxdf_fixes_cook_torrance
keptsecret Sep 10, 2025
ad13044
numerous typo bug fixes
keptsecret Sep 10, 2025
d8d2116
fixes to ggx ndf
keptsecret Sep 10, 2025
238b08e
fixed conductor fresnel naming ior as eta
keptsecret Sep 10, 2025
8bc707f
minor fixes to beckmann ndf, removed obsolete comments
keptsecret Sep 10, 2025
9fb28cf
added luminosity contribution hint to cook torrance bsdfs
keptsecret Sep 11, 2025
4cb8a0a
added aniso overloads to isotropic bxdf methods
keptsecret Sep 11, 2025
392dc31
checks for invalid generate sample
keptsecret Sep 11, 2025
02de86e
removed obsolete commented out stuff
keptsecret Sep 12, 2025
4a7f532
added cartesian-polar conversions from unit tests
keptsecret Sep 12, 2025
80c4f67
Merge branch 'fix_rotation_mat' into bxdf_fixes_cook_torrance
keptsecret Sep 15, 2025
6233bd1
Merge branch 'master' into bxdf_fixes_cook_torrance
keptsecret Sep 15, 2025
ce5fbac
vector hashes
keptsecret Sep 15, 2025
47e814b
Merge branch 'fix_rotation_mat' into bxdf_fixes_cook_torrance
keptsecret Sep 15, 2025
c983975
Merge branch 'master' into bxdf_fixes_cook_torrance
keptsecret Sep 16, 2025
0f2ee0b
fix fresnel usage in bxdf pdf
keptsecret Sep 17, 2025
b5f02e6
fix F calc in generate
keptsecret Sep 17, 2025
a111415
merge master, fix conflicts
keptsecret Sep 22, 2025
9655049
minor fixes to non cook torrance bxdf generate
keptsecret Sep 22, 2025
a1743d2
split out bxdf concept typdefs
keptsecret Sep 22, 2025
e6d663b
removed redundant thin_smooth_dielectric create
keptsecret Sep 22, 2025
340cee3
added and use notEqual spirv intrinsic
keptsecret Sep 22, 2025
a3733b1
moved polar coord stuff into its own file
keptsecret Sep 22, 2025
3e3589b
made smith functions return measureless
keptsecret Sep 22, 2025
4bdf199
use type alias macro from config
keptsecret Sep 22, 2025
4faecc3
adjust ndf concept, change fresnel conductor ior to eta
keptsecret Sep 23, 2025
407da2f
combine brdf/bsdf cook torrance into same struct, old stuff commented…
keptsecret Sep 23, 2025
638b8b5
moved duplicate code in eval, pdf, quotient_pdf into templated intera…
keptsecret Sep 23, 2025
c587820
some changes to fresnel, cook torrance base
keptsecret Sep 24, 2025
d438360
reverted ggx ndf to use optimizations
keptsecret Sep 24, 2025
5f49f11
pdf function checks for backfacing V
keptsecret Sep 25, 2025
627074b
reduced beckmann, ggx ndfs to single struct with enable_ifs
keptsecret Sep 25, 2025
3896231
put concepts back in for ndf impl
keptsecret Sep 26, 2025
91b39d5
ggx ndf determine clamp with template bool
keptsecret Sep 26, 2025
2a3cda3
moved A out of ndf base into generate base
keptsecret Sep 26, 2025
c9f9366
added create methods to ndfs, cook torrance base; slight changes to c…
keptsecret Sep 26, 2025
fd128e6
make beckmann + ggx bxdfs typedefs of cooktorrance base, functionalit…
keptsecret Sep 26, 2025
882375e
added flipSign func that copies sign of rhs
keptsecret Sep 29, 2025
b22d570
remove unused var
keptsecret Sep 29, 2025
c0586f5
moved cook torrance base into base folder, removed commented out in b…
keptsecret Sep 29, 2025
9eeb248
make lambertian + oren nayar bxdfs typedefs of corresponding base, fu…
keptsecret Sep 29, 2025
26c76e4
fix microfacet bxdf concept
keptsecret Sep 29, 2025
58e2a0b
fixes to cook torrance generate
keptsecret Sep 30, 2025
2a08728
templated ray_dir_info reflect/refract funcs
keptsecret Sep 30, 2025
b993e47
pdf should return inf when smooth cook torrance bxdf
keptsecret Sep 30, 2025
f3cb6ff
set pdf=0 in specific cases
keptsecret Oct 1, 2025
7389c9a
added checking for TIR in bsdfs
keptsecret Oct 1, 2025
ec5913b
change fresnel orientedeta based on NdotV, user needs to pass front f…
keptsecret Oct 2, 2025
bccdb0b
fixes flipSign and flipSignIfRHSNeg
keptsecret Oct 3, 2025
1e9e407
fix bsdf generate: LdotH and NdotL same sign, otherwise invalid sample
keptsecret Oct 3, 2025
dab51c3
cook torrance brdf returns invalid sample in cases, fix missing return
keptsecret Oct 3, 2025
53ab934
more util funcs for ray_dir_info, avoid setting vals directly
keptsecret Oct 3, 2025
804014f
added IsMicrofacet to bxdf_traits
keptsecret Oct 3, 2025
260f7a3
projectedSphere generate should take v by ref
keptsecret Oct 6, 2025
fd54ac4
removed vector std::hash because glm already implemented it
keptsecret Oct 6, 2025
5caf006
Merge branch 'master' into bxdf_fixes_cook_torrance
keptsecret Oct 6, 2025
7508b82
get orientedeta and rcp methods in fresnel + concept
keptsecret Oct 6, 2025
2b4a9c1
slight change to flipSignIfRHSNeg struct
keptsecret Oct 6, 2025
d3fa872
added two-sided fresnel concept
keptsecret Oct 6, 2025
5765e87
removed cook torrance param structs/create funcs
keptsecret Oct 6, 2025
23763e2
cache.isValid func, schlick fresnel reorient
keptsecret Oct 7, 2025
069f499
big fixes to cook torrance bxdf generate
keptsecret Oct 7, 2025
22c4918
moved cook torrance checks into private func, changed checks in quoti…
keptsecret Oct 8, 2025
dcc2464
getRefractionOrientedEta returns a scalar, but now I have to turn it …
keptsecret Oct 8, 2025
7aa071b
moved ndf type defs and constexpr declaration into macro
keptsecret Oct 8, 2025
97e5ce3
moved out quant query, adjusted ndf macro usage
keptsecret Oct 8, 2025
6272281
reduced duplicate code in beckmann, ggx ndfs
keptsecret Oct 9, 2025
b55bdef
fix calculations in cook torrance eval, generate
keptsecret Oct 9, 2025
444b656
removed passthrough funcs, template directly on required interaction/…
keptsecret Oct 9, 2025
971e140
precompute more stuff in quant query
keptsecret Oct 10, 2025
6a0e28d
various fixes to ggx ndf, cook torrance base
keptsecret Oct 10, 2025
f93772e
change ndf type alias macro usage
keptsecret Oct 10, 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
361 changes: 361 additions & 0 deletions include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl

Large diffs are not rendered by default.

36 changes: 27 additions & 9 deletions include/nbl/builtin/hlsl/bxdf/base/lambertian.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,40 @@ struct SLambertianBase
{
return hlsl::promote<spectral_type>(_sample.getNdotL(_clamp) * numbers::inv_pi<scalar_type> * hlsl::mix(1.0, 0.5, IsBSDF));
}
spectral_type eval(NBL_CONST_REF_ARG(sample_type) _sample, NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction)
{
return eval(_sample, interaction.isotropic);
}

sample_type generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector2_type u)
template<typename C=bool_constant<!IsBSDF> >
enable_if_t<C::value && !IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector2_type u)
{
// static_assert(!IsBSDF);
ray_dir_info_type L;
L.direction = sampling::ProjectedHemisphere<scalar_type>::generate(u);
L.setDirection(sampling::ProjectedHemisphere<scalar_type>::generate(u));
return sample_type::createFromTangentSpace(L, interaction.getFromTangentSpace());
}

sample_type generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector3_type u)
template<typename C=bool_constant<IsBSDF> >
enable_if_t<C::value && IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector3_type u)
{
// static_assert(IsBSDF);
vector3_type _u = u;
ray_dir_info_type L;
L.direction = sampling::ProjectedSphere<scalar_type>::generate(u);
L.setDirection(sampling::ProjectedSphere<scalar_type>::generate(_u));
return sample_type::createFromTangentSpace(L, interaction.getFromTangentSpace());
}
template<typename C=bool_constant<!IsBSDF> >
enable_if_t<C::value && !IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(isotropic_interaction_type) interaction, const vector2_type u)
{
return generate(anisotropic_interaction_type::create(interaction), u);
}
template<typename C=bool_constant<IsBSDF> >
enable_if_t<C::value && IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(isotropic_interaction_type) interaction, const vector3_type u)
{
return generate(anisotropic_interaction_type::create(interaction), u);
}

scalar_type pdf(NBL_CONST_REF_ARG(sample_type) _sample)
{
if (IsBSDF)
NBL_IF_CONSTEXPR (IsBSDF)
return sampling::ProjectedSphere<scalar_type>::pdf(_sample.getNdotL(_clamp));
else
return sampling::ProjectedHemisphere<scalar_type>::pdf(_sample.getNdotL(_clamp));
Expand All @@ -57,12 +71,16 @@ struct SLambertianBase
quotient_pdf_type quotient_and_pdf(NBL_CONST_REF_ARG(sample_type) _sample, NBL_CONST_REF_ARG(isotropic_interaction_type) interaction)
{
sampling::quotient_and_pdf<monochrome_type, scalar_type> qp;
if (IsBSDF)
NBL_IF_CONSTEXPR (IsBSDF)
qp = sampling::ProjectedSphere<scalar_type>::template quotient_and_pdf(_sample.getNdotL(_clamp));
else
qp = sampling::ProjectedHemisphere<scalar_type>::template quotient_and_pdf(_sample.getNdotL(_clamp));
return quotient_pdf_type::create(qp.quotient[0], qp.pdf);
}
quotient_pdf_type quotient_and_pdf(NBL_CONST_REF_ARG(sample_type) _sample, NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction)
{
return quotient_and_pdf(_sample, interaction.isotropic);
}
};

}
Expand Down
32 changes: 25 additions & 7 deletions include/nbl/builtin/hlsl/bxdf/base/oren_nayar.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,36 @@ struct SOrenNayarBase
query.VdotL = hlsl::dot(interaction.getV().getDirection(), _sample.getL().getDirection());
return __eval<SQuery>(query, _sample, interaction);
}
spectral_type eval(NBL_CONST_REF_ARG(sample_type) _sample, NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction)
{
return eval(_sample, interaction.isotropic);
}

sample_type generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector2_type u)
template<typename C=bool_constant<!IsBSDF> >
enable_if_t<C::value && !IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector2_type u)
{
// static_assert(!IsBSDF);
ray_dir_info_type L;
L.direction = sampling::ProjectedHemisphere<scalar_type>::generate(u);
L.setDirection(sampling::ProjectedHemisphere<scalar_type>::generate(u));
return sample_type::createFromTangentSpace(L, interaction.getFromTangentSpace());
}

sample_type generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector3_type u)
template<typename C=bool_constant<IsBSDF> >
enable_if_t<C::value && IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector3_type u)
{
// static_assert(IsBSDF);
vector3_type _u = u;
ray_dir_info_type L;
L.direction = sampling::ProjectedSphere<scalar_type>::generate(u);
L.setDirection(sampling::ProjectedSphere<scalar_type>::generate(_u));
return sample_type::createFromTangentSpace(L, interaction.getFromTangentSpace());
}
template<typename C=bool_constant<!IsBSDF> >
enable_if_t<C::value && !IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(isotropic_interaction_type) interaction, const vector2_type u)
{
return generate(anisotropic_interaction_type::create(interaction), u);
}
template<typename C=bool_constant<IsBSDF> >
enable_if_t<C::value && IsBSDF, sample_type> generate(NBL_CONST_REF_ARG(isotropic_interaction_type) interaction, const vector3_type u)
{
return generate(anisotropic_interaction_type::create(interaction), u);
}

scalar_type pdf(NBL_CONST_REF_ARG(sample_type) _sample)
{
Expand All @@ -102,6 +116,10 @@ struct SOrenNayarBase
query.VdotL = hlsl::dot(interaction.getV().getDirection(), _sample.getL().getDirection());
return __quotient_and_pdf<SQuery>(query, _sample, interaction);
}
quotient_pdf_type quotient_and_pdf(NBL_CONST_REF_ARG(sample_type) _sample, NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction)
{
return quotient_and_pdf(_sample, interaction.isotropic);
}

scalar_type A2;
vector2_type AB;
Expand Down
Loading
Loading