@@ -38,32 +38,24 @@ struct SOrenNayar
3838 scalar_type VdotL;
3939 };
4040
41- static this_t create (scalar_type A )
41+ static this_t create (NBL_CONST_REF_ARG (creation_type) params )
4242 {
4343 this_t retval;
44- retval.A2 = A * 0.5 ;
44+ retval.A2 = params. A * 0.5 ;
4545 retval.AB = vector2_type (1.0 , 0.0 ) + vector2_type (-0.5 , 0.45 ) * vector2_type (retval.A2, retval.A2) / vector2_type (retval.A2 + 0.33 , retval.A2 + 0.09 );
4646 return retval;
4747 }
48- static this_t create (NBL_CONST_REF_ARG (creation_type) params)
49- {
50- return create (params.A);
51- }
5248
53- scalar_type __rec_pi_factored_out_wo_clamps (scalar_type VdotL, scalar_type maxNdotL, scalar_type maxNdotV)
54- {
55- scalar_type C = 1.0 / max <scalar_type>(maxNdotL, maxNdotV);
56-
57- scalar_type cos_phi_sin_theta = max <scalar_type>(VdotL - maxNdotL * maxNdotV, 0.0 );
58- return (AB.x + AB.y * cos_phi_sin_theta * C);
59- }
6049 template<typename Query>
6150 spectral_type __eval (NBL_CONST_REF_ARG (Query) query, NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction)
6251 {
6352 scalar_type NdotL = _sample.getNdotL (_clamp);
64- 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)) );
65- }
53+ scalar_type NdotV = interaction.getNdotV (_clamp);
54+ scalar_type C = 1.0 / max <scalar_type>(NdotL, NdotV);
6655
56+ scalar_type cos_phi_sin_theta = max <scalar_type>(VdotL - 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));
58+ }
6759 spectral_type eval (NBL_CONST_REF_ARG (sample_type) _sample, NBL_CONST_REF_ARG (isotropic_interaction_type) interaction)
6860 {
6961 SQuery query;
0 commit comments