From 4689d4fb92a7c5a59d610c18ecc3c3f8998d648e Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 29 Sep 2012 19:51:58 -0400 Subject: [PATCH] pass direct illumination sampler in the MLT seeding process --- src/integrators/mlt/mlt.cpp | 14 +++++++------- src/integrators/mlt/mlt_proc.cpp | 2 +- src/libbidir/pathsampler.cpp | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/integrators/mlt/mlt.cpp b/src/integrators/mlt/mlt.cpp index 4b557164..2c7443f0 100644 --- a/src/integrators/mlt/mlt.cpp +++ b/src/integrators/mlt/mlt.cpp @@ -161,11 +161,6 @@ public: return false; } 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 fs = new FileStream(debugFile, FileStream::ETruncReadWrite); - m_config.importanceMap->write(Bitmap::EOpenEXR, fs); } bool nested = m_config.twoStage && m_config.firstStage; @@ -193,12 +188,17 @@ public: ref rplSampler = new ReplayableSampler(); ref pathSampler = new PathSampler(PathSampler::EBidirectional, scene, - rplSampler, rplSampler, NULL, m_config.maxDepth, 10, + rplSampler, rplSampler, rplSampler, m_config.maxDepth, 10, m_config.separateDirect, true); - + std::vector pathSeeds; ref process = new MLTProcess(job, queue, 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.workUnits, true, pathSeeds); diff --git a/src/integrators/mlt/mlt_proc.cpp b/src/integrators/mlt/mlt_proc.cpp index 5df58291..e6e01cfe 100644 --- a/src/integrators/mlt/mlt_proc.cpp +++ b/src/integrators/mlt/mlt_proc.cpp @@ -79,7 +79,7 @@ public: static_cast(getResource("rplSampler"))->clone().get()); 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_pool = &m_pathSampler->getMemoryPool(); diff --git a/src/libbidir/pathsampler.cpp b/src/libbidir/pathsampler.cpp index 517febfc..a7fee312 100644 --- a/src/libbidir/pathsampler.cpp +++ b/src/libbidir/pathsampler.cpp @@ -474,6 +474,14 @@ void PathSampler::samplePaths(const Point2i &offset, PathCallback &callback) { PathEdge 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) { /* A direct sampling strategy was used, which generated 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, 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()) { int k = (int) m_connectionSubpath.vertexCount(); /* Construct the full path, make a temporary backup copy of the connection vertices */