pass direct illumination sampler in the MLT seeding process

metadata
Wenzel Jakob 2012-09-29 19:51:58 -04:00
parent 1af8453a58
commit 4689d4fb92
3 changed files with 16 additions and 16 deletions

View File

@ -161,11 +161,6 @@ public:
return false; return false;
} }
Log(EInfo, "First MLT stage took %i ms", timer->getMilliseconds()); Log(EInfo, "First MLT stage took %i ms", timer->getMilliseconds());
std::string debugFile = "mlt_stage1.exr";
Log(EInfo, "Writing upsampled luminances to \"%s\"", debugFile.c_str());
ref<FileStream> fs = new FileStream(debugFile, FileStream::ETruncReadWrite);
m_config.importanceMap->write(Bitmap::EOpenEXR, fs);
} }
bool nested = m_config.twoStage && m_config.firstStage; bool nested = m_config.twoStage && m_config.firstStage;
@ -193,13 +188,18 @@ public:
ref<ReplayableSampler> rplSampler = new ReplayableSampler(); ref<ReplayableSampler> rplSampler = new ReplayableSampler();
ref<PathSampler> pathSampler = new PathSampler(PathSampler::EBidirectional, scene, ref<PathSampler> pathSampler = new PathSampler(PathSampler::EBidirectional, scene,
rplSampler, rplSampler, NULL, m_config.maxDepth, 10, rplSampler, rplSampler, rplSampler, m_config.maxDepth, 10,
m_config.separateDirect, true); m_config.separateDirect, true);
std::vector<PathSeed> pathSeeds; std::vector<PathSeed> pathSeeds;
ref<MLTProcess> process = new MLTProcess(job, queue, ref<MLTProcess> process = new MLTProcess(job, queue,
m_config, directImage, pathSeeds); m_config, directImage, pathSeeds);
m_config.luminance = pathSampler->generateSeeds(m_config.luminanceSamples,
m_config.workUnits, false, pathSeeds);
pathSeeds.clear();
m_config.luminance = pathSampler->generateSeeds(m_config.luminanceSamples, m_config.luminance = pathSampler->generateSeeds(m_config.luminanceSamples,
m_config.workUnits, true, pathSeeds); m_config.workUnits, true, pathSeeds);

View File

@ -79,7 +79,7 @@ public:
static_cast<Sampler *>(getResource("rplSampler"))->clone().get()); static_cast<Sampler *>(getResource("rplSampler"))->clone().get());
m_pathSampler = new PathSampler(PathSampler::EBidirectional, m_scene, m_pathSampler = new PathSampler(PathSampler::EBidirectional, m_scene,
m_rplSampler, m_rplSampler, NULL, m_config.maxDepth, 10, m_rplSampler, m_rplSampler, m_rplSampler, m_config.maxDepth, 10,
m_config.separateDirect, true); m_config.separateDirect, true);
m_pool = &m_pathSampler->getMemoryPool(); m_pool = &m_pathSampler->getMemoryPool();

View File

@ -474,6 +474,14 @@ void PathSampler::samplePaths(const Point2i &offset, PathCallback &callback) {
PathEdge connectionEdge; PathEdge connectionEdge;
m_connectionSubpath.collapseTo(connectionEdge); m_connectionSubpath.collapseTo(connectionEdge);
/* Account for the terms of the measurement contribution
function that are coupled to the connection edge */
if (!sampleDirect)
value *= connectionEdge.evalCached(vs, vt, PathEdge::EGeneralizedGeometricTerm);
else
value *= connectionEdge.evalCached(vs, vt, PathEdge::ETransmittance |
(s == 1 ? PathEdge::ECosineRad : PathEdge::ECosineImp));
if (sampleDirect) { if (sampleDirect) {
/* A direct sampling strategy was used, which generated /* A direct sampling strategy was used, which generated
two new vertices at one of the path ends. Temporarily two new vertices at one of the path ends. Temporarily
@ -488,14 +496,6 @@ void PathSampler::samplePaths(const Point2i &offset, PathCallback &callback) {
value *= Path::miWeight(m_scene, m_emitterSubpath, &connectionEdge, value *= Path::miWeight(m_scene, m_emitterSubpath, &connectionEdge,
m_sensorSubpath, s, t, m_sampleDirect, m_lightImage); m_sensorSubpath, s, t, m_sampleDirect, m_lightImage);
/* Account for the terms of the measurement contribution
function that are coupled to the connection edge */
if (!sampleDirect)
value *= connectionEdge.evalCached(vs, vt, PathEdge::EGeneralizedGeometricTerm);
else
value *= connectionEdge.evalCached(vs, vt, PathEdge::ETransmittance |
(s == 1 ? PathEdge::ECosineRad : PathEdge::ECosineImp));
if (!value.isZero()) { if (!value.isZero()) {
int k = (int) m_connectionSubpath.vertexCount(); int k = (int) m_connectionSubpath.vertexCount();
/* Construct the full path, make a temporary backup copy of the connection vertices */ /* Construct the full path, make a temporary backup copy of the connection vertices */