Visibility of volumes is now handled on a shader level, not during
ray traversal. Before, this could lead to inconsistent states.
Detailed description of the issue:
When maintaining the volume stack and tracking volume visibility at intersection level, we see problems when a path enters a volume as one kind of ray and leaves it as the other. It can happen that either an enter or leave event is missed and a volume is mistaken as either missing or infinite.
In this example, the object in the middle is for reference, with all visibility enabled.
The left object is set to be invisible to shadow rays. Note that the ground plane, intersecting the volume, is fully in the shadow because the path registers as being inside the volume via the camera ray intersections, but the following shadow ray never leaves the volume. The volume is also casting a strong shadow onto itself.
The object on the right is the opposite effect - invisible to the camera, visible to all other rays. There the shadow ray from the ground plane inside the volume notices that it leaves the volume, but the camera ray leading to it never registered that it entered the volume.
(before the patch)
With volumes being visible to all intersections and resolving visibility at shading time, this can be fixed. Then segments of a path can correctly account for mixed ray visibility.
(after the patch)
This may look like an esoteric problem - it was very obvious for us though when we started trying to render volumes separately for compositing and wanted to have volumes invisible to the camera, but still wanted their shadows to show up.
As reference, this is what the scene looks like when every volume is visible to all rays. It is obvious that the object on the left, when set invisible to shadow rays, comes out much darker than it should.