fixed a photonmapper regression involving environment maps

metadata
Wenzel Jakob 2012-10-06 23:49:12 -04:00
parent 7bd2d3ecae
commit feb303d639
1 changed files with 45 additions and 41 deletions

View File

@ -197,9 +197,9 @@ public:
SamplingIntegrator::configureSampler(scene, sampler);
if (m_directSamples > 1)
sampler->request2DArray(m_directSamples);
int glossySamples = std::max(m_directSamples, m_glossySamples);
if (glossySamples > 1)
sampler->request2DArray(glossySamples);
int bsdfSamples = std::max(m_directSamples, m_glossySamples);
if (bsdfSamples > 1)
sampler->request2DArray(bsdfSamples);
if (scene->getMedia().size() == 0)
m_volumePhotons = 0;
@ -442,7 +442,7 @@ public:
}
if ((bsdfType & BSDF::EDelta) && (bsdfType & ~BSDF::EDelta) == 0 && rRec.depth < m_maxSpecularDepth && !cacheQuery) {
if (RadianceQueryRecord::EIndirectSurfaceRadiance) {
if (rRec.type & RadianceQueryRecord::EIndirectSurfaceRadiance) {
int compCount = bsdf->getComponentCount();
RadianceQueryRecord rRec2;
for (int i=0; i<compCount; i++) {
@ -493,6 +493,7 @@ public:
}
DirectSamplingRecord dRec(its);
if (bsdf->getType() & BSDF::ESmooth) {
for (int i=0; i<numEmitterSamples; ++i) {
int interactions = m_maxDepth - rRec.depth - 1;
Spectrum value = scene->sampleAttenuatedEmitterDirect(
@ -524,6 +525,7 @@ public:
}
}
}
}
/* ==================================================================== */
/* BSDF sampling */
@ -550,9 +552,6 @@ public:
/* Trace a ray in this direction */
RayDifferential bsdfRay(its.p, its.toWorld(bRec.wo), ray.time);
rRec2.recursiveQuery(rRec,
RadianceQueryRecord::ERadianceNoEmission);
Spectrum value;
bool hitEmitter = false;
if (scene->rayIntersect(bsdfRay, bsdfIts)) {
@ -567,17 +566,12 @@ public:
const Emitter *env = scene->getEnvironmentEmitter();
if (env) {
value = env->evalEnvironment(ray);
if (env->fillDirectSamplingRecord(dRec, ray))
value = env->evalEnvironment(bsdfRay);
if (env->fillDirectSamplingRecord(dRec, bsdfRay))
hitEmitter = true;
}
}
if (its.isMediumTransition())
rRec2.medium = its.getTargetMedium(bsdfRay.d);
rRec2.type ^= RadianceQueryRecord::EIntersection;
if (hitEmitter) {
const Float emitterPdf = (!(bRec.sampledType & BSDF::EDelta)) ?
scene->pdfEmitterDirect(dRec) : 0;
@ -592,9 +586,19 @@ public:
}
/* Recurse */
if (!isDiffuse && (rRec.type & RadianceQueryRecord::EIndirectSurfaceRadiance) && !cacheQuery)
if (!isDiffuse && (rRec.type & RadianceQueryRecord::EIndirectSurfaceRadiance) && !cacheQuery) {
rRec2.recursiveQuery(rRec,
RadianceQueryRecord::ERadianceNoEmission);
rRec2.type ^= RadianceQueryRecord::EIntersection;
if (its.isMediumTransition())
rRec2.medium = its.getTargetMedium(bsdfRay.d);
LiSurf += bsdfVal * m_parentIntegrator->Li(bsdfRay, rRec2) * weightBSDF;
}
}
if (true)
return LiSurf;
} else if (!isDiffuse && (rRec.type & RadianceQueryRecord::EIndirectSurfaceRadiance) && !cacheQuery) {
int numBSDFSamples = (rRec.depth > 1 || adaptiveQuery) ? 1 : m_glossySamples;
Float weightBSDF;