diff --git a/src/pbrt/bxdfs.cpp b/src/pbrt/bxdfs.cpp index cd65f3c19a809af52a525535f4da7321703fe0d9..9ab74a2b077592d0c6bc003749d6d02bbec0a3f2 100644 --- a/src/pbrt/bxdfs.cpp +++ b/src/pbrt/bxdfs.cpp @@ -424,6 +424,9 @@ pstd::optional HairBxDF::Sample_f(Vector3f wo, Float uc, Point2f u, cosThetap_o = cosTheta_o; } + // Handle out-of-range $\cos \thetao$ from scale adjustment + cosThetap_o = std::abs(cosThetap_o); + // Sample $M_p$ to compute $\thetai$ Float cosTheta = 1 + v[p] * std::log(std::max(u[0], 1e-5) + (1 - u[0]) * FastExp(-2 / v[p])); @@ -473,6 +476,9 @@ pstd::optional HairBxDF::Sample_f(Vector3f wo, Float uc, Point2f u, // Handle out-of-range $\cos \thetao$ from scale adjustment cosThetap_o = std::abs(cosThetap_o); + // Handle out-of-range $\cos \thetao$ from scale adjustment + cosThetap_o = std::abs(cosThetap_o); + pdf += Mp(cosTheta_i, cosThetap_o, sinTheta_i, sinThetap_o, v[p]) * apPDF[p] * Np(dphi, p, s, gamma_o, gamma_t); }