Skip to content

Commit

Permalink
Fix bug in MicrofacetTransmission
Browse files Browse the repository at this point in the history
Return 0 for f() and pdf if both directions are on the same side of the microsurface.

Issue mmp#228, via Mandy Xia.
  • Loading branch information
mmp committed Jun 26, 2020
1 parent 3123d85 commit 9629f11
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ Spectrum MicrofacetTransmission::f(const Vector3f &wo,
Vector3f wh = Normalize(wo + wi * eta);
if (wh.z < 0) wh = -wh;

// Same side?
if (Dot(wo, wh) * Dot(wi, wh) > 0) return Spectrum(0);

Spectrum F = fresnel.Evaluate(Dot(wo, wh));

Float sqrtDenom = Dot(wo, wh) + eta * Dot(wi, wh);
Expand Down Expand Up @@ -445,6 +448,8 @@ Float MicrofacetTransmission::Pdf(const Vector3f &wo,
Float eta = CosTheta(wo) > 0 ? (etaB / etaA) : (etaA / etaB);
Vector3f wh = Normalize(wo + wi * eta);

if (Dot(wo, wh) * Dot(wi, wh) > 0) return 0;

// Compute change of variables _dwh\_dwi_ for microfacet transmission
Float sqrtDenom = Dot(wo, wh) + eta * Dot(wi, wh);
Float dwh_dwi =
Expand Down

0 comments on commit 9629f11

Please sign in to comment.