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;