From 979e0fa7a0f3f46dd45fee8f39abc08b5c9c9344 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Mon, 11 Feb 2013 22:07:00 -0500 Subject: [PATCH] ptracer: better handling of unscattered emission -> camera paths --- src/integrators/ptracer/ptracer_proc.cpp | 7 ++++++- src/librender/scene.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/integrators/ptracer/ptracer_proc.cpp b/src/integrators/ptracer/ptracer_proc.cpp index 781f8f7d..e7c224c2 100644 --- a/src/integrators/ptracer/ptracer_proc.cpp +++ b/src/integrators/ptracer/ptracer_proc.cpp @@ -88,8 +88,13 @@ void CaptureParticleWorker::handleEmission(const PositionSamplingRecord &pRec, DirectSamplingRecord dRec(pRec.p, pRec.time); int maxInteractions = m_maxPathDepth - 1; + /* Create a dummy intersection to ensure that sampleAttenuatedSensorDirect() + treats the light source vertex as being located on a surface */ + Intersection its; + its.p = pRec.p; + Spectrum value = weight * m_scene->sampleAttenuatedSensorDirect( - dRec, medium, maxInteractions, m_sampler->next2D(), m_sampler); + dRec, its, medium, maxInteractions, m_sampler->next2D(), m_sampler); if (value.isZero()) return; diff --git a/src/librender/scene.cpp b/src/librender/scene.cpp index 0ebc510f..ac42ce4f 100644 --- a/src/librender/scene.cpp +++ b/src/librender/scene.cpp @@ -881,7 +881,7 @@ Spectrum Scene::sampleAttenuatedEmitterDirect(DirectSamplingRecord &dRec, Spectrum value = emitter->sampleDirect(dRec, sample); if (dRec.pdf != 0) { - if (its.isMediumTransition()) + if (its.shape && its.isMediumTransition()) medium = its.getTargetMedium(dRec.d); value *= evalTransmittance(its.p, true, dRec.p, emitter->isOnSurface(), dRec.time, medium, interactions, sampler) / emPdf; @@ -931,7 +931,7 @@ Spectrum Scene::sampleAttenuatedSensorDirect(DirectSamplingRecord &dRec, Spectrum value = m_sensor->sampleDirect(dRec, sample); if (dRec.pdf != 0) { - if (its.isMediumTransition()) + if (its.shape && its.isMediumTransition()) medium = its.getTargetMedium(dRec.d); value *= evalTransmittance(its.p, true, dRec.p, m_sensor->isOnSurface(), dRec.time, medium, interactions, sampler);