@@ -46,16 +46,19 @@ struct SOrenNayar
46
46
return retval;
47
47
}
48
48
49
+ scalar_type __rec_pi_factored_out_wo_clamps (scalar_type VdotL, scalar_type clampedNdotL, scalar_type clampedNdotV)
50
+ {
51
+ scalar_type C = 1.0 / max <scalar_type>(clampedNdotL, clampedNdotV);
52
+ scalar_type cos_phi_sin_theta = max <scalar_type>(VdotL - clampedNdotL * clampedNdotV, 0.0 );
53
+ return (AB.x + AB.y * cos_phi_sin_theta * C);
54
+ }
49
55
template<typename Query>
50
56
spectral_type __eval (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction)
51
57
{
52
58
scalar_type NdotL = _sample.getNdotL (_clamp);
53
- scalar_type NdotV = interaction.getNdotV (_clamp);
54
- scalar_type C = 1.0 / max <scalar_type>(NdotL, NdotV);
55
-
56
- scalar_type cos_phi_sin_theta = max <scalar_type>(query.getVdotL () - NdotL * NdotV, 0.0 );
57
- return hlsl::promote<spectral_type>(NdotL * numbers::inv_pi<scalar_type> * 0.5 * (AB.x + AB.y * cos_phi_sin_theta * C));
59
+ return hlsl::promote<spectral_type>(NdotL * numbers::inv_pi<scalar_type> * 0.5 * __rec_pi_factored_out_wo_clamps (query.getVdotL (), NdotL, interaction.getNdotV (_clamp)));
58
60
}
61
+
59
62
spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction)
60
63
{
61
64
SQuery query;
@@ -87,13 +90,7 @@ struct SOrenNayar
87
90
quotient_pdf_type __quotient_and_pdf (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction)
88
91
{
89
92
scalar_type _pdf = pdf (_sample);
90
-
91
- scalar_type NdotL = _sample.getNdotL (_clamp);
92
- scalar_type NdotV = interaction.getNdotV (_clamp);
93
- scalar_type C = 1.0 / max <scalar_type>(NdotL, NdotV);
94
-
95
- scalar_type cos_phi_sin_theta = max <scalar_type>(query.getVdotL () - NdotL * NdotV, 0.0 );
96
- scalar_type q = AB.x + AB.y * cos_phi_sin_theta * C;
93
+ scalar_type q = __rec_pi_factored_out_wo_clamps (query.getVdotL (), _sample.getNdotL (_clamp), interaction.getNdotV (_clamp));
97
94
return quotient_pdf_type::create (q, _pdf);
98
95
}
99
96
quotient_pdf_type quotient_and_pdf (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction)
0 commit comments