@@ -130,14 +130,15 @@ struct SCookTorrance
130130
131131 template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
132132 typename C=bool_constant<!fresnel_type::ReturnsMonochrome> NBL_FUNC_REQUIRES (C::value && !fresnel_type::ReturnsMonochrome)
133- static scalar_type __getScaledReflectance (NBL_CONST_REF_ARG (fresnel_type) orientedFresnel, NBL_CONST_REF_ARG (Interaction) interaction, scalar_type clampedVdotH)
133+ static scalar_type __getScaledReflectance (NBL_CONST_REF_ARG (fresnel_type) orientedFresnel, NBL_CONST_REF_ARG (Interaction) interaction, scalar_type clampedVdotH, NBL_REF_ARG (spectral_type) outFresnelVal )
134134 {
135135 spectral_type throughputWeights = interaction.getLuminosityContributionHint ();
136- return hlsl::dot<spectral_type>(orientedFresnel (clampedVdotH), throughputWeights);
136+ outFresnelVal = orientedFresnel (clampedVdotH);
137+ return hlsl::dot<spectral_type>(outFresnelVal, throughputWeights);
137138 }
138139 template<class Interaction=conditional_t<IsAnisotropic,anisotropic_interaction_type,isotropic_interaction_type>,
139140 typename C=bool_constant<fresnel_type::ReturnsMonochrome> NBL_FUNC_REQUIRES (C::value && fresnel_type::ReturnsMonochrome)
140- static scalar_type __getScaledReflectance (NBL_CONST_REF_ARG (fresnel_type) orientedFresnel, NBL_CONST_REF_ARG (Interaction) interaction, scalar_type clampedVdotH)
141+ static scalar_type __getScaledReflectance (NBL_CONST_REF_ARG (fresnel_type) orientedFresnel, NBL_CONST_REF_ARG (Interaction) interaction, scalar_type clampedVdotH, NBL_REF_ARG (spectral_type) outFresnelVal )
141142 {
142143 return orientedFresnel (clampedVdotH)[0 ];
143144 }
@@ -294,7 +295,8 @@ struct SCookTorrance
294295 assert (NdotV*VdotH >= scalar_type (0.0 ));
295296 }
296297
297- const scalar_type reflectance = __getScaledReflectance (_f, interaction, hlsl::abs (VdotH));
298+ spectral_type dummy;
299+ const scalar_type reflectance = __getScaledReflectance (_f, interaction, hlsl::abs (VdotH), dummy);
298300
299301 scalar_type rcpChoiceProb;
300302 scalar_type z = u.z;
@@ -337,7 +339,8 @@ struct SCookTorrance
337339
338340 NBL_IF_CONSTEXPR (IsBSDF)
339341 {
340- const scalar_type reflectance = __getScaledReflectance (_f, interaction, hlsl::abs (cache.getVdotH ()));
342+ spectral_type dummy;
343+ const scalar_type reflectance = __getScaledReflectance (_f, interaction, hlsl::abs (cache.getVdotH ()), dummy);
341344 return hlsl::mix (reflectance, scalar_type (1.0 ) - reflectance, cache.isTransmission ()) * DG1.projectedLightMeasure;
342345 }
343346 else
@@ -389,8 +392,8 @@ struct SCookTorrance
389392 quo = hlsl::promote<spectral_type>(G2_over_G1);
390393 else
391394 {
392- const scalar_type scaled_reflectance = __getScaledReflectance (_f, interaction, hlsl:: abs (cache. getVdotH ())) ;
393- spectral_type reflectance = impl::__implicit_promote<spectral_type, typename fresnel_type::vector_type>:: __call ( _f ( hlsl::abs (cache.getVdotH ())) );
395+ spectral_type reflectance ;
396+ const scalar_type scaled_reflectance = __getScaledReflectance (_f, interaction, hlsl::abs (cache.getVdotH ()), reflectance );
394397 quo = hlsl::mix (reflectance / scaled_reflectance,
395398 (hlsl::promote<spectral_type>(1.0 ) - reflectance) / (scalar_type (1.0 ) - scaled_reflectance), cache.isTransmission ()) * G2_over_G1;
396399 }
0 commit comments