@@ -98,20 +98,18 @@ struct SMicrofacetNormals<Config, BRDF, P, 1 NBL_PARTIAL_REQ_BOT(config_concepts
9898 return nested_bsdf.evalAndWeight (sample_N, interaction_N);
9999 }
100100
101- const scalar_type NdotV = hlsl::dot (shadingNormal, V.getDirection ());
102- const vector3_type upperHemisphereV = ieee754::flipSignIfRHSNegative<vector3_type>(V.getDirection (), hlsl::promote<vector3_type>(NdotV));
103101 const vector3_type Nt = shadowing_method_type::computeNt (Np, shadingBasis);
104- const scalar_type NpdotV = hlsl:: dot (Np, upperHemisphereV );
105- const scalar_type NtdotV = hlsl::dot (Nt, upperHemisphereV );
102+ const scalar_type NpdotV = interaction. getNdotV ( );
103+ const scalar_type NtdotV = hlsl::dot (Nt, V. getDirection () );
106104 spectral_type eval = hlsl::promote<spectral_type>(0.0 );
107105
108106 const vector3_type L = _sample.getL ().getDirection ();
109107 const scalar_type NdotL = hlsl::dot (shadingNormal, L);
110- const scalar_type NpdotL = _sample.getNdotL (BxDFClampMode::BCM_MAX );
108+ const scalar_type NpdotL = _sample.getNdotL (BxDFClampMode::BCM_ABS );
111109 const scalar_type NtdotL = hlsl::dot (Nt, L);
112- const scalar_type lambda_p = shadowing_method_type::lambdaP (NdotNp, hlsl::max ( scalar_type ( 0.0 ), NpdotV), hlsl::max ( scalar_type ( 0.0 ), NtdotV));
113- const scalar_type shadowing = shadowing_method_type::G1 (hlsl::max ( scalar_type ( 0.0 ), NdotL), NdotNp,
114- NpdotL, hlsl::max ( scalar_type ( 0.0 ), NtdotL));
110+ const scalar_type lambda_p = shadowing_method_type::lambdaP (NdotNp, hlsl::abs ( NpdotV), hlsl::abs ( NtdotV));
111+ const scalar_type shadowing = shadowing_method_type::G1 (hlsl::abs ( NdotL), NdotNp,
112+ NpdotL, hlsl::abs ( NtdotL));
115113
116114 // i -> p -> o
117115 {
@@ -128,8 +126,8 @@ struct SMicrofacetNormals<Config, BRDF, P, 1 NBL_PARTIAL_REQ_BOT(config_concepts
128126 iso_t.luminosityContributionHint = interaction.getLuminosityContributionHint ();
129127 typename bxdf_type::anisotropic_interaction_type interaction_t = bxdf_type::anisotropic_interaction_type::create (iso_t);
130128
131- const scalar_type shadowing_t = shadowing_method_type::G1 (hlsl::max ( scalar_type ( 0.0 ), NdotL), hlsl::dot (shadingNormal, Nt),
132- NpdotL, hlsl::max ( scalar_type ( 0.0 ), NtdotL) );
129+ const scalar_type shadowing_t = shadowing_method_type::G1 (hlsl::abs ( NdotL), hlsl::dot (shadingNormal, Nt),
130+ NpdotL, hlsl::abs (NtdotL ), true );
133131
134132 value_weight_type eval_t = nested_bsdf.evalAndWeight (sample_t, interaction_t);
135133 eval += eval_t.value () * (scalar_type (1.0 ) - lambda_p) * shadowing_t;
@@ -208,23 +206,21 @@ struct SMicrofacetNormals<Config, BRDF, P, 1 NBL_PARTIAL_REQ_BOT(config_concepts
208206 return nested_bsdf.forwardPdf (sample_N, interaction_N, __createChildCache (sample_N, interaction_N));
209207 }
210208
211- const scalar_type NdotV = hlsl::dot (shadingNormal, V.getDirection ());
212- const vector3_type upperHemisphereV = ieee754::flipSignIfRHSNegative<vector3_type>(V.getDirection (), hlsl::promote<vector3_type>(NdotV));
213209 const vector3_type Nt = shadowing_method_type::computeNt (Np, shadingBasis);
214- const scalar_type NpdotV = hlsl:: dot (Np, upperHemisphereV );
215- const scalar_type NtdotV = hlsl::dot (Nt, upperHemisphereV );
210+ const scalar_type NpdotV = interaction. getNdotV ( );
211+ const scalar_type NtdotV = hlsl::dot (Nt, V. getDirection () );
216212
217213 scalar_type pdf = scalar_type (0.0 );
218- const scalar_type lambda_p = shadowing_method_type::lambdaP (NdotNp, hlsl::max ( scalar_type ( 0.0 ), NpdotV), hlsl::max ( scalar_type ( 0.0 ), NtdotV));
214+ const scalar_type lambda_p = shadowing_method_type::lambdaP (NdotNp, hlsl::abs ( NpdotV), hlsl::abs ( NtdotV));
219215
220216 if (lambda_p > scalar_type (0.0 ))
221217 {
222218 const vector3_type L = _sample.getL ().getDirection ();
223219 const scalar_type NdotL = hlsl::dot (shadingNormal, L);
224- const scalar_type NpdotL = _sample.getNdotL (BxDFClampMode::BCM_MAX );
220+ const scalar_type NpdotL = _sample.getNdotL (BxDFClampMode::BCM_ABS );
225221 const scalar_type NtdotL = hlsl::dot (Nt, L);
226222 pdf += lambda_p * nested_bsdf.forwardPdf (_sample, interaction, _cache.aniso_cache)
227- * shadowing_method_type::G1 (hlsl::max ( scalar_type ( 0.0 ), NdotL), NdotNp, NpdotL, hlsl::max ( scalar_type ( 0.0 ), NtdotL));
223+ * shadowing_method_type::G1 (hlsl::abs ( NdotL), NdotNp, NpdotL, hlsl::abs ( NtdotL));
228224 }
229225
230226 if (lambda_p < scalar_type (1.0 ) && NtdotV > numeric_limits<scalar_type>::min )
@@ -282,8 +278,8 @@ struct SMicrofacetNormals<Config, BRDF, P, 1 NBL_PARTIAL_REQ_BOT(config_concepts
282278 if (_cache.sampleIsShadowed)
283279 {
284280 const vector3_type L = _sample.getL ().getDirection ();
285- const scalar_type NpdotL = _sample.getNdotL (BxDFClampMode::BCM_MAX );
286- quo *= shadowing_method_type::G1 (hlsl::max ( scalar_type ( 0.0 ), hlsl::dot (shadingNormal, L)), hlsl::max ( scalar_type ( 0.0 ), hlsl::dot (shadingNormal, Nt)), NpdotL, hlsl::max ( scalar_type ( 0.0 ), hlsl::dot (Nt, L)));
281+ const scalar_type NpdotL = _sample.getNdotL (BxDFClampMode::BCM_ABS );
282+ quo *= shadowing_method_type::G1 (hlsl::abs ( hlsl::dot (shadingNormal, L)), hlsl::abs ( hlsl::dot (shadingNormal, Nt)), NpdotL, hlsl::abs ( hlsl::dot (Nt, L)), true );
287283 }
288284
289285 return quotient_weight_type::create (quo, forwardPdf (_sample, interaction, _cache));
0 commit comments