@@ -50,7 +50,7 @@ struct quant_query_helper<N, F, true>
5050 using quant_query_type = typename N::quant_query_type;
5151
5252 template<class I, class C>
53- static quant_query_type __call (NBL_REF_ARG (N) ndf, NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (I) interaction, NBL_CONST_REF_ARG (C) cache)
53+ static quant_query_type __call (NBL_CONST_REF_ARG (N) ndf, NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (I) interaction, NBL_CONST_REF_ARG (C) cache)
5454 {
5555 return ndf.template createQuantQuery<I,C>(interaction, cache, fresnel.getRefractionOrientedEta ());
5656 }
@@ -62,7 +62,7 @@ struct quant_query_helper<N, F, false>
6262 using quant_query_type = typename N::quant_query_type;
6363
6464 template<class I, class C>
65- static quant_query_type __call (NBL_REF_ARG (N) ndf, NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (I) interaction, NBL_CONST_REF_ARG (C) cache)
65+ static quant_query_type __call (NBL_CONST_REF_ARG (N) ndf, NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (I) interaction, NBL_CONST_REF_ARG (C) cache)
6666 {
6767 typename N::scalar_type dummy;
6868 return ndf.template createQuantQuery<I,C>(interaction, cache, dummy);
@@ -146,7 +146,7 @@ struct SCookTorrance
146146 return hlsl::mix (reflectance, scalar_type (1.0 )-reflectance, transmitted);
147147 }
148148
149- bool __dotIsValue (const vector3_type a, const vector3_type b, const scalar_type value)
149+ bool __dotIsValue (const vector3_type a, const vector3_type b, const scalar_type value) NBL_CONST_MEMBER_FUNC
150150 {
151151 const scalar_type ab = hlsl::dot (a, b);
152152 return hlsl::max (ab, value / ab) <= scalar_type (value + 1e-3 );
@@ -156,7 +156,7 @@ struct SCookTorrance
156156 template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
157157 class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
158158 NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
159- spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
159+ spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache) NBL_CONST_MEMBER_FUNC
160160 {
161161 fresnel_type _f = __getOrientedFresnel (fresnel, interaction.getNdotV ());
162162 if (!__checkValid<Interaction, MicrofacetCache>(_f, _sample, interaction, cache))
@@ -197,14 +197,14 @@ struct SCookTorrance
197197 sample_type __generate_common (NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, const vector3_type localH,
198198 const scalar_type NdotV, const scalar_type VdotH, const scalar_type LdotH, bool transmitted,
199199 NBL_CONST_REF_ARG (fresnel::OrientedEtaRcps<monochrome_type>) rcpEta,
200- NBL_REF_ARG (bool ) valid)
200+ NBL_REF_ARG (bool ) valid) NBL_CONST_MEMBER_FUNC
201201 {
202202 // fail if samples have invalid paths
203203 const scalar_type NdotL = hlsl::mix (scalar_type (2.0 ) * VdotH * localH.z - NdotV,
204204 localH.z * (VdotH * rcpEta.value[0 ] + LdotH) - NdotV * rcpEta.value[0 ], transmitted);
205205 // VNDF sampling guarantees that `VdotH` has same sign as `NdotV`
206206 // and `transmitted` controls the sign of `LdotH` relative to `VdotH` by construction (reflect -> same sign, or refract -> opposite sign)
207- if (ComputeMicrofacetNormal<scalar_type>::isTransmissionPath (NdotV, NdotL) != transmitted)
207+ if (hlsl:: isnan (NdotL) || ComputeMicrofacetNormal<scalar_type>::isTransmissionPath (NdotV, NdotL) != transmitted)
208208 {
209209 valid = false ;
210210 return sample_type::createInvalid (); // should check if sample direction is invalid
@@ -244,7 +244,7 @@ struct SCookTorrance
244244 return sample_type::create (L, T, B, NdotL);
245245 }
246246 template<typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES (C::value && !IsBSDF)
247- sample_type generate (NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, const vector2_type u, NBL_REF_ARG (anisocache_type) cache)
247+ sample_type generate (NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, const vector2_type u, NBL_REF_ARG (anisocache_type) cache) NBL_CONST_MEMBER_FUNC
248248 {
249249 const scalar_type NdotV = interaction.getNdotV ();
250250 if (NdotV < numeric_limits<scalar_type>::min )
@@ -274,7 +274,7 @@ struct SCookTorrance
274274 return s;
275275 }
276276 template<typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES (C::value && IsBSDF)
277- sample_type generate (NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, const vector3_type u, NBL_REF_ARG (anisocache_type) cache)
277+ sample_type generate (NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, const vector3_type u, NBL_REF_ARG (anisocache_type) cache) NBL_CONST_MEMBER_FUNC
278278 {
279279 const vector3_type localV = interaction.getTangentSpaceV ();
280280 const scalar_type NdotV = localV.z;
@@ -322,7 +322,7 @@ struct SCookTorrance
322322 return s;
323323 }
324324 template<typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES (C::value && !IsAnisotropic)
325- sample_type generate (NBL_CONST_REF_ARG (isotropic_interaction_type) interaction, const conditional_t<IsBSDF, vector3_type, vector2_type> u, NBL_REF_ARG (isocache_type) cache)
325+ sample_type generate (NBL_CONST_REF_ARG (isotropic_interaction_type) interaction, const conditional_t<IsBSDF, vector3_type, vector2_type> u, NBL_REF_ARG (isocache_type) cache) NBL_CONST_MEMBER_FUNC
326326 {
327327 anisocache_type aniso_cache;
328328 sample_type s = generate (anisotropic_interaction_type::create (interaction), u, aniso_cache);
@@ -331,7 +331,7 @@ struct SCookTorrance
331331 }
332332
333333 template<class Interaction, class MicrofacetCache>
334- scalar_type __pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache, NBL_REF_ARG (bool ) isInfinity)
334+ scalar_type __pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache, NBL_REF_ARG (bool ) isInfinity) NBL_CONST_MEMBER_FUNC
335335 {
336336 using quant_query_type = typename ndf_type::quant_query_type;
337337 using dg1_query_type = typename ndf_type::dg1_query_type;
@@ -356,7 +356,7 @@ struct SCookTorrance
356356 template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
357357 class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
358358 NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
359- scalar_type pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
359+ scalar_type pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache) NBL_CONST_MEMBER_FUNC
360360 {
361361 fresnel_type _f = __getOrientedFresnel (fresnel, interaction.getNdotV ());
362362 if (!__checkValid<Interaction, MicrofacetCache>(_f, _sample, interaction, cache))
@@ -370,7 +370,7 @@ struct SCookTorrance
370370 template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
371371 class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
372372 NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
373- quotient_pdf_type quotient_and_pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
373+ quotient_pdf_type quotient_and_pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache) NBL_CONST_MEMBER_FUNC
374374 {
375375 if (!_sample.isValid ())
376376 return quotient_pdf_type::create (scalar_type (0.0 ), scalar_type (0.0 )); // set pdf=0 when quo=0 because we don't want to give high weight to sampling strategy that yields 0 contribution
0 commit comments