Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4b3224a
initial iridescent fresnel, only single channel ior
keptsecret Aug 26, 2025
9c71906
iridescent fresnel does rgb IOR, use in brdf
keptsecret Aug 26, 2025
0f51306
some bug fixes
keptsecret Aug 27, 2025
f205d4e
replace loop for vector operations in fresnel
keptsecret Aug 27, 2025
f6daa6f
added iridescent btdf
keptsecret Aug 27, 2025
09402ea
added unit tests
keptsecret Aug 27, 2025
a77c337
merge bxdfs, fix conflicts
keptsecret Aug 28, 2025
aa0f6e8
latest example
keptsecret Aug 28, 2025
d2cb193
moved colorspace transform mats into struct functions
keptsecret Aug 28, 2025
33fc955
some more colorspace utility
keptsecret Aug 28, 2025
0f6c7a2
merge latest bxdf_fixes, fix conflicts
keptsecret Nov 3, 2025
d8b6773
restore encode/decode matrices
keptsecret Nov 3, 2025
65239d9
colorspace specific dominant wavelengths (still missing ACES), use gl…
keptsecret Nov 3, 2025
9a8b77e
update iridescent fresnel to match fresnel concept
keptsecret Nov 3, 2025
702ec8d
Merge branch 'master' into iridescence_bxdf
keptsecret Nov 4, 2025
76ad0ed
minor typo fixes
keptsecret Nov 4, 2025
53c930f
minor fixes to cook torrance, ndf infinity, move util functions into …
keptsecret Nov 4, 2025
23de8ed
changes to angle adding usage
keptsecret Nov 4, 2025
ff9e03f
better orthonormality for H
keptsecret Nov 4, 2025
18b3922
minor change to ggx clamp
keptsecret Nov 4, 2025
a5d8f5c
Merge branch 'master' into iridescence_bxdf
keptsecret Nov 5, 2025
f3dd05c
minor changes to create complex_t in angle_adding
keptsecret Nov 5, 2025
68d3614
refactor out common section of cook torrance generate
keptsecret Nov 5, 2025
aebfecf
added luma contribution hint, getPrefixThroughputWeights to interacti…
keptsecret Nov 6, 2025
b53fa1b
cook torrance bsdf can use spectral fresnel, uses interaction.getPref…
keptsecret Nov 6, 2025
946b050
thin smooth dielectric use luma coeff from interaction
keptsecret Nov 6, 2025
1a2f561
split iridescent fresnel by SupportsTransmission, adjusted fresnel co…
keptsecret Nov 7, 2025
4b8a06b
fix edge cases for iridescent fresnel
keptsecret Nov 7, 2025
5782a49
removed redundant weight in interaction
keptsecret Nov 7, 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
280 changes: 140 additions & 140 deletions include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl

Large diffs are not rendered by default.

32 changes: 21 additions & 11 deletions include/nbl/builtin/hlsl/bxdf/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@ NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_TYPE)(T::ray_dir_info_type))
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_TYPE)(T::vector3_type))
((NBL_CONCEPT_REQ_TYPE)(T::spectral_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getV()), ::nbl::hlsl::is_same_v, typename T::ray_dir_info_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getN()), ::nbl::hlsl::is_same_v, typename T::vector3_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getNdotV(clampMode)), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getNdotV2()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getPathOrigin()), ::nbl::hlsl::is_same_v, PathOrigin))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getLuminosityContributionHint()), ::nbl::hlsl::is_same_v, typename T::spectral_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(normV,normN)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ray_dir_info::Basic, typename T::ray_dir_info_type))
);
Expand All @@ -202,21 +204,24 @@ NBL_CONCEPT_END(
#undef iso
#include <nbl/builtin/hlsl/concepts/__end.hlsl>

template<class RayDirInfo NBL_PRIMARY_REQUIRES(ray_dir_info::Basic<RayDirInfo>)
template<class RayDirInfo, class Spectrum NBL_PRIMARY_REQUIRES(ray_dir_info::Basic<RayDirInfo> && concepts::FloatingPointLikeVectorial<Spectrum>)
struct SIsotropic
{
using this_t = SIsotropic<RayDirInfo, Spectrum>;
using ray_dir_info_type = RayDirInfo;
using scalar_type = typename RayDirInfo::scalar_type;
using vector3_type = typename RayDirInfo::vector3_type;
using spectral_type = vector3_type;

// WARNING: Changed since GLSL, now arguments need to be normalized!
static SIsotropic<RayDirInfo> create(NBL_CONST_REF_ARG(RayDirInfo) normalizedV, const vector3_type normalizedN)
static this_t create(NBL_CONST_REF_ARG(RayDirInfo) normalizedV, const vector3_type normalizedN)
{
SIsotropic<RayDirInfo> retval;
this_t retval;
retval.V = normalizedV;
retval.N = normalizedN;
retval.NdotV = nbl::hlsl::dot<vector3_type>(retval.N, retval.V.getDirection());
retval.NdotV2 = retval.NdotV * retval.NdotV;
retval.luminosityContributionHint = hlsl::promote<spectral_type>(1.0);

return retval;
}
Expand All @@ -230,11 +235,14 @@ struct SIsotropic
scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return NdotV2; }

PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return PathOrigin::PO_SENSOR; }
spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return luminosityContributionHint; }

RayDirInfo V;
vector3_type N;
scalar_type NdotV;
scalar_type NdotV2;

spectral_type luminosityContributionHint;
};

#define NBL_CONCEPT_NAME Anisotropic
Expand Down Expand Up @@ -278,6 +286,7 @@ struct SAnisotropic
using scalar_type = typename ray_dir_info_type::scalar_type;
using vector3_type = typename ray_dir_info_type::vector3_type;
using matrix3x3_type = matrix<scalar_type, 3, 3>;
using spectral_type = typename isotropic_interaction_type::spectral_type;

// WARNING: Changed since GLSL, now arguments need to be normalized!
static this_t create(
Expand Down Expand Up @@ -319,6 +328,7 @@ struct SAnisotropic
scalar_type getNdotV(BxDFClampMode _clamp = BxDFClampMode::BCM_NONE) NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV(_clamp); }
scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV2(); }
PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return isotropic.getPathOrigin(); }
spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return isotropic.getLuminosityContributionHint(); }

vector3_type getT() NBL_CONST_MEMBER_FUNC { return T; }
vector3_type getB() NBL_CONST_MEMBER_FUNC { return B; }
Expand All @@ -345,7 +355,7 @@ struct SAnisotropic
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (_sample, T)
#define NBL_CONCEPT_PARAM_1 (inter, surface_interactions::SIsotropic<typename T::ray_dir_info_type>)
#define NBL_CONCEPT_PARAM_1 (inter, surface_interactions::SIsotropic<typename T::ray_dir_info_type, typename T::vector3_type>)
#define NBL_CONCEPT_PARAM_2 (rdirinfo, typename T::ray_dir_info_type)
#define NBL_CONCEPT_PARAM_3 (pV, typename T::vector3_type)
#define NBL_CONCEPT_PARAM_4 (frame, typename T::matrix3x3_type)
Expand Down Expand Up @@ -376,7 +386,7 @@ NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(rdirinfo,pV)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(rdirinfo,pV,pV,pV)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(rdirinfo,pV,pV,pNdotL)), ::nbl::hlsl::is_same_v, T))
// ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<typename T::ray_dir_info_type> >(pV,inter)), ::nbl::hlsl::is_same_v, T)) // NOTE: temporarily commented out due to dxc bug https://github.com/microsoft/DirectXShaderCompiler/issues/7154
// ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<typename T::ray_dir_info_type, typename T::vector3_type> >(pV,inter)), ::nbl::hlsl::is_same_v, T)) // NOTE: temporarily commented out due to dxc bug https://github.com/microsoft/DirectXShaderCompiler/issues/7154
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((_sample.getTangentSpaceL()), ::nbl::hlsl::is_same_v, typename T::vector3_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createInvalid()), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ray_dir_info::Basic, typename T::ray_dir_info_type))
Expand Down Expand Up @@ -525,7 +535,7 @@ NBL_CONCEPT_END(
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (cache, T)
#define NBL_CONCEPT_PARAM_1 (iso, surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> >)
#define NBL_CONCEPT_PARAM_1 (iso, surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type >)
#define NBL_CONCEPT_PARAM_2 (pNdotV, typename T::scalar_type)
#define NBL_CONCEPT_PARAM_3 (_sample, SLightSample<ray_dir_info::SBasic<typename T::scalar_type> >)
#define NBL_CONCEPT_PARAM_4 (V, typename T::vector3_type)
Expand All @@ -540,9 +550,9 @@ NBL_CONCEPT_BEGIN(6)
NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(pNdotV,pNdotV,pNdotV,pNdotV)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(pNdotV,pNdotV,pNdotV)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(V,V,V,eta,V)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample,eta,V)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample,eta,V)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ReadableIsotropicMicrofacetCache, T))
);
#undef eta
Expand Down Expand Up @@ -698,7 +708,7 @@ struct SIsotropicMicrofacetCache
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (cache, T)
#define NBL_CONCEPT_PARAM_1 (aniso, surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> > >)
#define NBL_CONCEPT_PARAM_1 (aniso, surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type > >)
#define NBL_CONCEPT_PARAM_2 (pNdotL, typename T::scalar_type)
#define NBL_CONCEPT_PARAM_3 (_sample, SLightSample<ray_dir_info::SBasic<typename T::scalar_type> >)
#define NBL_CONCEPT_PARAM_4 (V, typename T::vector3_type)
Expand All @@ -724,9 +734,9 @@ NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(V,V)), ::nbl::hlsl::is_same_v, T))
// ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(V,V,b0,rcp_eta)), ::nbl::hlsl::is_same_v, T)) // TODO: refuses to compile when arg4 is rcp_eta for some reason, eta is fine
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(V,V,pNdotL)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(V,V,V,V,V,eta,V)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample,eta)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample,eta)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createPartial(pNdotL,pNdotL,pNdotL,b0,rcp_eta)), ::nbl::hlsl::is_same_v, T))
((NBL_CONCEPT_REQ_EXPR)(cache.fillTangents(V,V,V)))
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(CreatableIsotropicMicrofacetCache, typename T::isocache_type))
Expand Down
Loading
Loading