mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.86k stars 1.18k forks source link

Total internal reflection is broken for rough glass #254

Closed timo-oster closed 4 years ago

timo-oster commented 4 years ago

Hi,

I noticed that PBRT swallows rays that should be totally internally reflected in rough glass materials. If you create a rough glass box and place it in a completely white InfiniteAreaLight (see attached file), the box should have a uniform color, but PBRT produces dark areas where total internal reflection should be happening.

The reason I believe is that when computing the half vector in MicrofacetReflection::f, it is not ensured that it points outwards. However, the FrDielectric function relies on this for handling total internal reflection correctly.

The same problem was reported by a user on Google groups here, which also includes a discussion about a possible fix.

pbrtfile.zip

mmp commented 4 years ago

Fixed now, and thanks for the clear diagnosis of the problem--that made the fix easy.