@@ -167,8 +167,8 @@ struct SCookTorrance
167167
168168 NBL_IF_CONSTEXPR (IsBSDF)
169169 {
170- const scalar_type reflectance = _f (clampedVdotH)[ 0 ] ;
171- return hlsl::promote<spectral_type>(hlsl:: mix (reflectance, scalar_type (1.0 ) - reflectance, cache.isTransmission () )) * DG;
170+ const spectral_type reflectance = impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>:: __call ( _f (clampedVdotH)) ;
171+ return hlsl::mix (reflectance, hlsl::promote<spectral_type> (1.0 ) - reflectance, cache.isTransmission ()) * DG;
172172 }
173173 else
174174 return impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (clampedVdotH)) * DG;
@@ -271,7 +271,9 @@ struct SCookTorrance
271271 {
272272 assert (NdotV*VdotH >= scalar_type (0.0 ));
273273 }
274- const scalar_type reflectance = _f (hlsl::abs (VdotH))[0 ];
274+
275+ spectral_type prefixThroughputWeights = interaction.getPrefixThroughputWeights ();
276+ const scalar_type reflectance = hlsl::dot (impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (hlsl::abs (VdotH))), prefixThroughputWeights);
275277
276278 scalar_type rcpChoiceProb;
277279 scalar_type z = u.z;
@@ -312,7 +314,8 @@ struct SCookTorrance
312314
313315 NBL_IF_CONSTEXPR (IsBSDF)
314316 {
315- const scalar_type reflectance = _f (hlsl::abs (cache.getVdotH ()))[0 ];
317+ spectral_type prefixThroughputWeights = interaction.getPrefixThroughputWeights ();
318+ const scalar_type reflectance = hlsl::dot (impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (hlsl::abs (cache.getVdotH ()))), prefixThroughputWeights);
316319 return hlsl::mix (reflectance, scalar_type (1.0 ) - reflectance, cache.isTransmission ()) * DG1.projectedLightMeasure;
317320 }
318321 else
@@ -359,7 +362,13 @@ struct SCookTorrance
359362
360363 spectral_type quo;
361364 NBL_IF_CONSTEXPR (IsBSDF)
362- quo = hlsl::promote<spectral_type>(G2_over_G1);
365+ {
366+ spectral_type prefixThroughputWeights = interaction.getPrefixThroughputWeights ();
367+ spectral_type reflectance = impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>::__call (_f (hlsl::abs (cache.getVdotH ())));
368+ const scalar_type scaled_reflectance = hlsl::dot (reflectance, prefixThroughputWeights);
369+ quo = hlsl::mix (reflectance / scaled_reflectance,
370+ (hlsl::promote<spectral_type>(1.0 ) - reflectance) / (scalar_type (1.0 ) - scaled_reflectance), cache.isTransmission ()) * G2_over_G1;
371+ }
363372 else
364373 {
365374 const scalar_type VdotH = cache.getVdotH ();
0 commit comments