Skip to content

Commit fad651e

Browse files
committed
various minor fixes, ggx ndf devsh into query
1 parent 593fb71 commit fad651e

File tree

7 files changed

+141
-42
lines changed

7 files changed

+141
-42
lines changed

include/nbl/builtin/hlsl/bxdf/common.hlsl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,18 +583,17 @@ struct SIsotropicMicrofacetCache
583583
return create(interaction,_sample,orientedEtas,dummy);
584584
}
585585

586-
scalar_type getVdotH() NBL_CONST_MEMBER_FUNC
587-
{
588-
assert(VdotH >= scalar_type(0.0));
589-
return VdotH;
590-
}
591-
592586
bool isTransmission() NBL_CONST_MEMBER_FUNC { return getVdotHLdotH() < scalar_type(0.0); }
593587

594588
scalar_type getVdotL() NBL_CONST_MEMBER_FUNC { return VdotL; }
589+
scalar_type getVdotH() NBL_CONST_MEMBER_FUNC { return VdotH; }
595590
scalar_type getLdotH() NBL_CONST_MEMBER_FUNC { return LdotH; }
596591
scalar_type getVdotHLdotH() NBL_CONST_MEMBER_FUNC { return getVdotH() * getLdotH(); }
597-
scalar_type getNdotH() NBL_CONST_MEMBER_FUNC { return NdotH; }
592+
scalar_type getNdotH() NBL_CONST_MEMBER_FUNC
593+
{
594+
assert(NdotH >= scalar_type(0.0));
595+
return NdotH;
596+
}
598597
scalar_type getNdotH2() NBL_CONST_MEMBER_FUNC { return NdotH2; }
599598

600599
scalar_type VdotL;
@@ -911,7 +910,7 @@ struct beta
911910
// removed values that cancel out in beta
912911
static T __call(T x, T y)
913912
{
914-
assert(v1 >= 1.0 && v2 >= 1.0);
913+
assert(x >= T(0.999) && y >= T(0.999));
915914

916915
const T thresholds[4] = { 0, 5e5, 1e6, 1e15 }; // threshold values gotten from testing when the function returns nan/inf/1
917916
if (x+y > thresholds[mpl::find_lsb_v<sizeof(T)>])

include/nbl/builtin/hlsl/bxdf/config.hlsl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace hlsl
1313
namespace bxdf
1414
{
1515

16+
// TODO should just check `is_base_of` (but not possible right now cause of DXC limitations)
1617
namespace config_concepts
1718
{
1819
#define NBL_CONCEPT_NAME BasicConfiguration
@@ -102,9 +103,12 @@ struct SConfiguration<LS,Interaction,Spectrum NBL_PARTIAL_REQ_BOT(LightSample<LS
102103
template<class LS, class Interaction, class MicrofacetCache, class Spectrum NBL_STRUCT_CONSTRAINABLE>
103104
struct SMicrofacetConfiguration;
104105

106+
#define MICROFACET_CONF_ISO LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> && CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>
107+
105108
template<class LS, class Interaction, class MicrofacetCache, class Spectrum>
106-
NBL_PARTIAL_REQ_TOP(LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> && CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>)
107-
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> && CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>) >
109+
NBL_PARTIAL_REQ_TOP(MICROFACET_CONF_ISO)
110+
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(MICROFACET_CONF_ISO) >
111+
#undef MICROFACET_CONF_ISO
108112
{
109113
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = false;
110114

@@ -124,9 +128,12 @@ struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PART
124128
using anisocache_type = SAnisotropicMicrofacetCache<MicrofacetCache>;
125129
};
126130

131+
#define MICROFACET_CONF_ANISO LightSample<LS> && surface_interactions::Anisotropic<Interaction> && AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>
132+
127133
template<class LS, class Interaction, class MicrofacetCache, class Spectrum>
128-
NBL_PARTIAL_REQ_TOP(LightSample<LS> && surface_interactions::Anisotropic<Interaction> && AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>)
129-
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(LightSample<LS> && surface_interactions::Anisotropic<Interaction> && AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>) >
134+
NBL_PARTIAL_REQ_TOP(MICROFACET_CONF_ANISO)
135+
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(MICROFACET_CONF_ANISO) >
136+
#undef MICROFACET_CONF_ANISO
130137
{
131138
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = true;
132139

include/nbl/builtin/hlsl/bxdf/fresnel.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "nbl/builtin/hlsl/concepts.hlsl"
1010
#include "nbl/builtin/hlsl/numbers.hlsl"
1111
#include "nbl/builtin/hlsl/complex.hlsl"
12+
#include "nbl/builtin/hlsl/tgmath.hlsl"
1213
#include "nbl/builtin/hlsl/vector_utils/vector_traits.hlsl"
1314

1415
namespace nbl

include/nbl/builtin/hlsl/bxdf/ndf/ggx.hlsl

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ NBL_CONCEPT_END(
4747
);
4848
#undef query
4949
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
50+
51+
#define NBL_CONCEPT_NAME G2XQuery
52+
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
53+
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
54+
#define NBL_CONCEPT_PARAM_0 (query, T)
55+
NBL_CONCEPT_BEGIN(1)
56+
#define query NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
57+
NBL_CONCEPT_END(
58+
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
59+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getDevshV()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
60+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getDevshL()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
61+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getTransmitted()), ::nbl::hlsl::is_same_v, bool))
62+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getClampMode()), ::nbl::hlsl::is_same_v, BxDFClampMode))
63+
);
64+
#undef query
65+
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
5066
}
5167

5268
template<typename T, bool IsAnisotropic=false NBL_STRUCT_CONSTRAINABLE>
@@ -104,34 +120,41 @@ struct GGX<T,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
104120
return scalar_type(1.0) / (absNdotX + devsh_part);
105121
}
106122

107-
template<class LS, class Interaction NBL_FUNC_REQUIRES(LightSample<LS> && surface_interactions::Isotropic<Interaction>)
108-
scalar_type correlated_wo_numerator(NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, BxDFClampMode _clamp)
123+
template<class Query, class LS, class Interaction NBL_FUNC_REQUIRES(ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Isotropic<Interaction>)
124+
scalar_type correlated_wo_numerator(NBL_CONST_REF_ARG(Query) query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
109125
{
126+
BxDFClampMode _clamp = query.getClampMode();
127+
assert(_clamp != BxDFClampMode::BCM_NONE);
128+
110129
// numerator is 2 * NdotV * NdotL, we factor out 4 * NdotV * NdotL, hence 0.5
111-
scalar_type Vterm = _sample.getNdotL(_clamp) * devsh_part(interaction.getNdotV2());
112-
scalar_type Lterm = interaction.getNdotV(_clamp) * devsh_part(_sample.getNdotL2());
130+
scalar_type Vterm = _sample.getNdotL(_clamp) * query.getDevshV();
131+
scalar_type Lterm = interaction.getNdotV(_clamp) * query.getDevshL();
113132
return scalar_type(0.5) / (Vterm + Lterm);
114133
}
115134

116-
template<class LS, class Interaction NBL_FUNC_REQUIRES(LightSample<LS> && surface_interactions::Isotropic<Interaction>)
117-
scalar_type G2_over_G1(NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, bool transmitted, BxDFClampMode _clamp)
135+
template<class Query, class LS, class Interaction, class MicrofacetCache NBL_FUNC_REQUIRES(ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Isotropic<Interaction>)
136+
scalar_type G2_over_G1(NBL_CONST_REF_ARG(Query) query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
118137
{
138+
BxDFClampMode _clamp = query.getClampMode();
139+
assert(_clamp != BxDFClampMode::BCM_NONE);
140+
119141
scalar_type G2_over_G1;
120142
scalar_type NdotV = interaction.getNdotV(_clamp);
121143
scalar_type NdotL = _sample.getNdotL(_clamp);
122-
if (transmitted)
144+
scalar_type devsh_v = query.getDevshV();
145+
scalar_type devsh_l = query.getDevshL();
146+
if (query.getTransmitted())
123147
{
124148
if (NdotV < 1e-7 || NdotL < 1e-7)
125149
return 0.0;
126-
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_part(interaction.getNdotV2()) / NdotV + scalar_type(1.0));
127-
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_part(_sample.getNdotL2()) / NdotL + scalar_type(1.0));
150+
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_v / NdotV + scalar_type(1.0));
151+
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_l / NdotL + scalar_type(1.0));
128152
G2_over_G1 = bxdf::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
129153
}
130154
else
131155
{
132-
scalar_type devsh_v = devsh_part(interaction.getNdotV2());
133156
G2_over_G1 = NdotL * (devsh_v + NdotV); // alternative `Vterm+NdotL*NdotV /// NdotL*NdotV could come as a parameter
134-
G2_over_G1 /= NdotV * devsh_part(_sample.getNdotL2()) + NdotL * devsh_v;
157+
G2_over_G1 /= NdotV * devsh_l + NdotL * devsh_v;
135158
}
136159

137160
return G2_over_G1;
@@ -195,33 +218,40 @@ struct GGX<T,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
195218
return scalar_type(1.0) / (NdotX + devsh_part);
196219
}
197220

198-
template<class LS, class Interaction NBL_FUNC_REQUIRES(LightSample<LS> && surface_interactions::Anisotropic<Interaction>)
199-
scalar_type correlated_wo_numerator(NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, BxDFClampMode _clamp)
221+
template<class Query, class LS, class Interaction NBL_FUNC_REQUIRES(ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Anisotropic<Interaction>)
222+
scalar_type correlated_wo_numerator(NBL_CONST_REF_ARG(Query) query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
200223
{
201-
scalar_type Vterm = _sample.getNdotL(_clamp) * devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2());
202-
scalar_type Lterm = interaction.getNdotV(_clamp) * devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2());
224+
BxDFClampMode _clamp = query.getClampMode();
225+
assert(_clamp != BxDFClampMode::BCM_NONE);
226+
227+
scalar_type Vterm = _sample.getNdotL(_clamp) * query.getDevshV();
228+
scalar_type Lterm = interaction.getNdotV(_clamp) * query.getDevshL();
203229
return scalar_type(0.5) / (Vterm + Lterm);
204230
}
205231

206-
template<class LS, class Interaction NBL_FUNC_REQUIRES(LightSample<LS> && surface_interactions::Anisotropic<Interaction>)
207-
scalar_type G2_over_G1(NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, bool transmitted, BxDFClampMode _clamp)
232+
template<class Query, class LS, class Interaction, class MicrofacetCache NBL_FUNC_REQUIRES(ggx_concepts::G2XQuery<Query> && LightSample<LS> && surface_interactions::Anisotropic<Interaction>)
233+
scalar_type G2_over_G1(NBL_CONST_REF_ARG(Query) query, NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction)
208234
{
235+
BxDFClampMode _clamp = query.getClampMode();
236+
assert(_clamp != BxDFClampMode::BCM_NONE);
237+
209238
scalar_type G2_over_G1;
210239
scalar_type NdotV = interaction.getNdotV(_clamp);
211240
scalar_type NdotL = _sample.getNdotL(_clamp);
212-
if (transmitted)
241+
scalar_type devsh_v = query.getDevshV();
242+
scalar_type devsh_l = query.getDevshL();
243+
if (query.getTransmitted())
213244
{
214245
if (NdotV < 1e-7 || NdotL < 1e-7)
215246
return 0.0;
216-
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2()) / NdotV + scalar_type(1.0));
217-
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2()) / NdotL + scalar_type(1.0));
247+
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_v / NdotV + scalar_type(1.0));
248+
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_l / NdotL + scalar_type(1.0));
218249
G2_over_G1 = bxdf::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
219250
}
220251
else
221252
{
222-
scalar_type devsh_v = devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2());
223253
G2_over_G1 = NdotL * (devsh_v + NdotV);
224-
G2_over_G1 /= NdotV * devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2()) + NdotL * devsh_v;
254+
G2_over_G1 /= NdotV * devsh_l + NdotL * devsh_v;
225255
}
226256

227257
return G2_over_G1;

include/nbl/builtin/hlsl/bxdf/reflection/ggx.hlsl

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ struct SGGXDG1Query
110110
scalar_type G1_over_2NdotV;
111111
};
112112

113+
template<typename T>
114+
struct SGGXG2XQuery
115+
{
116+
using scalar_type = T;
117+
118+
scalar_type getDevshV() NBL_CONST_MEMBER_FUNC { return devsh_v; }
119+
scalar_type getDevshL() NBL_CONST_MEMBER_FUNC { return devsh_l; }
120+
bool getTransmitted() NBL_CONST_MEMBER_FUNC { return transmitted; }
121+
BxDFClampMode getClampMode() NBL_CONST_MEMBER_FUNC { return _clamp; }
122+
123+
scalar_type devsh_v;
124+
scalar_type devsh_l;
125+
bool transmitted;
126+
BxDFClampMode _clamp;
127+
};
128+
113129
template<class Config NBL_STRUCT_CONSTRAINABLE>
114130
struct SGGXAnisotropicBxDF;
115131

@@ -154,7 +170,11 @@ struct SGGXIsotropicBxDF
154170
scalar_type NG = ggx_ndf.template D<isocache_type>(params.cache);
155171
if (a2 > numeric_limits<scalar_type>::min)
156172
{
157-
NG *= ggx_ndf.template correlated_wo_numerator<sample_type, isotropic_interaction_type>(params._sample, params.interaction, _clamp);
173+
SGGXG2XQuery<scalar_type> g2_query;
174+
g2_query.devsh_v = ggx_ndf.devsh_part(params.interaction.getNdotV2());
175+
g2_query.devsh_l = ggx_ndf.devsh_part(params._sample.getNdotL2());
176+
g2_query._clamp = _clamp;
177+
NG *= ggx_ndf.template correlated_wo_numerator<SGGXG2XQuery<scalar_type>, sample_type, isotropic_interaction_type>(g2_query, params._sample, params.interaction);
158178
}
159179
return NG;
160180
}
@@ -208,7 +228,12 @@ struct SGGXIsotropicBxDF
208228
ggx_ndf.a2 = a2;
209229
ggx_ndf.one_minus_a2 = scalar_type(1.0) - a2;
210230

211-
const scalar_type G2_over_G1 = ggx_ndf.template G2_over_G1<sample_type, isotropic_interaction_type>(params._sample, params.interaction, false, BxDFClampMode::BCM_MAX);
231+
SGGXG2XQuery<scalar_type> g2_query;
232+
g2_query.devsh_v = ggx_ndf.devsh_part(params.interaction.getNdotV2());
233+
g2_query.devsh_l = ggx_ndf.devsh_part(params._sample.getNdotL2());
234+
g2_query.transmitted = false;
235+
g2_query._clamp = BxDFClampMode::BCM_MAX;
236+
const scalar_type G2_over_G1 = ggx_ndf.template G2_over_G1<SGGXG2XQuery<scalar_type>, sample_type, isotropic_interaction_type, isocache_type>(g2_query, params._sample, params.interaction);
212237

213238
fresnel::Conductor<spectral_type> f = fresnel::Conductor<spectral_type>::create(ior0, ior1, params.getVdotH());
214239
const spectral_type reflectance = f();
@@ -264,7 +289,11 @@ struct SGGXAnisotropicBxDF<Config NBL_PARTIAL_REQ_BOT(config_concepts::Microface
264289
scalar_type NG = ggx_ndf.template D<anisocache_type>(params.cache);
265290
if (any<vector<bool, 2> >(A > (vector2_type)numeric_limits<scalar_type>::min))
266291
{
267-
NG *= ggx_ndf.template correlated_wo_numerator<sample_type, anisotropic_interaction_type>(params._sample, params.interaction, _clamp);
292+
SGGXG2XQuery<scalar_type> g2_query;
293+
g2_query.devsh_v = ggx_ndf.devsh_part(params.interaction.getTdotV2(), params.interaction.getBdotV2(), params.interaction.getNdotV2());
294+
g2_query.devsh_l = ggx_ndf.devsh_part(params._sample.getTdotL2(), params._sample.getBdotL2(), params._sample.getNdotL2());
295+
g2_query._clamp = _clamp;
296+
NG *= ggx_ndf.template correlated_wo_numerator<SGGXG2XQuery<scalar_type>, sample_type, anisotropic_interaction_type>(g2_query, params._sample, params.interaction);
268297
}
269298
return NG;
270299
}
@@ -344,7 +373,12 @@ struct SGGXAnisotropicBxDF<Config NBL_PARTIAL_REQ_BOT(config_concepts::Microface
344373
ggx_ndf.ay2 = A.y*A.y;
345374
ggx_ndf.a2 = A.x*A.y;
346375

347-
const scalar_type G2_over_G1 = ggx_ndf.template G2_over_G1<sample_type, anisotropic_interaction_type>(params._sample, params.interaction, false, BxDFClampMode::BCM_MAX);
376+
SGGXG2XQuery<scalar_type> g2_query;
377+
g2_query.devsh_v = ggx_ndf.devsh_part(params.interaction.getTdotV2(), params.interaction.getBdotV2(), params.interaction.getNdotV2());
378+
g2_query.devsh_l = ggx_ndf.devsh_part(params._sample.getTdotL2(), params._sample.getBdotL2(), params._sample.getNdotL2());
379+
g2_query.transmitted = false;
380+
g2_query._clamp = BxDFClampMode::BCM_MAX;
381+
const scalar_type G2_over_G1 = ggx_ndf.template G2_over_G1<SGGXG2XQuery<scalar_type>, sample_type, anisotropic_interaction_type, anisocache_type>(g2_query, params._sample, params.interaction);
348382

349383
fresnel::Conductor<spectral_type> f = fresnel::Conductor<spectral_type>::create(ior0, ior1, params.getVdotH());
350384
const spectral_type reflectance = f();

include/nbl/builtin/hlsl/bxdf/transmission/ggx.hlsl

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ struct SGGXDG1Query
114114
scalar_type orientedEta;
115115
};
116116

117+
template<typename T>
118+
struct SGGXG2XQuery
119+
{
120+
using scalar_type = T;
121+
122+
scalar_type getDevshV() NBL_CONST_MEMBER_FUNC { return devsh_v; }
123+
scalar_type getDevshL() NBL_CONST_MEMBER_FUNC { return devsh_l; }
124+
bool getTransmitted() NBL_CONST_MEMBER_FUNC { return transmitted; }
125+
BxDFClampMode getClampMode() NBL_CONST_MEMBER_FUNC { return _clamp; }
126+
127+
scalar_type devsh_v;
128+
scalar_type devsh_l;
129+
bool transmitted;
130+
BxDFClampMode _clamp;
131+
};
132+
117133
template<class Config NBL_STRUCT_CONSTRAINABLE>
118134
struct SGGXDielectricAnisotropicBxDF;
119135

@@ -209,8 +225,15 @@ struct SGGXDielectricIsotropicBxDF
209225
ndf::GGX<scalar_type, false> ggx_ndf;
210226
ggx_ndf.a2 = a2;
211227
ggx_ndf.one_minus_a2 = scalar_type(1.0) - a2;
228+
229+
SGGXG2XQuery<scalar_type> g2_query;
230+
g2_query.devsh_v = ggx_ndf.devsh_part(params.interaction.getNdotV2());
231+
g2_query.devsh_l = ggx_ndf.devsh_part(params._sample.getNdotL2());
232+
g2_query.transmitted = transmitted;
233+
g2_query._clamp = BxDFClampMode::BCM_ABS;
234+
212235
scalar_type quo;
213-
quo = ggx_ndf.template G2_over_G1<sample_type, isotropic_interaction_type>(params._sample, params.interaction, transmitted, BxDFClampMode::BCM_ABS);
236+
quo = ggx_ndf.template G2_over_G1<SGGXG2XQuery<scalar_type>, sample_type, isotropic_interaction_type, isocache_type>(g2_query, params._sample, params.interaction);
214237

215238
return quotient_pdf_type::create(hlsl::promote<spectral_type>(quo), _pdf);
216239
}
@@ -346,8 +369,15 @@ struct SGGXDielectricAnisotropicBxDF<Config NBL_PARTIAL_REQ_BOT(config_concepts:
346369
ggx_ndf.ax2 = A.x*A.x;
347370
ggx_ndf.ay2 = A.y*A.y;
348371
ggx_ndf.a2 = A.x*A.y;
372+
373+
SGGXG2XQuery<scalar_type> g2_query;
374+
g2_query.devsh_v = ggx_ndf.devsh_part(params.interaction.getTdotV2(), params.interaction.getBdotV2(), params.interaction.getNdotV2());
375+
g2_query.devsh_l = ggx_ndf.devsh_part(params._sample.getTdotL2(), params._sample.getBdotL2(), params._sample.getNdotL2());
376+
g2_query.transmitted = transmitted;
377+
g2_query._clamp = BxDFClampMode::BCM_ABS;
378+
349379
scalar_type quo;
350-
quo = ggx_ndf.template G2_over_G1<sample_type, anisotropic_interaction_type>(params._sample, params.interaction, transmitted, BxDFClampMode::BCM_ABS);
380+
quo = ggx_ndf.template G2_over_G1<SGGXG2XQuery<scalar_type>, sample_type, anisotropic_interaction_type, anisocache_type>(g2_query, params._sample, params.interaction);
351381

352382
return quotient_pdf_type::create(hlsl::promote<spectral_type>(quo), _pdf);
353383
}

include/nbl/builtin/hlsl/tgmath/impl.hlsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,6 @@ struct beta_helper<T NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
582582
// implementation from Numerical Recipes in C, 2nd ed.
583583
static T __call(T v1, T v2)
584584
{
585-
assert(v1 >= 1.0 && v2 >= 1.0);
586-
587585
const T thresholds[4] = { 0, 2e4, 1e6, 1e15 }; // threshold values gotten from testing when the function returns nan/inf/1
588586
if (v1+v2 > thresholds[mpl::find_lsb_v<sizeof(T)>])
589587
return T(0.0);

0 commit comments

Comments
 (0)