Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
02d6d0f
initial example
keptsecret Feb 4, 2025
129b50e
use bxdf creation params struct
keptsecret Feb 6, 2025
74261dc
triangle and rectangle shapes
keptsecret Feb 7, 2025
ab3ae20
more sampling methods
keptsecret Feb 10, 2025
355cfec
spherical rectangle
keptsecret Feb 11, 2025
ebf8fca
merge pcg fix from upstream
keptsecret Feb 12, 2025
11180f4
fix aniso cache bug
keptsecret Feb 17, 2025
4516051
init func to modify bxdf params directly
keptsecret Feb 18, 2025
d9a00c9
bug fixes
keptsecret Feb 20, 2025
ffe9029
fix sampling bugs #2
keptsecret Feb 21, 2025
cee192e
update to master
keptsecret Feb 21, 2025
b207312
fix rank type trait for matrix/vector
keptsecret Feb 21, 2025
673f788
merge hlsl bxdfs, resolve conflict
keptsecret Feb 25, 2025
69a257d
temporary fix for dxc bug issue 7154
keptsecret Feb 25, 2025
866e6d7
some bug fixes again
keptsecret Feb 26, 2025
85e955f
fix wrong template usage
keptsecret Feb 27, 2025
3b167ab
merge changes from hlsl_bxdf
keptsecret Feb 28, 2025
19e3a35
merge master/bxdf fixes, resolve conflicts
keptsecret Mar 3, 2025
6b5bf06
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 4, 2025
7b574da
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 4, 2025
1c773d9
fix typo
keptsecret Mar 4, 2025
326c885
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 5, 2025
6132a4e
Merge branch 'revert-some-device-limits' into hlsl_path_tracer_example
keptsecret Mar 6, 2025
0bd26c7
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Mar 6, 2025
ebb1b15
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 7, 2025
7cb977d
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 7, 2025
67c525e
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Mar 10, 2025
a8f209e
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 11, 2025
e8d2ed8
fixed some func usage to nbl ver
keptsecret Mar 14, 2025
c47f446
specify template args
keptsecret Mar 17, 2025
642e46d
fix merge conflicts
keptsecret Mar 17, 2025
1137b6b
update to latest example
keptsecret Mar 17, 2025
5cd4e6c
merge math, fix conflict
keptsecret Mar 19, 2025
7e8dd81
latest example
keptsecret Mar 19, 2025
f86dd0c
Merge remote-tracking branch 'origin/intrinsics_adjustments' into hls…
keptsecret Mar 21, 2025
b154638
fix use of static const in func
keptsecret Mar 21, 2025
7892563
added more morton order stuff
keptsecret Mar 24, 2025
b21b789
latest example
keptsecret Mar 28, 2025
1f461ff
merge master, fix conflicts
keptsecret Apr 3, 2025
df2321a
merge hlsl_bxdfs, fix conflicts
keptsecret Jun 26, 2025
26adf95
latest example
keptsecret Jun 27, 2025
0d80626
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Jun 27, 2025
36910c6
latest example fixes
keptsecret Jun 30, 2025
afc3485
merge bxdf, fix conflicts
keptsecret Aug 28, 2025
19ba15d
Updated examples
Przemog1 Sep 25, 2025
7ec3f39
Created RWMC files
Przemog1 Oct 18, 2025
4dcf56a
Updated examples
Przemog1 Oct 20, 2025
dbbb30a
merge master, fix conflicts
keptsecret Nov 12, 2025
3ae69fa
updated example
keptsecret Nov 12, 2025
1f9bf16
merge iridescent_bxdf, fix conflicts (hope it's merged to master soon)
keptsecret Nov 12, 2025
4cfed1b
use new angle adder
keptsecret Nov 13, 2025
8ecfecf
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Nov 13, 2025
dc8b5bc
initialize invalid ndf return to inf, not 0
keptsecret Nov 13, 2025
434234c
derive trait from cook torrance base
keptsecret Nov 13, 2025
ffeb633
fix angle adder
keptsecret Nov 13, 2025
d75246d
optimizations to iridescent fresnel
keptsecret Nov 13, 2025
494c625
avoid repeat fresnel calc
keptsecret Nov 13, 2025
ab25c17
mix reflectance w/ transmission in getScaledReflectance
keptsecret Nov 13, 2025
2a7db14
Refactored resolve.hlsl
Przemog1 Nov 13, 2025
1acf7d6
some minor fixes to fresnel orientedEta usage
keptsecret Nov 14, 2025
72429cb
refactor usage of angle adding
keptsecret Nov 14, 2025
381bb50
temp? fix for mix_helper on floats
keptsecret Nov 14, 2025
482ef2e
merge rwmc, fix conflicts
keptsecret Nov 14, 2025
a40a025
added missing typename qualifier
keptsecret Nov 14, 2025
b3f6d55
Fixed `ResolveAccessor` concept
Przemog1 Nov 14, 2025
cf6760e
minor fixes to spherical rect, latest example
keptsecret Nov 17, 2025
4a283ba
quaternion struct, renamed spherical tri/rect shapes
keptsecret Nov 18, 2025
0305948
make PartitionRandVar in struct and templated
keptsecret Nov 18, 2025
3134254
precompute values in linear, bilinear sampling; make box muller a struct
keptsecret Nov 18, 2025
8d744a9
precompute cos_sides, csc_sides in shape spherical_tri
keptsecret Nov 19, 2025
2a22cb6
merge new rwmc fix
keptsecret Nov 19, 2025
8292707
fix spherical tri precompute
keptsecret Nov 20, 2025
563e072
latest example
keptsecret Nov 25, 2025
4abbacf
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Nov 25, 2025
229929d
update examples
Erfan-Ahmadi Nov 25, 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 examples_tests
Submodule examples_tests updated 35 files
+2 −2 28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl
+37 −0 31_HLSLPathTracer/CMakeLists.txt
+837 −0 31_HLSLPathTracer/app_resources/glsl/common.glsl
+182 −0 31_HLSLPathTracer/app_resources/glsl/litByRectangle.comp
+60 −0 31_HLSLPathTracer/app_resources/glsl/litBySphere.comp
+105 −0 31_HLSLPathTracer/app_resources/glsl/litByTriangle.comp
+34 −0 31_HLSLPathTracer/app_resources/hlsl/accumulator.hlsl
+53 −0 31_HLSLPathTracer/app_resources/hlsl/common.hlsl
+338 −0 31_HLSLPathTracer/app_resources/hlsl/example_common.hlsl
+73 −0 31_HLSLPathTracer/app_resources/hlsl/intersector.hlsl
+177 −0 31_HLSLPathTracer/app_resources/hlsl/material_system.hlsl
+382 −0 31_HLSLPathTracer/app_resources/hlsl/next_event_estimator.hlsl
+262 −0 31_HLSLPathTracer/app_resources/hlsl/pathtracer.hlsl
+19 −0 31_HLSLPathTracer/app_resources/hlsl/present.frag.hlsl
+29 −0 31_HLSLPathTracer/app_resources/hlsl/rand_gen.hlsl
+75 −0 31_HLSLPathTracer/app_resources/hlsl/ray_gen.hlsl
+266 −0 31_HLSLPathTracer/app_resources/hlsl/render.comp.hlsl
+64 −0 31_HLSLPathTracer/app_resources/hlsl/render_common.hlsl
+17 −0 31_HLSLPathTracer/app_resources/hlsl/render_rwmc_common.hlsl
+41 −0 31_HLSLPathTracer/app_resources/hlsl/resolve.comp.hlsl
+15 −0 31_HLSLPathTracer/app_resources/hlsl/resolve_common.hlsl
+7 −0 31_HLSLPathTracer/app_resources/hlsl/rwmc_global_settings_common.hlsl
+177 −0 31_HLSLPathTracer/app_resources/hlsl/scene.hlsl
+28 −0 31_HLSLPathTracer/config.json.template
+17 −0 31_HLSLPathTracer/include/nbl/this_example/common.hpp
+1,641 −0 31_HLSLPathTracer/main.cpp
+50 −0 31_HLSLPathTracer/pipeline.groovy
+10 −14 66_HLSLBxDFTests/CMakeLists.txt
+0 −31 66_HLSLBxDFTests/app_resources/config.json
+0 −105 66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl
+0 −382 66_HLSLBxDFTests/app_resources/test_components.hlsl
+344 −905 66_HLSLBxDFTests/app_resources/tests.hlsl
+0 −610 66_HLSLBxDFTests/app_resources/tests_common.hlsl
+33 −321 66_HLSLBxDFTests/main.cpp
+2 −0 CMakeLists.txt
17 changes: 17 additions & 0 deletions include/nbl/builtin/glsl/utils/morton.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ uint nbl_glsl_morton_decode2d8bComponent(in uint x)
return x;
}

uint nbl_glsl_morton_decode2d32bComponent(in uint x)
{
x &= 0x55555555u;
x = (x ^ (x >> 1u)) & 0x33333333u;
x = (x ^ (x >> 2u)) & 0x0f0f0f0fu;
x = (x ^ (x >> 4u)) & 0x00ff00ffu;
x = (x ^ (x >> 8u)) & 0x0000ffffu;
x = (x ^ (x >> 16u));
return x;
}


uvec2 nbl_glsl_morton_decode2d4b(in uint x)
{
return uvec2(nbl_glsl_morton_decode2d4bComponent(x), nbl_glsl_morton_decode2d4bComponent(x >> 1u));
Expand All @@ -32,4 +44,9 @@ uvec2 nbl_glsl_morton_decode2d8b(in uint x)
return uvec2(nbl_glsl_morton_decode2d8bComponent(x), nbl_glsl_morton_decode2d8bComponent(x >> 1u));
}

uvec2 nbl_glsl_morton_decode2d32b(in uint x)
{
return uvec2(nbl_glsl_morton_decode2d32bComponent(x), nbl_glsl_morton_decode2d32bComponent(x >> 1u));
}

#endif
52 changes: 35 additions & 17 deletions include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "nbl/builtin/hlsl/bxdf/config.hlsl"
#include "nbl/builtin/hlsl/bxdf/ndf.hlsl"
#include "nbl/builtin/hlsl/bxdf/fresnel.hlsl"
#include "nbl/builtin/hlsl/sampling/basic.hlsl"
#include "nbl/builtin/hlsl/bxdf/ndf/microfacet_to_light_transform.hlsl"

namespace nbl
Expand Down Expand Up @@ -130,19 +131,22 @@ struct SCookTorrance

template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
typename C=bool_constant<!fresnel_type::ReturnsMonochrome> NBL_FUNC_REQUIRES(C::value && !fresnel_type::ReturnsMonochrome)
static scalar_type __getScaledReflectance(NBL_CONST_REF_ARG(fresnel_type) orientedFresnel, NBL_CONST_REF_ARG(Interaction) interaction, scalar_type clampedVdotH)
static scalar_type __getScaledReflectance(NBL_CONST_REF_ARG(fresnel_type) orientedFresnel, NBL_CONST_REF_ARG(Interaction) interaction, scalar_type clampedVdotH, bool transmitted, NBL_REF_ARG(spectral_type) outFresnelVal)
{
spectral_type throughputWeights = interaction.getLuminosityContributionHint();
return hlsl::dot<spectral_type>(impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(orientedFresnel(clampedVdotH)), throughputWeights);
spectral_type reflectance = orientedFresnel(clampedVdotH);
outFresnelVal = hlsl::mix(reflectance, hlsl::promote<spectral_type>(1.0)-reflectance, transmitted);
return hlsl::dot<spectral_type>(outFresnelVal, throughputWeights);
}
template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
typename C=bool_constant<fresnel_type::ReturnsMonochrome> NBL_FUNC_REQUIRES(C::value && fresnel_type::ReturnsMonochrome)
static scalar_type __getScaledReflectance(NBL_CONST_REF_ARG(fresnel_type) orientedFresnel, NBL_CONST_REF_ARG(Interaction) interaction, scalar_type clampedVdotH)
static scalar_type __getScaledReflectance(NBL_CONST_REF_ARG(fresnel_type) orientedFresnel, NBL_CONST_REF_ARG(Interaction) interaction, scalar_type clampedVdotH, bool transmitted, NBL_REF_ARG(spectral_type) outFresnelVal)
{
return orientedFresnel(clampedVdotH)[0];
scalar_type reflectance = orientedFresnel(clampedVdotH)[0];
return hlsl::mix(reflectance, scalar_type(1.0)-reflectance, transmitted);
}

bool __dotIsUnity(const vector3_type a, const vector3_type b, const scalar_type value)
bool __dotIsValue(const vector3_type a, const vector3_type b, const scalar_type value)
{
const scalar_type ab = hlsl::dot(a, b);
return hlsl::max(ab, value / ab) <= scalar_type(value + 1e-3);
Expand Down Expand Up @@ -209,11 +213,11 @@ struct SCookTorrance
ray_dir_info_type V = interaction.getV();
const matrix3x3_type fromTangent = interaction.getFromTangentSpace();
// tangent frame orthonormality
assert(__dotIsUnity(fromTangent[0],fromTangent[1],0.0));
assert(__dotIsUnity(fromTangent[1],fromTangent[2],0.0));
assert(__dotIsUnity(fromTangent[2],fromTangent[0],0.0));
assert(__dotIsValue(fromTangent[0],fromTangent[1],0.0));
assert(__dotIsValue(fromTangent[1],fromTangent[2],0.0));
assert(__dotIsValue(fromTangent[2],fromTangent[0],0.0));
// NDF sampling produced a unit length direction
assert(__dotIsUnity(localH,localH,1.0));
assert(__dotIsValue(localH,localH,1.0));
const vector3_type H = hlsl::mul(interaction.getFromTangentSpace(), localH);
Refract<scalar_type> r = Refract<scalar_type>::create(V.getDirection(), H);

Expand Down Expand Up @@ -294,11 +298,13 @@ struct SCookTorrance
assert(NdotV*VdotH >= scalar_type(0.0));
}

const scalar_type reflectance = __getScaledReflectance(_f, interaction, hlsl::abs(VdotH));
spectral_type dummy;
const scalar_type reflectance = __getScaledReflectance(_f, interaction, hlsl::abs(VdotH), false, dummy);

scalar_type rcpChoiceProb;
scalar_type z = u.z;
bool transmitted = math::partitionRandVariable(reflectance, z, rcpChoiceProb);
sampling::PartitionRandVariable<scalar_type> partitionRandVariable;
bool transmitted = partitionRandVariable(reflectance, z, rcpChoiceProb);

const scalar_type LdotH = hlsl::mix(VdotH, ieee754::copySign(hlsl::sqrt(rcpEta.value2[0]*VdotH*VdotH + scalar_type(1.0) - rcpEta.value2[0]), -VdotH), transmitted);
bool valid;
Expand Down Expand Up @@ -337,8 +343,9 @@ struct SCookTorrance

NBL_IF_CONSTEXPR(IsBSDF)
{
const scalar_type reflectance = __getScaledReflectance(_f, interaction, hlsl::abs(cache.getVdotH()));
return hlsl::mix(reflectance, scalar_type(1.0) - reflectance, cache.isTransmission()) * DG1.projectedLightMeasure;
spectral_type dummy;
const scalar_type reflectance = __getScaledReflectance(_f, interaction, hlsl::abs(cache.getVdotH()), cache.isTransmission(), dummy);
return reflectance * DG1.projectedLightMeasure;
}
else
{
Expand Down Expand Up @@ -389,10 +396,9 @@ struct SCookTorrance
quo = hlsl::promote<spectral_type>(G2_over_G1);
else
{
const scalar_type scaled_reflectance = __getScaledReflectance(_f, interaction, hlsl::abs(cache.getVdotH()));
spectral_type reflectance = impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call(_f(hlsl::abs(cache.getVdotH())));
quo = hlsl::mix(reflectance / scaled_reflectance,
(hlsl::promote<spectral_type>(1.0) - reflectance) / (scalar_type(1.0) - scaled_reflectance), cache.isTransmission()) * G2_over_G1;
spectral_type reflectance;
const scalar_type scaled_reflectance = __getScaledReflectance(_f, interaction, hlsl::abs(cache.getVdotH()), cache.isTransmission(), reflectance);
quo = reflectance / scaled_reflectance * G2_over_G1;
}
}
else
Expand All @@ -409,6 +415,18 @@ struct SCookTorrance
fresnel_type fresnel; // always front-facing
};


template<class Config, class N, class F>
struct traits<SCookTorrance<Config,N,F> >
{
using __type = SCookTorrance<Config,N,F>;

NBL_CONSTEXPR_STATIC_INLINE BxDFType type = conditional_value<__type::IsBSDF, BxDFType, BxDFType::BT_BSDF, BxDFType::BT_BRDF>::value;
NBL_CONSTEXPR_STATIC_INLINE bool IsMicrofacet = true;
NBL_CONSTEXPR_STATIC_INLINE bool clampNdotV = !__type::IsBSDF;
NBL_CONSTEXPR_STATIC_INLINE bool clampNdotL = !__type::IsBSDF;
};

}
}
}
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/builtin/hlsl/bxdf/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ struct SIsotropicMicrofacetCache

// not coming from the medium (reflected) OR
// exiting at the macro scale AND ( (not L outside the cone of possible directions given IoR with constraint VdotH*LdotH<0.0) OR (microfacet not facing toward the macrosurface, i.e. non heightfield profile of microsurface) )
const bool valid = ComputeMicrofacetNormal<scalar_type>::isValidMicrofacet(transmitted, VdotL, retval.absNdotH, computeMicrofacetNormal.orientedEta);
const bool valid = ComputeMicrofacetNormal<scalar_type>::isValidMicrofacet(transmitted, VdotL, retval.absNdotH, fresnel::OrientedEtas<monochrome_type>::create(1.0, computeMicrofacetNormal.orientedEta));
if (valid)
{
retval.VdotH = hlsl::dot<vector3_type>(computeMicrofacetNormal.V,H);
Expand All @@ -638,7 +638,7 @@ struct SIsotropicMicrofacetCache
const bool transmitted = ComputeMicrofacetNormal<scalar_type>::isTransmissionPath(NdotV,NdotL);

ComputeMicrofacetNormal<scalar_type> computeMicrofacetNormal = ComputeMicrofacetNormal<scalar_type>::create(V,L,N,1.0);
computeMicrofacetNormal.orientedEta = orientedEtas;
computeMicrofacetNormal.orientedEta = orientedEtas.value[0];

return create(transmitted, computeMicrofacetNormal, VdotL, N, H);
}
Expand All @@ -664,7 +664,7 @@ struct SIsotropicMicrofacetCache
const bool transmitted = ComputeMicrofacetNormal<scalar_type>::isTransmissionPath(interaction.getNdotV(),_sample.getNdotL());

ComputeMicrofacetNormal<scalar_type> computeMicrofacetNormal = ComputeMicrofacetNormal<scalar_type>::create(V,L,N,1.0);
computeMicrofacetNormal.orientedEta = orientedEtas;
computeMicrofacetNormal.orientedEta = orientedEtas.value[0];

return create(transmitted, computeMicrofacetNormal, hlsl::dot<vector3_type>(V, L), N, H);
}
Expand Down
Loading
Loading