HK and coating bugfixes

metadata
Wenzel Jakob 2011-07-28 14:25:03 +02:00
parent ff025d558f
commit 4d01f32749
5 changed files with 25 additions and 16 deletions

View File

@ -5,9 +5,9 @@
<!-- Test the coating model with the Hanrahan-Krueger model -->
<bsdf type="coating">
<bsdf type="hk">
<!-- <rgb name="sigmaA" value="0.1 0.2 0.3"/>
<rgb name="sigmaA" value="0.1 0.2 0.3"/>
<rgb name="sigmaS" value="1"/>
<float name="thickness" value="20"/>-->
<float name="thickness" value="2"/>
</bsdf>
</bsdf>

View File

@ -15,6 +15,7 @@ plugins += env.SharedLibrary('twosided', ['twosided.cpp'])
plugins += env.SharedLibrary('mask', ['mask.cpp'])
plugins += env.SharedLibrary('mixture', ['mixture.cpp'])
plugins += env.SharedLibrary('coating', ['coating.cpp'])
plugins += env.SharedLibrary('coatingold', ['coatingold.cpp'])
plugins += env.SharedLibrary('bump', ['bump.cpp'])
# Other materials

View File

@ -247,8 +247,9 @@ public:
if (measure == ESolidAngle) {
Float eta = m_extIOR / m_intIOR;
result *= eta * eta * std::abs(Frame::cosTheta(bRec.wo)
/ Frame::cosTheta(bRecInt.wo));
/* Solid angle compression & irradiance conversion factors */
result *= eta * eta * std::abs(Frame::cosTheta(bRec.wi)
/ Frame::cosTheta(bRecInt.wi));
}
return result;
@ -357,16 +358,21 @@ public:
if (R21 == 1.0f) /* Total internal reflection */
return Spectrum(0.0f);
Float commonTerms = 1.0f;
if (sampleSpecular)
pdf *= 1 - probSpecular;
result *= (1 - R12) * (1 - R21);
if (BSDF::getMeasure(bRec.sampledType) == ESolidAngle) {
Float eta = m_extIOR / m_intIOR;
commonTerms = eta*eta *
Float eta = m_extIOR / m_intIOR, etaSqr = eta*eta;
/* Solid angle compression & irradiance conversion factors */
result *= etaSqr *
std::abs(Frame::cosTheta(bRec.wi) / Frame::cosTheta(wiPrime));
pdf *= etaSqr *
std::abs(Frame::cosTheta(bRec.wo) / Frame::cosTheta(woPrime));
}
pdf *= (sampleSpecular ? (1 - probSpecular) : 1.0f) * commonTerms;
result *= (1 - R12) * (1 - R21) * commonTerms;
return result;
}

View File

@ -154,9 +154,11 @@ public:
bool hasGlossyTransmission = (bRec.typeMask & EGlossyTransmission)
&& (bRec.component == -1 || bRec.component == 1);
const Float cosThetaI = Frame::cosTheta(bRec.wi);
const Float cosThetaO = Frame::cosTheta(bRec.wo);
bool reflection = cosThetaI * cosThetaO > 0;
const Float cosThetaI = Frame::cosTheta(bRec.wi),
cosThetaO = Frame::cosTheta(bRec.wo),
dp = cosThetaI*cosThetaO;
bool reflection = dp > 0, transmission = dp < 0;
/* ==================================================================== */
/* Reflection component */
@ -175,13 +177,13 @@ public:
/* Transmission component */
/* ==================================================================== */
if (hasGlossyTransmission && !reflection) {
if (hasGlossyTransmission && transmission) {
MediumSamplingRecord dummy;
PhaseFunctionQueryRecord pRec(dummy,bRec.wi,bRec.wo);
const Float phaseVal = m_phase->eval(pRec);
/* Hanrahan etal 93 Single Scattering transmission term */
if (cosThetaI + cosThetaO == 0.0f) {
if (std::abs(cosThetaI + cosThetaO) < Epsilon) {
/* avoid division by zero */
result += m_albedo * phaseVal*m_tauD/std::abs(cosThetaO) *
((-m_tauD/std::abs(cosThetaO)).exp());

View File

@ -47,8 +47,8 @@ class TestChiSquare : public TestCase {
public:
MTS_BEGIN_TESTCASE()
MTS_DECLARE_TEST(test03_Luminaire)
// MTS_DECLARE_TEST(test01_BSDF)
// MTS_DECLARE_TEST(test02_PhaseFunction)
MTS_DECLARE_TEST(test01_BSDF)
MTS_DECLARE_TEST(test02_PhaseFunction)
MTS_END_TESTCASE()
/**