@@ -133,6 +133,7 @@ struct SCookTorrance
133
133
134
134
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = ndf_type::IsAnisotropic;
135
135
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = ndf_type::SupportedPaths != ndf::MTT_REFLECT;
136
+ NBL_HLSL_BXDF_ANISOTROPIC_COND_DECLS (IsAnisotropic);
136
137
137
138
template<class Interaction, class MicrofacetCache>
138
139
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)
@@ -143,8 +144,10 @@ struct SCookTorrance
143
144
return _sample.getNdotL () > numeric_limits<scalar_type>::min && interaction.getNdotV () > numeric_limits<scalar_type>::min ;
144
145
}
145
146
146
- template<class Interaction, class MicrofacetCache>
147
- spectral_type __eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
147
+ template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
148
+ class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
149
+ NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
150
+ spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
148
151
{
149
152
fresnel_type _f = fresnel;
150
153
NBL_IF_CONSTEXPR (IsBSDF)
@@ -170,15 +173,6 @@ struct SCookTorrance
170
173
clampedVdotH = hlsl::abs (clampedVdotH);
171
174
return impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (clampedVdotH)) * DG;
172
175
}
173
- template<typename C=bool_constant<!IsAnisotropic> >
174
- enable_if_t<C::value && !IsAnisotropic, spectral_type> eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction, NBL_CONST_REF_ARG (isocache_type) cache)
175
- {
176
- return __eval<isotropic_interaction_type, isocache_type>(_sample, interaction, cache);
177
- }
178
- spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, NBL_CONST_REF_ARG (anisocache_type) cache)
179
- {
180
- return __eval<anisotropic_interaction_type, anisocache_type>(_sample, interaction, cache);
181
- }
182
176
183
177
template<typename C=bool_constant<!IsBSDF> >
184
178
enable_if_t<C::value && !IsBSDF, sample_type> generate (NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, const vector2_type u, NBL_REF_ARG (anisocache_type) cache)
@@ -318,19 +312,10 @@ struct SCookTorrance
318
312
return DG1.projectedLightMeasure;
319
313
}
320
314
}
321
- template<typename C=bool_constant<!IsAnisotropic> >
322
- enable_if_t<C::value && !IsAnisotropic, scalar_type> pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction, NBL_CONST_REF_ARG (isocache_type) cache)
323
- {
324
- fresnel_type _f = fresnel;
325
- NBL_IF_CONSTEXPR (IsBSDF)
326
- _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call (fresnel, interaction.getNdotV ());
327
- if (!__checkValid<isotropic_interaction_type, isocache_type>(_f, _sample, interaction, cache))
328
- return scalar_type (0.0 );
329
-
330
- scalar_type _pdf = __pdf<isotropic_interaction_type, isocache_type>(_sample, interaction, cache);
331
- return hlsl::mix (scalar_type (0.0 ), _pdf, _pdf < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity));
332
- }
333
- scalar_type pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, NBL_CONST_REF_ARG (anisocache_type) cache)
315
+ template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
316
+ class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
317
+ NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
318
+ scalar_type pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
334
319
{
335
320
fresnel_type _f = fresnel;
336
321
NBL_IF_CONSTEXPR (IsBSDF)
@@ -342,8 +327,10 @@ struct SCookTorrance
342
327
return hlsl::mix (scalar_type (0.0 ), _pdf, _pdf < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity));
343
328
}
344
329
345
- template<class Interaction, class MicrofacetCache>
346
- 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)
330
+ template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
331
+ class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
332
+ NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
333
+ 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)
347
334
{
348
335
if (!_sample.isValid ())
349
336
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
@@ -374,15 +361,6 @@ struct SCookTorrance
374
361
375
362
return quotient_pdf_type::create (quo, _pdf);
376
363
}
377
- template<typename C=bool_constant<!IsAnisotropic> >
378
- enable_if_t<C::value && !IsAnisotropic, quotient_pdf_type> quotient_and_pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction, NBL_CONST_REF_ARG (isocache_type) cache)
379
- {
380
- return __quotient_and_pdf<isotropic_interaction_type, isocache_type>(_sample, interaction, cache);
381
- }
382
- quotient_pdf_type quotient_and_pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (anisotropic_interaction_type) interaction, NBL_CONST_REF_ARG (anisocache_type) cache)
383
- {
384
- return __quotient_and_pdf<anisotropic_interaction_type, anisocache_type>(_sample, interaction, cache);
385
- }
386
364
387
365
ndf_type ndf;
388
366
fresnel_type fresnel; // always front-facing
0 commit comments