From 0175931ed34ee763cd283e38d96b216a6792a497 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 22 Jul 2011 18:43:11 +0200 Subject: [PATCH] bugfixes to the coating material --- data/tests/test_bsdf.xml | 17 ++++++++--------- doc/acknowledgements.tex | 4 ++-- src/bsdfs/bump.cpp | 2 +- src/bsdfs/coating.cpp | 37 +++++++++++++++++++----------------- src/tests/test_chisquare.cpp | 6 +++--- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/data/tests/test_bsdf.xml b/data/tests/test_bsdf.xml index 1ce3b51e..54c46889 100644 --- a/data/tests/test_bsdf.xml +++ b/data/tests/test_bsdf.xml @@ -2,15 +2,6 @@ to be tested for consistency. This is done using the testcase 'test_chisquare' --> - - - - - - - - - @@ -201,4 +192,12 @@ + + + + + + + diff --git a/doc/acknowledgements.tex b/doc/acknowledgements.tex index 4619cbda..a6338cb0 100644 --- a/doc/acknowledgements.tex +++ b/doc/acknowledgements.tex @@ -3,7 +3,7 @@ The architecture of Mitsuba as well as some individual components are based on i The architecture of the coherent path tracer traversal code was influenced by Radius from Thierry Berger-Perrin. Many thanks go to my advisor Steve Marschner, who let me spend time on this project. Some of the GUI icons were taken from the Humanity icon set by Canonical Ltd. -The material test scene was kindly contributed by Jonas Pilo, and the environment map +The material test scene was created by Jonas Pilo, and the environment map it uses is courtesy of Bernhard Vogl. The included index of refraction data files for conductors are copied from @@ -13,7 +13,7 @@ and measurements of atomic scattering factors made by the Center For X-Ray Optics (CXRO) at Berkeley and the Lawrence Livermore National Laboratory (LLNL). -The following people have contributed code or bugfixes: +The following people have kindly contributed code or bugfixes: \begin{itemize} \item Milo\^{s} Ha\^{s}an \item Tom Kazimiers diff --git a/src/bsdfs/bump.cpp b/src/bsdfs/bump.cpp index d8a966d8..3c68c907 100644 --- a/src/bsdfs/bump.cpp +++ b/src/bsdfs/bump.cpp @@ -21,7 +21,7 @@ MTS_NAMESPACE_BEGIN -/*! \plugin{bump}{Bump map} +/*! \plugin{bump}{Bump map modifier} * \icon{bsdf_bump} * * \parameters{ diff --git a/src/bsdfs/coating.cpp b/src/bsdfs/coating.cpp index 50ad36ac..105990be 100644 --- a/src/bsdfs/coating.cpp +++ b/src/bsdfs/coating.cpp @@ -236,9 +236,8 @@ public: if (R12 == 1 || R21 == 1) /* Total internal reflection */ return Spectrum(0.0f); - Float eta = m_extIOR / m_intIOR; Spectrum result = m_nested->eval(bRecInt, measure) - * ((1-R12) * (1-R21) * eta * eta); + * (1-R12) * (1-R21); Spectrum sigmaA = m_sigmaA->getValue(bRec.its) * m_thickness; if (!sigmaA.isZero()) @@ -246,9 +245,11 @@ public: (1/std::abs(Frame::cosTheta(bRecInt.wi)) + 1/std::abs(Frame::cosTheta(bRecInt.wo)))).exp(); - if (measure == ESolidAngle) - result *= std::abs(Frame::cosTheta(bRec.wo) + if (measure == ESolidAngle) { + Float eta = m_extIOR / m_intIOR; + result *= eta * eta * std::abs(Frame::cosTheta(bRec.wo) / Frame::cosTheta(bRecInt.wo)); + } return result; } @@ -281,15 +282,15 @@ public: if (R12 == 1 || R21 == 1) /* Total internal reflection */ return 0.0f; - + Float pdf = m_nested->pdf(bRecInt, measure); - if (measure == ESolidAngle) - pdf *= std::abs(Frame::cosTheta(bRec.wo) - / Frame::cosTheta(bRecInt.wo)); + if (measure == ESolidAngle) { + Float eta = m_extIOR / m_intIOR; + pdf *= eta * eta * std::abs(Frame::cosTheta(bRec.wo) + / Frame::cosTheta(bRecInt.wo)); + } - Float eta = m_extIOR / m_intIOR; - pdf *= eta * eta; return sampleSpecular ? (pdf * (1 - probSpecular)) : pdf; } else { @@ -340,11 +341,11 @@ public: bRec.wi = wiPrime; Spectrum result = m_nested->sample(bRec, pdf, sample); bRec.wi = wiBackup; - Vector woPrime = bRec.wo; - if (result.isZero()) return Spectrum(0.0f); + Vector woPrime = bRec.wo; + Spectrum sigmaA = m_sigmaA->getValue(bRec.its) * m_thickness; if (!sigmaA.isZero()) result *= (-sigmaA * @@ -353,14 +354,16 @@ public: Float R21; bRec.wo = refractTo(EExterior, woPrime, R21); - if (R21 == 1.0f) /* Total internal reflection */ return Spectrum(0.0f); - Float eta = m_extIOR / m_intIOR; - bool sampledSA = (BSDF::getMeasure(bRec.sampledType) == ESolidAngle); - Float cosRatio = std::abs(Frame::cosTheta(bRec.wo) / Frame::cosTheta(woPrime)), - commonTerms = (sampledSA ? cosRatio : 1.0f) * eta * eta; + Float commonTerms = 1.0f; + + if (BSDF::getMeasure(bRec.sampledType) == ESolidAngle) { + Float eta = m_extIOR / m_intIOR; + commonTerms = eta*eta * + std::abs(Frame::cosTheta(bRec.wo) / Frame::cosTheta(woPrime)); + } pdf *= (sampleSpecular ? (1 - probSpecular) : 1.0f) * commonTerms; result *= (1 - R12) * (1 - R21) * commonTerms; diff --git a/src/tests/test_chisquare.cpp b/src/tests/test_chisquare.cpp index f9602ff1..8b4433d7 100644 --- a/src/tests/test_chisquare.cpp +++ b/src/tests/test_chisquare.cpp @@ -117,7 +117,7 @@ public: #endif Float pdfVal, pdfVal2; - + /* Check the various sampling routines for agreement amongst each other */ m_fakeSampler->clear(); @@ -132,8 +132,8 @@ public: if (f.isZero() || pdfVal == 0 || pdfVal2 == 0) { if (!sampled.isZero()) - Log(EWarn, "Inconsistency (1): f=%s, f2=%s, pdf=%f, pdf2=%f, sampled f/pdf=%s, bRec=%s", - f.toString().c_str(), f2.toString().c_str(), pdfVal, pdfVal2, sampled.toString().c_str(), bRec.toString().c_str()); + Log(EWarn, "Inconsistency (1): f=%s, f2=%s, pdf=%f, pdf2=%f, sampled f/pdf=%s, bRec=%s, measure=%i", + f.toString().c_str(), f2.toString().c_str(), pdfVal, pdfVal2, sampled.toString().c_str(), bRec.toString().c_str(), measure); #if defined(MTS_DEBUG_FP) disableFPExceptions(); #endif