Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
83 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
3519866
overwrite DG concept, added Dcorrelated to ggx ndf with optimizations
keptsecret Oct 13, 2025
2a7cf4b
fix pdf call
keptsecret Oct 13, 2025
79aea6d
minor fixes to cook torrance generate
keptsecret Oct 14, 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 include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct SCookTorrance
using fresnel_type = F;

NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = ndf_type::IsAnisotropic;
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = ndf_type::NDFSurfaceType != ndf::MTT_REFLECT;
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = ndf_type::SupportedPaths != ndf::MTT_REFLECT;

template<class Interaction, class MicrofacetCache>
static bool __checkValid(NBL_CONST_REF_ARG(fresnel_type) f, NBL_CONST_REF_ARG(sample_type) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
Copy link
Member Author

Choose a reason for hiding this comment

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

why make static and pass the f if its your member?

Copy link
Member Author

@devshgraphicsprogramming devshgraphicsprogramming Oct 8, 2025

Choose a reason for hiding this comment

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

is it because the fresnel is already properly oriented? then give f a clear name like reorientedFresnel

and since its static you may as well make the __checkValid into a standalone struct functor with a partial spec on IsBSDF, that way you don't call impl::check_TIR_helper but you can call cache.isValid(reorientedFresnel.getRefractionOrientedEta()) directly

Copy link
Member Author

Choose a reason for hiding this comment

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

actually if you use impl::checkValid<IsBSDF>::template __call() here

const bool notTIR = impl::check_TIR_helper<fresnel_type, IsBSDF>::template __call<MicrofacetCache>(_f, cache);
assert(notTIR);

then there's no need to have an impl::check_TIR_helper at all

Expand Down
38 changes: 23 additions & 15 deletions include/nbl/builtin/hlsl/bxdf/ndf.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ namespace bxdf
namespace ndf
{

namespace impl
{
template<typename T>
struct NDFQuantQuery
{
using scalar_type = T;

scalar_type getVdotHLdotH() NBL_CONST_MEMBER_FUNC { return VdotHLdotH; }
scalar_type getVdotH_etaLdotH() NBL_CONST_MEMBER_FUNC { return VdotH_etaLdotH; }

scalar_type VdotHLdotH;
scalar_type VdotH_etaLdotH;
};
}

namespace dummy_impl
{
using sample_t = SLightSample<ray_dir_info::SBasic<float> >;
Expand Down Expand Up @@ -76,6 +61,29 @@ NBL_CONCEPT_END(
#undef ndf
#include <nbl/builtin/hlsl/concepts/__end.hlsl>


#define NDF_CONSTEXPR_DECLS(ANISO,REFLECT_REFRACT) NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = ANISO;\
NBL_CONSTEXPR_STATIC_INLINE MicrofacetTransformTypes SupportedPaths = REFLECT_REFRACT;\
NBL_CONSTEXPR_STATIC_INLINE bool SupportsTransmission = REFLECT_REFRACT != MTT_REFLECT;\
NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = SupportsTransmission ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_NONE;\
template<class Interaction>\
NBL_CONSTEXPR_STATIC_INLINE bool RequiredInteraction = IsAnisotropic ? surface_interactions::Anisotropic<Interaction> : surface_interactions::Isotropic<Interaction>;\
template<class MicrofacetCache>\
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;\

// help avoid preprocessor splitting template declarations by comma
#define SINGLE_ARG(...) __VA_ARGS__
Copy link
Member Author

Choose a reason for hiding this comment

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

if you want a global macro, make it NDF prefixed.

Also all macros need NBL_HLSL prefix


#define NDF_TYPE_ALIASES(N,BASE,DG1_QUERY,G2_QUERY,QUANT_QUERY) using this_t = N;\
using scalar_type = T;\
using base_type = BASE;\
using quant_type = SDualMeasureQuant<scalar_type>;\
using vector2_type = vector<T, 2>;\
using vector3_type = vector<T, 3>;\
using dg1_query_type = DG1_QUERY;\
using g2g1_query_type = G2_QUERY;\
using quant_query_type = QUANT_QUERY;\

}
}
}
Expand Down
55 changes: 18 additions & 37 deletions include/nbl/builtin/hlsl/bxdf/ndf/beckmann.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -298,24 +298,8 @@ struct BeckmannGenerateH
template<typename T, bool _IsAnisotropic, MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T>)
struct Beckmann
{
using this_t = Beckmann<T, _IsAnisotropic, reflect_refract>;
using scalar_type = T;
using base_type = impl::BeckmannCommon<T,_IsAnisotropic>;
using quant_type = SDualMeasureQuant<scalar_type>;
using vector2_type = vector<T, 2>;
using vector3_type = vector<T, 3>;

using dg1_query_type = impl::SBeckmannDG1Query<scalar_type>;
using g2g1_query_type = impl::SBeckmannG2overG1Query<scalar_type>;
using quant_query_type = impl::NDFQuantQuery<scalar_type>;

NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic;
NBL_CONSTEXPR_STATIC_INLINE MicrofacetTransformTypes NDFSurfaceType = reflect_refract;
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT;
template<class Interaction>
NBL_CONSTEXPR_STATIC_INLINE bool RequiredInteraction = IsAnisotropic ? surface_interactions::Anisotropic<Interaction> : surface_interactions::Isotropic<Interaction>;
template<class MicrofacetCache>
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;
NDF_CONSTEXPR_DECLS(_IsAnisotropic,reflect_refract);
NDF_TYPE_ALIASES(SINGLE_ARG(Beckmann<T,IsAnisotropic,SupportedPaths>), SINGLE_ARG(impl::BeckmannCommon<T,IsAnisotropic>), impl::SBeckmannDG1Query<scalar_type>, impl::SBeckmannG2overG1Query<scalar_type>, DualMeasureQuantQuery<scalar_type>);
Copy link
Member Author

Choose a reason for hiding this comment

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

You could structure the macro to take a BOOST_PP tuple

NDF_TYPE_ALIASES((Beckmann<T,IsAnisotropic,SupportedPaths>)(impl::BeckmannCommon<T,IsAnisotropic>)(impl::SBeckmannDG1Query<scalar_type>)(impl::SBeckmannG2overG1Query<scalar_type>)(DualMeasureQuantQuery<scalar_type>))

and then get the args via BOOST_PP_TUPLE_ELEM

Copy link
Contributor

Choose a reason for hiding this comment

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

Tuple is comma separated. Seq?


template<typename C=bool_constant<!IsAnisotropic> >
static enable_if_t<C::value && !IsAnisotropic, this_t> create(scalar_type A)
Expand All @@ -338,18 +322,15 @@ struct Beckmann
return retval;
}

template<class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && !IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
template<class MicrofacetCache NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
quant_query_type createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
{
quant_query_type dummy; // brdfs don't make use of this
return dummy;
}
template<class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
{
quant_query_type quant_query;
quant_query.VdotHLdotH = cache.getVdotHLdotH();
quant_query.VdotH_etaLdotH = cache.getVdotH() + orientedEta * cache.getLdotH();
quant_query_type quant_query; // only has members for refraction
if (SupportsTransmission)
{
quant_query.VdotHLdotH = cache.getVdotHLdotH();
Copy link
Member Author

Choose a reason for hiding this comment

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

add a comment that even though in PBRT its abs(VdotH)*abs(LdotH) we leverage that under transmission the sign must always be negattive and rest of the code accounts for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

or where the getVdotHLdotH concept check is defined

quant_query.VdotH_etaLdotH = cache.getVdotH() + orientedEta * cache.getLdotH();
}
return quant_query;
}
template<class Interaction, class MicrofacetCache, typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES(RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
Expand Down Expand Up @@ -390,27 +371,27 @@ struct Beckmann
return __generate_base.__call(localV, u);
}

template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && !IsBSDF, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && !SupportsTransmission, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
{
scalar_type d = __ndf_base.template D<MicrofacetCache>(cache);
return createDualMeasureQuantity<T>(d, interaction.getNdotV(BxDFClampMode::BCM_MAX), _sample.getNdotL(BxDFClampMode::BCM_MAX));
}
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && IsBSDF, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && SupportsTransmission, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
{
scalar_type d = __ndf_base.template D<MicrofacetCache>(cache);
return createDualMeasureQuantity<T, reflect_refract>(d, interaction.getNdotV(BxDFClampMode::BCM_ABS), _sample.getNdotL(BxDFClampMode::BCM_ABS), quant_query.getVdotHLdotH(), quant_query.getVdotH_etaLdotH());
}

template<class LS, class Interaction, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && !IsBSDF, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
template<class LS, class Interaction, typename C=bool_constant<!SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && !SupportsTransmission, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
{
scalar_type dg1 = base_type::template DG1<dg1_query_type>(query);
return createDualMeasureQuantity<T>(dg1, interaction.getNdotV(BxDFClampMode::BCM_MAX), _sample.getNdotL(BxDFClampMode::BCM_MAX));
}
template<class LS, class Interaction, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && IsBSDF, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
template<class LS, class Interaction, typename C=bool_constant<SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && SupportsTransmission, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
{
scalar_type dg1 = base_type::template DG1<dg1_query_type>(query);
return createDualMeasureQuantity<T, reflect_refract>(dg1, interaction.getNdotV(BxDFClampMode::BCM_ABS), _sample.getNdotL(BxDFClampMode::BCM_ABS), quant_query.getVdotHLdotH(), quant_query.getVdotH_etaLdotH());
Expand Down
71 changes: 25 additions & 46 deletions include/nbl/builtin/hlsl/bxdf/ndf/ggx.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ struct SGGXG2XQuery
scalar_type devsh_l;
};

template<typename T, bool IsBSDF, bool IsAnisotropic=false NBL_STRUCT_CONSTRAINABLE>
template<typename T, bool SupportsTransmission, bool IsAnisotropic=false NBL_STRUCT_CONSTRAINABLE>
struct GGXCommon;

template<typename T, bool IsBSDF>
template<typename T, bool SupportsTransmission>
NBL_PARTIAL_REQ_TOP(concepts::FloatingPointScalar<T>)
struct GGXCommon<T,IsBSDF,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
struct GGXCommon<T,SupportsTransmission,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
{
using scalar_type = T;

NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = IsBSDF ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;
NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = SupportsTransmission ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;

// trowbridge-reitz
template<class MicrofacetCache NBL_FUNC_REQUIRES(ReadableIsotropicMicrofacetCache<MicrofacetCache>)
Expand Down Expand Up @@ -158,13 +158,13 @@ struct GGXCommon<T,IsBSDF,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScala
scalar_type one_minus_a2;
};

template<typename T, bool IsBSDF>
template<typename T, bool SupportsTransmission>
NBL_PARTIAL_REQ_TOP(concepts::FloatingPointScalar<T>)
struct GGXCommon<T,IsBSDF,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
struct GGXCommon<T,SupportsTransmission,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
{
using scalar_type = T;

NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = IsBSDF ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;
NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = SupportsTransmission ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;

template<class MicrofacetCache NBL_FUNC_REQUIRES(AnisotropicMicrofacetCache<MicrofacetCache>)
scalar_type D(NBL_CONST_REF_ARG(MicrofacetCache) cache)
Expand Down Expand Up @@ -278,26 +278,8 @@ struct GGXGenerateH
template<typename T, bool _IsAnisotropic, MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T>)
struct GGX
{
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic;
NBL_CONSTEXPR_STATIC_INLINE MicrofacetTransformTypes NDFSurfaceType = reflect_refract;
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT;

using this_t = GGX<T, _IsAnisotropic, reflect_refract>;
using scalar_type = T;
using base_type = impl::GGXCommon<T,IsBSDF,IsAnisotropic>;
using quant_type = SDualMeasureQuant<scalar_type>;
using vector2_type = vector<T, 2>;
using vector3_type = vector<T, 3>;

using dg1_query_type = impl::SGGXDG1Query<scalar_type>;
using g2g1_query_type = impl::SGGXG2XQuery<scalar_type>;
using quant_query_type = impl::NDFQuantQuery<scalar_type>;

NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = IsBSDF ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_NONE;
template<class Interaction>
NBL_CONSTEXPR_STATIC_INLINE bool RequiredInteraction = IsAnisotropic ? surface_interactions::Anisotropic<Interaction> : surface_interactions::Isotropic<Interaction>;
template<class MicrofacetCache>
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;
NDF_CONSTEXPR_DECLS(_IsAnisotropic,reflect_refract);
NDF_TYPE_ALIASES(SINGLE_ARG(GGX<T,IsAnisotropic,SupportedPaths>), SINGLE_ARG(impl::GGXCommon<T,SupportsTransmission,IsAnisotropic>), impl::SGGXDG1Query<scalar_type>, impl::SGGXG2XQuery<scalar_type>, DualMeasureQuantQuery<scalar_type>);

template<typename C=bool_constant<!IsAnisotropic> >
static enable_if_t<C::value && !IsAnisotropic, this_t> create(scalar_type A)
Expand All @@ -321,18 +303,15 @@ struct GGX
return retval;
}

template<class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && !IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
{
quant_query_type dummy; // brdfs don't make use of this
return dummy;
}
template<class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
template<class MicrofacetCache NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
quant_query_type createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
{
quant_query_type quant_query;
quant_query.VdotHLdotH = cache.getVdotHLdotH();
quant_query.VdotH_etaLdotH = cache.getVdotH() + orientedEta * cache.getLdotH();
quant_query_type quant_query; // only has members for refraction
if (SupportsTransmission)
{
quant_query.VdotHLdotH = cache.getVdotHLdotH();
quant_query.VdotH_etaLdotH = cache.getVdotH() + orientedEta * cache.getLdotH();
}
return quant_query;
}
template<class Interaction, class MicrofacetCache, typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES(RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
Expand Down Expand Up @@ -375,17 +354,17 @@ struct GGX
return __generate_base.__call(localV, u);
}

template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && !IsBSDF, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && !SupportsTransmission, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
{
scalar_type d = __ndf_base.template D<MicrofacetCache>(cache);
quant_type dmq;
dmq.microfacetMeasure = d;
dmq.projectedLightMeasure = d * _sample.getNdotL(BxDFClampMode::BCM_MAX);
return dmq;
}
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && IsBSDF, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
enable_if_t<C::value && SupportsTransmission, quant_type> D(NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, NBL_CONST_REF_ARG(MicrofacetCache) cache)
{
scalar_type d = __ndf_base.template D<MicrofacetCache>(cache);
quant_type dmq;
Expand All @@ -401,17 +380,17 @@ struct GGX
return dmq;
}

template<class LS, class Interaction, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && !IsBSDF, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
template<class LS, class Interaction, typename C=bool_constant<!SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && !SupportsTransmission, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
{
scalar_type dg1 = base_type::template DG1<dg1_query_type>(query);
quant_type dmq;
dmq.microfacetMeasure = dg1;
dmq.projectedLightMeasure = dg1;// TODO: figure this out * _sample.getNdotL(BxDFClampMode::BCM_MAX);
return dmq;
}
template<class LS, class Interaction, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && IsBSDF, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
template<class LS, class Interaction, typename C=bool_constant<SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>)
enable_if_t<C::value && SupportsTransmission, quant_type> DG1(NBL_CONST_REF_ARG(dg1_query_type) query, NBL_CONST_REF_ARG(quant_query_type) quant_query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
{
scalar_type dg1 = base_type::template DG1<dg1_query_type>(query);
quant_type dmq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ enum MicrofacetTransformTypes : uint16_t
MTT_REFLECT_REFRACT = 0b11
};

template<typename T>
struct DualMeasureQuantQuery
{
using scalar_type = T;

scalar_type getVdotHLdotH() NBL_CONST_MEMBER_FUNC { return VdotHLdotH; }
scalar_type getVdotH_etaLdotH() NBL_CONST_MEMBER_FUNC { return VdotH_etaLdotH; }

scalar_type VdotHLdotH;
scalar_type VdotH_etaLdotH;
Copy link
Member Author

Choose a reason for hiding this comment

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

the VdotH_etaLdotH needs to change (name and what they store) as per #930 (comment)

and a comment needs to be left here or in the concept #930 (comment)

};


template<typename T>
struct SDualMeasureQuant
Expand Down
Loading