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.87k stars 1.18k forks source link

HairBSDF's beta_m param maybe bring a nan problem #219

Closed zq317157782 closed 5 years ago

zq317157782 commented 5 years ago

In hair.h/cpp I found that when beta_m eq zero,the set of roughness variance v[pMax]'s elements are alse all zero,and beta_m eq zero is a valid param. But I also found in functionMp has code: Float a = cosThetaI * cosThetaO / v; Float b = sinThetaI * sinThetaO / v; that v maybe a zero.I think this will cause a nan problem maybe.

syoyo commented 5 years ago

Actually, there are many places that floating point become NaN(e.g. division by zero) or Inf (e.g. log/exp) in PBRT's hair bsdf implementation.

We have to add nan/inf/zero check in many places in our own hair BSDF module based on PBRT-v3.

zq317157782 commented 5 years ago

Hi syoyo. I haven't read the original paper,so I can't ensure these behaviors(NaN/INF/zero) are correct in mathematics based on this hair bsdf model,I think I should cost some time to read this paper.Thanks for comment!