@@ -184,7 +184,14 @@ struct SCookTorrance
184184 scalar_type clampedVdotH = cache.getVdotH ();
185185 NBL_IF_CONSTEXPR (IsBSDF)
186186 clampedVdotH = hlsl::abs (clampedVdotH);
187- return impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (clampedVdotH)) * DG;
187+
188+ NBL_IF_CONSTEXPR (IsBSDF)
189+ {
190+ const scalar_type reflectance = _f (clampedVdotH)[0 ];
191+ return hlsl::promote<spectral_type>(hlsl::mix (reflectance, scalar_type (1.0 ) - reflectance, cache.isTransmission ())) * DG;
192+ }
193+ else
194+ return impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (clampedVdotH)) * DG;
188195 }
189196
190197 template<typename C=bool_constant<!IsBSDF> >
@@ -267,7 +274,7 @@ struct SCookTorrance
267274 return sample_type::createInvalid (); // should check if sample direction is invalid
268275
269276 cache = anisocache_type::createPartial (VdotH, LdotH, localH.z, transmitted, rcpEta);
270- // assert(cache.isValid(fresnel.getRefractionOrientedEta())); TODO get clarification on case NdotV<0, transmitted=false (technically not TIR?)
277+ // assert(cache.isValid(fresnel.getRefractionOrientedEta()));
271278
272279 struct reflect_refract_wrapper // so we don't recalculate LdotH
273280 {
@@ -347,7 +354,7 @@ struct SCookTorrance
347354 fresnel_type _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call (fresnel, interaction.getNdotV ());
348355
349356 const bool valid = impl::checkValid<fresnel_type, IsBSDF>::template __call<sample_type, Interaction, MicrofacetCache>(_f, _sample, interaction, cache);
350- assert (valid);
357+ // assert(valid);
351358
352359 scalar_type G2_over_G1 = scalar_type (1.0 );
353360 if (_pdf < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity))
0 commit comments