From 227a95c76f111ed7fcd5a512d1125726a0e8b3aa Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 10 Apr 2011 22:09:52 +0200 Subject: [PATCH] dielectric bugfixes --- src/bsdfs/dielectric.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bsdfs/dielectric.cpp b/src/bsdfs/dielectric.cpp index d0b6e289..a6055dae 100644 --- a/src/bsdfs/dielectric.cpp +++ b/src/bsdfs/dielectric.cpp @@ -135,8 +135,8 @@ public: inline Spectrum sample(BSDFQueryRecord &bRec, const Point2 &sample) const { Float pdf=1; Spectrum spec = Dielectric::sample(bRec, pdf, sample); - if (pdf == 0) - return spec; + if (pdf == 0 || spec.isZero()) + return Spectrum(0.0f); return spec/pdf; } @@ -175,17 +175,17 @@ public: bRec.sampledComponent = 0; bRec.sampledType = EDeltaReflection; pdf = std::abs(Frame::cosTheta(bRec.wo)); - return m_reflectance * (fr * std::abs(1.0f/Frame::cosTheta(bRec.wo))); + return m_reflectance * fr; } else if (sampleTransmission) { bRec.sampledComponent = 1; bRec.sampledType = EDeltaTransmission; - pdf = std::abs(Frame::cosTheta(bRec.wo)); Float result = refract(m_intIOR, m_extIOR, bRec.wi, bRec.wo, bRec.quantity); + pdf = std::abs(Frame::cosTheta(bRec.wo)); if (result == 0) return Spectrum(0.0f); - return m_transmittance * (result * (1-fr) * std::abs(1.0f/Frame::cosTheta(bRec.wo))); + return m_transmittance * result * (1-fr); } return Spectrum(0.0f); }