medium handling fixes in photonmapper.cpp

metadata
Wenzel Jakob 2011-09-15 14:03:45 -04:00
parent 94ea62495c
commit 14ce675ebb
1 changed files with 10 additions and 5 deletions

View File

@ -387,9 +387,12 @@ public:
Spectrum bsdfVal = bsdf->sample(bRec, Point2(0.0f)); Spectrum bsdfVal = bsdf->sample(bRec, Point2(0.0f));
if (bsdfVal.isZero()) if (bsdfVal.isZero())
continue; continue;
rRec2.recursiveQuery(rRec, RadianceQueryRecord::ERadiance); rRec2.recursiveQuery(rRec, RadianceQueryRecord::ERadiance);
RayDifferential bsdfRay(its.p, its.toWorld(bRec.wo), ray.time); RayDifferential bsdfRay(its.p, its.toWorld(bRec.wo), ray.time);
if (its.isMediumTransition())
rRec2.medium = its.getTargetMedium(bsdfRay.d);
LiSurf += bsdfVal * m_parentIntegrator->Li(bsdfRay, rRec2); LiSurf += bsdfVal * m_parentIntegrator->Li(bsdfRay, rRec2);
} }
} }
@ -426,7 +429,7 @@ public:
for (int i=0; i<numLuminaireSamples; ++i) { for (int i=0; i<numLuminaireSamples; ++i) {
/* Estimate the direct illumination if this is requested */ /* Estimate the direct illumination if this is requested */
if (scene->sampleAttenuatedLuminaire(its.p, ray.time, rRec.medium, if (scene->sampleAttenuatedLuminaire(its, rRec.medium,
lRec, sampleArray[i], rRec.sampler)) { lRec, sampleArray[i], rRec.sampler)) {
/* Allocate a record for querying the BSDF */ /* Allocate a record for querying the BSDF */
BSDFQueryRecord bRec(its, its.toLocal(-lRec.d)); BSDFQueryRecord bRec(its, its.toLocal(-lRec.d));
@ -476,10 +479,13 @@ public:
rRec2.recursiveQuery(rRec, rRec2.recursiveQuery(rRec,
RadianceQueryRecord::ERadianceNoEmission); RadianceQueryRecord::ERadianceNoEmission);
if (its.isMediumTransition())
rRec2.medium = its.getTargetMedium(bsdfRay.d);
bool indexMatchedMediumTransition = false; bool indexMatchedMediumTransition = false;
Spectrum transmittance; Spectrum transmittance;
scene->attenuatedRayIntersect(bsdfRay, rRec.medium, bsdfIts, scene->attenuatedRayIntersect(bsdfRay, rRec2.medium, bsdfIts,
indexMatchedMediumTransition, transmittance, rRec.sampler); indexMatchedMediumTransition, transmittance, rRec.sampler);
rRec2.type ^= RadianceQueryRecord::EIntersection; rRec2.type ^= RadianceQueryRecord::EIntersection;
@ -518,8 +524,7 @@ public:
we need to rewind and account for this transition -- therefore, we need to rewind and account for this transition -- therefore,
another ray intersection call is neccessary */ another ray intersection call is neccessary */
scene->rayIntersect(bsdfRay, bsdfIts); scene->rayIntersect(bsdfRay, bsdfIts);
} }
LiSurf += bsdfVal * m_parentIntegrator->Li(bsdfRay, rRec2) * weightBSDF; LiSurf += bsdfVal * m_parentIntegrator->Li(bsdfRay, rRec2) * weightBSDF;
} }