More numerical robustness for microfacet

metadata
tofic 2014-11-06 21:43:11 +01:00 committed by Wenzel Jakob
parent ce80ddcb6d
commit 8390e5ff5a
2 changed files with 4 additions and 2 deletions

View File

@ -460,6 +460,8 @@ public:
/// Implements the probability density of the function \ref sampleVisible()
Float pdfVisible(const Vector &wi, const Vector &m) const {
if(Frame::cosTheta(wi) == 0)
return 0.0f;
return smithG1(wi, m) * absDot(wi, m) * eval(m) / std::abs(Frame::cosTheta(wi));
}
@ -501,7 +503,7 @@ public:
case EGGX: {
Float root = alpha * tanTheta;
return 2.0f / (1.0f + std::sqrt(1.0f + root*root));
return 2.0f / (1.0f + math::hypot2((Float) 1.0f, root));
}
break;

View File

@ -268,7 +268,7 @@ public:
}
Spectrum eval(const BSDFSamplingRecord &bRec, EMeasure measure) const {
if (measure != ESolidAngle)
if (measure != ESolidAngle || Frame::cosTheta(bRec.wi) == 0)
return Spectrum(0.0f);
/* Determine the type of interaction */