From a721b1874073f10db56367f8979a163286e97ca9 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 24 Jan 2013 20:06:58 -0500 Subject: [PATCH] better computation of the alpha channel when rendering index-matched media --- include/mitsuba/render/records.inl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/include/mitsuba/render/records.inl b/include/mitsuba/render/records.inl index b6ee2894..2cc60831 100644 --- a/include/mitsuba/render/records.inl +++ b/include/mitsuba/render/records.inl @@ -101,12 +101,23 @@ inline bool RadianceQueryRecord::rayIntersect(const RayDifferential &ray) { if (type & EIntersection) { scene->rayIntersect(ray, its); if (type & EOpacity) { - if (its.isValid()) - alpha = 1.0f; - else if (medium == NULL) + int unused = INT_MAX; + + if (its.isValid()) { + if (EXPECT_TAKEN(!its.isMediumTransition())) + alpha = 1.0f; + else + alpha = 1-scene->evalTransmittance(its.p, true, + ray(scene->getBSphere().radius*2), false, + ray.time, its.getTargetMedium(ray.d), unused).average(); + } else if (medium) { + alpha = 1-scene->evalTransmittance(ray.o, false, + ray(scene->getBSphere().radius*2), false, + ray.time, medium, unused).average(); + } else { alpha = 0.0f; - else - alpha = 1-medium->evalTransmittance(ray).average(); + } + } if (type & EDistance) dist = its.t;