@@ -69,28 +69,29 @@ struct quant_query_helper<N, F, false>
69
69
};
70
70
71
71
template<class F, bool IsBSDF>
72
- struct check_TIR_helper ;
72
+ struct checkValid ;
73
73
74
74
template<class F>
75
- struct check_TIR_helper <F, false >
75
+ struct checkValid <F, false >
76
76
{
77
- template<class MicrofacetCache>
78
- static bool __call (NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (MicrofacetCache) cache)
77
+ using scalar_type = typename F::scalar_type;
78
+
79
+ template<class Sample, class Interaction, class MicrofacetCache>
80
+ static bool __call (NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (Sample) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
79
81
{
80
- return true ;
82
+ return _sample. getNdotL () > numeric_limits<scalar_type>:: min && interaction. getNdotV () > numeric_limits<scalar_type>:: min ;
81
83
}
82
84
};
83
85
84
86
template<class F>
85
- struct check_TIR_helper <F, true >
87
+ struct checkValid <F, true >
86
88
{
87
89
using vector_type = typename F::vector_type; // expect monochrome
88
90
89
- template<class MicrofacetCache>
90
- static bool __call (NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (MicrofacetCache) cache)
91
+ template<class Sample, class Interaction, class MicrofacetCache>
92
+ static bool __call (NBL_CONST_REF_ARG (F) fresnel, NBL_CONST_REF_ARG (Sample) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG ( MicrofacetCache) cache)
91
93
{
92
- fresnel::OrientedEtas<vector_type> orientedEta = fresnel::OrientedEtas<vector_type>::create (typename F::scalar_type (1.0 ), hlsl::promote<vector_type>(fresnel.getRefractionOrientedEta ()));
93
- return cache.isValid (orientedEta);
94
+ return cache.isValid (fresnel.getRefractionOrientedEta ());
94
95
}
95
96
};
96
97
@@ -135,22 +136,13 @@ struct SCookTorrance
135
136
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = ndf_type::SupportedPaths != ndf::MTT_REFLECT;
136
137
NBL_HLSL_BXDF_ANISOTROPIC_COND_DECLS (IsAnisotropic);
137
138
138
- template<class Interaction, class MicrofacetCache>
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)
140
- {
141
- NBL_IF_CONSTEXPR (IsBSDF)
142
- return impl::check_TIR_helper<fresnel_type, IsBSDF>::template __call<MicrofacetCache>(f, cache);
143
- else
144
- return _sample.getNdotL () > numeric_limits<scalar_type>::min && interaction.getNdotV () > numeric_limits<scalar_type>::min ;
145
- }
146
-
147
139
template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
148
140
class MicrofacetCache=conditional_t<IsAnisotropic,anisocache_type,isocache_type>
149
141
NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
150
142
spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
151
143
{
152
144
fresnel_type _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call (fresnel, interaction.getNdotV ());
153
- if (!__checkValid< Interaction, MicrofacetCache>(_f, _sample, interaction, cache))
145
+ if (!impl::checkValid<fresnel_type, IsBSDF>::template __call<sample_type, Interaction, MicrofacetCache>(_f, _sample, interaction, cache))
154
146
return hlsl::promote<spectral_type>(0.0 );
155
147
156
148
using quant_query_type = typename ndf_type::quant_query_type;
@@ -279,8 +271,8 @@ struct SCookTorrance
279
271
280
272
return sample_type::create (L, T, B, NdotL);
281
273
}
282
- template<typename C=bool_constant<!IsAnisotropic>, typename T=conditional_t<IsBSDF, vector3_type, vector2_type> >
283
- enable_if_t<C::value && !IsAnisotropic, sample_type> generate (NBL_CONST_REF_ARG (isotropic_interaction_type) interaction, const T u, NBL_REF_ARG (isocache_type) cache)
274
+ template<typename C=bool_constant<!IsAnisotropic> >
275
+ enable_if_t<C::value && !IsAnisotropic, 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)
284
276
{
285
277
anisocache_type aniso_cache;
286
278
sample_type s = generate (anisotropic_interaction_type::create (interaction), u, aniso_cache);
@@ -315,10 +307,8 @@ struct SCookTorrance
315
307
NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
316
308
scalar_type pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
317
309
{
318
- fresnel_type _f = fresnel;
319
- NBL_IF_CONSTEXPR (IsBSDF)
320
- _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call (fresnel, interaction.getNdotV ());
321
- if (!__checkValid<anisotropic_interaction_type, anisocache_type>(_f, _sample, interaction, cache))
310
+ fresnel_type _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call (fresnel, interaction.getNdotV ());
311
+ if (!impl::checkValid<fresnel_type, IsBSDF>::template __call<sample_type, Interaction, MicrofacetCache>(_f, _sample, interaction, cache))
322
312
return scalar_type (0.0 );
323
313
324
314
scalar_type _pdf = __pdf<anisotropic_interaction_type, anisocache_type>(_sample, interaction, cache);
@@ -336,8 +326,8 @@ struct SCookTorrance
336
326
scalar_type _pdf = __pdf<Interaction, MicrofacetCache>(_sample, interaction, cache);
337
327
fresnel_type _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call (fresnel, interaction.getNdotV ());
338
328
339
- const bool notTIR = impl::check_TIR_helper <fresnel_type, IsBSDF>::template __call<MicrofacetCache>(_f, cache);
340
- assert (notTIR );
329
+ const bool valid = impl::checkValid <fresnel_type, IsBSDF>::template __call<sample_type, Interaction, MicrofacetCache>(_f, _sample, interaction , cache);
330
+ assert (valid );
341
331
342
332
scalar_type G2_over_G1 = scalar_type (1.0 );
343
333
if (_pdf < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity))
0 commit comments