How can I create an Intersection Material?

Hello all,

I’m trying to create a boolean intersection material. Where only the area intersecting two meshes is rendered. Kinda like the 3D modeling operation.

I have very limited capacity when it comes to shaders and materials but with the help from another forum I was able to put something like this together:

The problem here is that I’m using a sphere mask and it doesn’t translate to the cross-sections of other meshes like the hexagon here. Is there a way to achieve rendering only the cross-section in the interacting plane?

My graph:


Thanks for any help!

Distance fields would probably be the way to go. Unreal can generate them, and in fact relies on them for things like lumen. They can be sampled in the material to detect overlapping objects.

You can also generate distance fields mathematically.