Commit 0d5fd12d authored by Matt Pharr's avatar Matt Pharr

Improve log() computation in Beckmann microfacet normal sampling.

parent 90649865
......@@ -201,15 +201,15 @@ Vector3f BeckmannDistribution::Sample_wh(const Vector3f &wo,
// Compute $\tan^2 \theta$ and $\phi$ for Beckmann distribution sample
Float tan2Theta, phi;
if (alphax == alphay) {
Float logSample = std::log(u[0]);
if (std::isinf(logSample)) logSample = 0;
Float logSample = std::log(1 - u[0]);
DCHECK(!std::isinf(logSample));
tan2Theta = -alphax * alphax * logSample;
phi = u[1] * 2 * Pi;
} else {
// Compute _tan2Theta_ and _phi_ for anisotropic Beckmann
// distribution
Float logSample = std::log(u[0]);
if (std::isinf(logSample)) logSample = 0;
Float logSample = std::log(1 - u[0]);
DCHECK(!std::isinf(logSample));
phi = std::atan(alphay / alphax *
std::tan(2 * Pi * u[1] + 0.5f * Pi));
if (u[1] > 0.5f) phi += Pi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment