Volumetric fog and DistanceToNearestSurface

Hello,

I have an actor called Clouds. This is a collection of sphere meshes with a “cloud” material applied. The cloud material is a Masked material that uses DistanceToNearestSurface in order to cut shapes into the clouds (part of my gameplay is having players fall through clouds and leave imprints).

The problem that I’m having is regarding the new Volumetric Fog feature in 4.16. I have an IF inside the cloud material which determines the opacity mask (if something is touching the cloud, it will have a 0 opacity in that location). This opacity mask technique works well BUT it does not seem to work correctly with Volumetric Fog. If I hard set the opacity mask to be 1, then the fog behaves correctly with the clouds, and I get nice shafts of light playing around the shapes of the opaque (1) clouds. However, if I use the IF statement, which takes the DistanceToNearestSurface node as input, though it appears to be fully opaque in the editor, the volumetric fog is not interacting correctly (i.e. ignores the clouds).

Something to note, inside the blueprint editor, when I have my Cloud material applied to this collection of spheres, they are completely invisible (viewport). When I drag the actor into the scene, however, they are correctly opaque in the right areas. I suspect that this could be related to the root of the issue with the volumetric fog ignoring the clouds despite their appearing correctly in the editor.

My end goal is to be able to have the volumetric fog “light rays” be shining up against the clouds, as well as through the holes that players leave behind as they fall through the clouds. I’ve tested a non-uniform opacity mask texture, and it behaves correctly so I don’t think the problem is with masked materials and volumetric fog. I think the issue is much deeper and something about UE4 rendering that I don’t understand, perhaps the order in which things are resolved.

Any help or insight is greatly appreciated :slight_smile:

EDIT:
By checking Dither Opacity Mask in the material details, I was able to correctly use a the masked cloud material and have it interact with the volumetric fog/lighting. However, I haven’t been able to get the light to go THROUGH the masked areas (0 opacity). I tried using the DitherTemporalAA node in conjunction with this but that didn’t work either.