the envmap luminaire is verified!

metadata
Wenzel Jakob 2011-07-27 18:50:15 +02:00
parent 7305768f61
commit e379ffda42
3 changed files with 30 additions and 33 deletions

BIN
data/tests/envmap.exr Normal file

Binary file not shown.

View File

@ -2,8 +2,14 @@
to be tested for consistency. This is done using the to be tested for consistency. This is done using the
testcase 'test_chisquare' --> testcase 'test_chisquare' -->
<scene version="0.3.0"> <scene version="0.3.0">
<!-- Test the constant luminaire --> <!-- Test the constant luminaire
<luminaire type="constant"/> <luminaire type="constant"/>
-->
<!-- Test the environment map luminaire -->
<luminaire type="envmap">
<string name="filename" value="data/tests/envmap.exr"/>
</luminaire>
<!-- Make sure that the scene actually contains something --> <!-- Make sure that the scene actually contains something -->
<shape type="sphere"/> <shape type="sphere"/>

View File

@ -331,8 +331,8 @@ public:
} }
if (mismatch) if (mismatch)
Log(EWarn, "Potential inconsistency: f/pdf=%s (sampled), f/pdf=%s (evaluated)", Log(EWarn, "Potential inconsistency: f/pdf=%s (sampled), f/pdf=%s (evaluated), f=%s, pdf=%f, pdf2=%f",
value.toString().c_str(), value2.toString().c_str()); value.toString().c_str(), value2.toString().c_str(), Le.toString().c_str(), pdf, lRec.pdf);
#if defined(MTS_DEBUG_FP) #if defined(MTS_DEBUG_FP)
disableFPExceptions(); disableFPExceptions();
@ -405,7 +405,6 @@ public:
); );
// (the following assumes that the distribution has 1 parameter, e.g. exponent value) // (the following assumes that the distribution has 1 parameter, e.g. exponent value)
chiSqr->dumpTables("test.m");
ChiSquare::ETestResult result = chiSqr->runTest(SIGNIFICANCE_LEVEL); ChiSquare::ETestResult result = chiSqr->runTest(SIGNIFICANCE_LEVEL);
if (result == ChiSquare::EReject) { if (result == ChiSquare::EReject) {
std::string filename = formatString("failure_%i.m", failureCount++); std::string filename = formatString("failure_%i.m", failureCount++);
@ -542,49 +541,41 @@ public:
scene->initialize(); scene->initialize();
const std::vector<Luminaire *> luminaires = scene->getLuminaires(); const std::vector<Luminaire *> luminaires = scene->getLuminaires();
size_t thetaBins = 10, wiSamples = 20, failureCount = 0, testCount = 0; size_t thetaBins = 10, failureCount = 0, testCount = 0;
ref<Sampler> sampler = static_cast<Sampler *> (PluginManager::getInstance()-> ref<Sampler> sampler = static_cast<Sampler *> (PluginManager::getInstance()->
createObject(MTS_CLASS(Sampler), Properties("independent"))); createObject(MTS_CLASS(Sampler), Properties("independent")));
ProgressReporter *progress = new ProgressReporter("Checking", wiSamples, NULL);
Log(EInfo, "Verifying luminaire sampling routines .."); Log(EInfo, "Verifying luminaire sampling routines ..");
for (size_t i=0; i<luminaires.size(); ++i) { for (size_t i=0; i<luminaires.size(); ++i) {
const Luminaire *luminaire = luminaires[i]; const Luminaire *luminaire = luminaires[i];
Log(EInfo, "Processing luminaire function model %s", luminaire->toString().c_str()); Log(EInfo, "Processing luminaire function model %s", luminaire->toString().c_str());
Log(EInfo, "Checking the model for %i incident directions", wiSamples);
progress->reset();
/* Test for a number of different incident directions */ LuminaireAdapter adapter(luminaire, sampler);
for (size_t j=0; j<wiSamples; ++j) { ref<ChiSquare> chiSqr = new ChiSquare(thetaBins, 2*thetaBins, 1);
LuminaireAdapter adapter(luminaire, sampler); chiSqr->setLogLevel(EDebug);
ref<ChiSquare> chiSqr = new ChiSquare(thetaBins, 2*thetaBins, wiSamples); chiSqr->dumpTables("test.m");
chiSqr->setLogLevel(EDebug);
// Initialize the tables used by the chi-square test // Initialize the tables used by the chi-square test
chiSqr->fill( chiSqr->fill(
boost::bind(&LuminaireAdapter::generateSample, &adapter), boost::bind(&LuminaireAdapter::generateSample, &adapter),
boost::bind(&LuminaireAdapter::pdf, &adapter, _1, _2) boost::bind(&LuminaireAdapter::pdf, &adapter, _1, _2)
); );
// (the following assumes that the distribution has 1 parameter, e.g. exponent value) // (the following assumes that the distribution has 1 parameter, e.g. exponent value)
ChiSquare::ETestResult result = chiSqr->runTest(SIGNIFICANCE_LEVEL); ChiSquare::ETestResult result = chiSqr->runTest(SIGNIFICANCE_LEVEL);
if (result == ChiSquare::EReject) { if (result == ChiSquare::EReject) {
std::string filename = formatString("failure_%i.m", failureCount++); std::string filename = formatString("failure_%i.m", failureCount++);
chiSqr->dumpTables(filename); chiSqr->dumpTables(filename);
failAndContinue(formatString("Uh oh, the chi-square test indicates a potential " failAndContinue(formatString("Uh oh, the chi-square test indicates a potential "
"issue. Dumped the contingency tables to '%s' for user analysis", "issue. Dumped the contingency tables to '%s' for user analysis",
filename.c_str())); filename.c_str()));
} else { } else {
succeed(); succeed();
}
++testCount;
progress->update(j+1);
} }
++testCount;
} }
Log(EInfo, "%i/%i luminaire checks succeeded", testCount-failureCount, testCount); Log(EInfo, "%i/%i luminaire checks succeeded", testCount-failureCount, testCount);
delete progress;
} }
}; };