Material that outlines where Two Objects Intersect

Hey guys I need some help.

I have been trying to figure out a way to create a shader that creates an outline where two objects intersect.
Similar to the white outline/froth that is created when the water intersects with the landscape. (example in the attached image)

I have tried DepthFade and PixelDepth but haven’t had any luck.

Thanks for the help.

DepthFade should work, but only with translucent materials.

Thanks Jacky but I am having trouble with changing the Color of the DepthFade.
I have tried setting it up through Base Color and Opacity.

I am also looking to create a solid colored outline whose radius I will be able to increase and decrease.

Hey AustinVonDoom -

Here is an example of how to set up the material:

And here is the result in the Editor:

Jackie is absolutely right though that the water will be a Translucent material.

Thank You -

Eric Ketchum

There is two problems with this solution.
1 It has to be translucent
2 it does not appear around the intersection but where the mesh is below the water mesh.

I am also trying to create a water material but I cant use a translucent material for the water since I’m using pixel depth for the waves and the depth always messes up when its translucent anyway.

How would I use distance fields for this effect? I looked at the documentation for them and got something like the demo mobile fog working however it only effected a tiny area around the intersection, is there any way to enlarge the distance around the intersection that is effected?

Ah, excellent, thank you :slight_smile:

Is there a version of this that works with 2 dynamic actors? I’m not able to find any documentation on how Mesh Distance Fields are generated or what’s included with them, but I’m only able to get this to work with static meshes placed directly into the environment. Even actors that contain static meshes that are placed in the environment don’t seem to work.

Hi ddbrown30 -

Currently, mesh distance fields only work with Static Meshes, you would need to fall back on the Translucent surface option I mentioned previously.

Thank You

Eric Ketchum