volpath_simple: render images correctly matching maxDepth when delta bounces are involved (attempt 2)

metadata
Wenzel Jakob 2010-11-25 21:38:54 +01:00
parent 2131bdb817
commit cbe5de3a01
1 changed files with 25 additions and 17 deletions

View File

@ -53,9 +53,9 @@ public:
intersection has already been provided). */ intersection has already been provided). */
rRec.rayIntersect(ray); rRec.rayIntersect(ray);
Spectrum pathThroughput(1.0f); Spectrum pathThroughput(1.0f);
bool computeIntersection = false, deltaBounce = false; bool computeIntersection = false;
while (rRec.depth < m_maxDepth || m_maxDepth < 0 || (rRec.depth == m_maxDepth && deltaBounce)) { while (rRec.depth < m_maxDepth || m_maxDepth < 0) {
if (computeIntersection) if (computeIntersection)
scene->rayIntersect(ray, its); scene->rayIntersect(ray, its);
@ -103,10 +103,11 @@ public:
if (!(rRec.type & RadianceQueryRecord::EInscatteredIndirectRadiance)) { if (!(rRec.type & RadianceQueryRecord::EInscatteredIndirectRadiance)) {
/* Stop if multiple scattering was not requested (except: sampled a delta phase function /* Stop if multiple scattering was not requested (except: sampled a delta phase function
- look for emitted radiance only) */ - look for emitted radiance only) */
if (sampledType == PhaseFunction::EDelta) if (sampledType == PhaseFunction::EDelta) {
rRec.type = RadianceQueryRecord::EEmittedRadiance; rRec.type = RadianceQueryRecord::EEmittedRadiance;
else } else {
break; break;
}
} else { } else {
if (sampledType != PhaseFunction::EDelta || !(rRec.type & RadianceQueryRecord::EInscatteredDirectRadiance)) { if (sampledType != PhaseFunction::EDelta || !(rRec.type & RadianceQueryRecord::EInscatteredDirectRadiance)) {
/* Emitted radiance is only included in the recursive query if: /* Emitted radiance is only included in the recursive query if:
@ -114,10 +115,8 @@ public:
- the current query asks for single scattering - the current query asks for single scattering
*/ */
rRec.type = RadianceQueryRecord::ERadianceNoEmission; rRec.type = RadianceQueryRecord::ERadianceNoEmission;
deltaBounce = false;
} else { } else {
rRec.type = RadianceQueryRecord::ERadiance; rRec.type = RadianceQueryRecord::ERadiance;
deltaBounce = true;
} }
} }
@ -188,27 +187,36 @@ public:
/* Indirect illumination */ /* Indirect illumination */
/* ==================================================================== */ /* ==================================================================== */
bool includeEmitted = (bRec.sampledType & BSDF::EDelta)
&& (rRec.type & RadianceQueryRecord::EDirectRadiance);
/* Stop if indirect illumination was not requested */ /* Stop if indirect illumination was not requested */
if (!(rRec.type & RadianceQueryRecord::EIndirectRadiance)) { if (!(rRec.type & RadianceQueryRecord::EIndirectRadiance)) {
/* Stop if indirect illumination was not requested (except: sampled a delta BSDF /* Stop if indirect illumination was not requested (except: sampled a delta BSDF
- look for emitted radiance only) */ - recursively look for emitted radiance only to get the direct component) */
if (bRec.sampledType & BSDF::EDelta) { if (includeEmitted) {
deltaBounce = true;
rRec.type = RadianceQueryRecord::EEmittedRadiance; rRec.type = RadianceQueryRecord::EEmittedRadiance;
if (rRec.depth+1 == m_maxDepth) {
/* Do one extra recursion to get the emitted radiance component
(e.g. from an envmap). We must reduce rRec.depth
or the loop will terminate */
--rRec.depth;
}
} else { } else {
break; break;
} }
} else { } else {
if (!(bRec.sampledType & BSDF::EDelta) || !(rRec.type & RadianceQueryRecord::EDirectRadiance)) { if (!includeEmitted) {
/* Emitted radiance is only included in the recursive query if:
- the sampled BSDF component had a Dirac delta distribution AND
- the current query asks for direct illumination
*/
rRec.type = RadianceQueryRecord::ERadianceNoEmission; rRec.type = RadianceQueryRecord::ERadianceNoEmission;
deltaBounce = false; } else {
if (rRec.depth+1 == m_maxDepth) {
/* Do one extra recursion to get the emitted radiance component
(e.g. from an envmap). We must reduce rRec.depth
or the loop will terminate */
--rRec.depth;
rRec.type = RadianceQueryRecord::EEmittedRadiance;
} else { } else {
rRec.type = RadianceQueryRecord::ERadiance; rRec.type = RadianceQueryRecord::ERadiance;
deltaBounce = true; }
} }
} }