Intersecting Geometry Shader

I’ve seen a couple threads with similar questions, but I haven’t been able to figure out the solutions they’ve presented.

I’ve been struggling to recreate a shader similar to the one used by the foliage painting tool, as seen here

…and present in The Division, shown here by the grenade highlight (orange highlights).

I am interested in the portion which highlights intersecting geometry.

I can create the core of the effect by rendering three spheres:
Two spheres with their front-faces culled and a third with backface culling. Then I do some depth testing with stencils to highlight all the intersecting geometry.

The problem I run into is how to accomplish the gradient fade (center is slightly less opaque, and opacity increases as it gets to the edge).

Is there a way I can view the source for Unreal’s shader, or has someone perhaps done this already?
It just feels like I could be doing this a different way which would allow for what I want.


Well after searching some more, and some trial and error, I made it work. Very similar to The Division.

Here it is, for everyone who happens to come by here.

Copy all the text and paste it into your material editor.

Hey, I’ve tried copy pasting it into the material editor in 4.19 and 4.18 as well as dragging in a saved .txt file on two separate computers and it isn’t working. Any ideas on what the problem could be? I have managed to do this before with a landscape material in a 4.16 project and it worked no problem.

Thanks a ton for this by the way I’ve been struggling with getting a similar material working with a desaturation for awhile now and this looks perfect!

Sorry for the late reply.
You’ll have to check on the object “Render CustomDepth” and in the material’s options select “Disable Depth Test”

Any chance you could post a screenshot of the material blueprint? The copy/paste text doesn’t seem to work.