Skip to content

Commit 6e84d79

Browse files
committed
fix yining masking term
1 parent db2dc26 commit 6e84d79

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

include/nbl/builtin/hlsl/bxdf/ndf/microfacet_normal_shadowing.hlsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct ShadowingMethod<T, PNS_YINING>
6464
static scalar_type G1(const scalar_type clampedNdotL, const scalar_type NdotNp, const scalar_type clampedNpdotL, const scalar_type clampedNtdotL)
6565
{
6666
const scalar_type g = hlsl::min(scalar_type(1.0),
67-
clampedNpdotL / (clampedNdotL * NdotNp)
67+
clampedNdotL / (clampedNpdotL * NdotNp)
6868
);
6969
const scalar_type g2 = g * g;
7070
return -g2 * g + g2 + g;
@@ -80,6 +80,8 @@ struct ShadowingMethod<T, PNS_YINING>
8080
{
8181
const scalar_type sinThetaNp = hlsl::sqrt(hlsl::max(1.0 - NdotNp * NdotNp, 0.0));
8282
const scalar_type ap = clampedNpdotV * NdotNp;
83+
if (ap < numeric_limits<scalar_type>::min)
84+
return scalar_type(0.0);
8385
const scalar_type at = clampedNtdotV * sinThetaNp;
8486
return ap / (ap + at);
8587
}

0 commit comments

Comments
 (0)