How to make a material(?) that highlights its edges at mesh intersections? Examples attached.

Hey guys, I’m looking for some input on how I can create an effect that I’ve seen commonly used in other games. I’m not sure exactly what you might call it, but the idea is that a transparent material is highlighted around a sphere’s edges, similar to a fresnel effect, but then is also highlighted along the intersection with other meshes in the game world. For example, in the Destiny screenshots above, you can see the spherical shields mold themselves to the shape of the ground and walls around them. If a player walks through the shield, it conforms to the skeletal mesh as it intersects with the sphere.

Any ideas how I could achieve this effect?



Thanks, as always!

The material editor has a node called depthfade that will give a gradient of the intersection of translucent geometry with opaque geometry.

Ahh, Ryan, you’re my hero! After just a little trial and error, I’ve got something that works very well. I’m always amazed how UE4 has great built in solutions for all my problems. :wink: Thank you so much!

b741ac437c9271a7880e397de3696bc4de516a3b.jpeg

No problem. One minor suggestion is that you can also use a second depthfade with a different fade distance but with inverted output (ie, just use another lerp but flip the 0 and 1), and multiply that by the first one, and then you will have a controllable gradient for the outer edge softness as well.

To get texture variation like the screenshot, you could use another lerp to vary the “FadeDistance” amount. the texture could use the UVs of the sphere or possibly worldcoord.XY or something depending on the look you want.

Hi Ryan, coming back to this after a few days and I’m not quite sure how I would use the UV’s of the sphere or the worldcoord.XY. Can you elaborate on these a bit?

1 Like

Worldcoords-XY is just way to tile a texture using worldcoords from top down. It would cause the noise pattern to stay constant in the world so if the sphere moves, you’d see different parts of the texture:

5314f2aa71330635cb5f9127a3ba4e36256108e1.jpeg
Could just as easily use default UVs for the noise texture (by just not connecting anything or using a texturecoordinate node with any tiling). I was just giving options.

Using second depthfade with sharper gradient for the outer edge:
f1d8d1fe30befac65080b946e94b60e3a1ec4acf.jpeg

Only have to do 1-x on the inner gradient.

Is there a way to have something similar but with two object with regular materials. Not translucent.