Material Overlays within a Volume

I’m trying to achieve a certain effect that I simply cannot figure out. What I want to do is apply a material overlay to objects that are within a volume (or perhaps within the boundaries of a static mesh, depending on which ends up being easier). A rough example of this might be if I had a scene with a bunch of normally-textured objects, any objects that are placed within the volume would have a green glow, or a blue checker pattern overlaid on top, or whatever. Objects that are partially within the volume would have the overlay only applied to the parts that are within the volume. A mocked-up example is below:

The problem with using post-process effects is twofold. 1) They are only visible when the camera is inside the volume and 2) when visible they affect everything, not just geometry that is within them. Similarly, a static mesh with a blended material is visible no matter where the camera is but will affect every object that is behind it, not just objects within it.

Suggestions would be appreciated. Thanks!

This is very possible, however you must apply the volumes in a deferred way. This is a similar method to how lights work, but instead of applying lighting calculations you can just apply a post process effect. You can use position data and a radius to control what the effect is applied to and limit it to the volume which should prevent distant things being affected even if the volume is infront of them as there will be a limit just like with a light.

I created something like this for someone in work this week, you could feed the material a World Position from Blueprints and it would create a spherical world-space mask that you could use. This is in it’s most simplest form:

d57bfd9ea436928c16d9fce6c2735ad080b10ecd.jpeg

Just feed that parameter via Blueprints (or if you know where the volume will be, hard-set it). And you’re good to go :slight_smile: You can only make this respond to one ‘volume’ at a time. The other method would be to use a more complex custom depth approach.

This material applied to a sphere mesh in a blueprint (making sure to use proper gbuffer textures to get position and screen-aligned uvs) would work perfectly fine. You could definitely go crazy and make a custom type of light if you really wanted to using the material editor.