Object intersection material change?

I am looking for the best method to visually show two objects intersecting. Object 1 would be a static semi -transparent object and Object 2 would be a moving projectile that would go through Object 1 s they intersect.I would like to change the material to show where the intersection takes place. Think Boolean in a 3D application but we would have multiple objects hitting the target and represented by a color.

I am also considering creating an outline where the two initially intersect similar to a toon outline in Maya.

Any advice would be appreciated.

If Im understanding this right, you might want to look into the depth fade node. If something is rendering as translucent you can use that node in the material to create an intersection effect. It’s used for water quite a bit.

This might work. Thanks.

Any idea how to get this to function with a translucent material on the second object? It doesn’t seem to recognize the object if it has transparency.

I have the depth node applied to the sphere. the cube on the left has an opaque material and the cube on the left has a transparent material. I want the sphere to show the different color and and outline with the transparent object on the left.

The Depth Fade node does not like opacity below 1. I considered duplicating the transparent cube, adding a different material and making it invisible at run time but that is not working either.

Any ideas?

Thanks

Translucency doesn’t draw to Scene Depth IIRC, which is where DepthFade get’s it’s values from, so you can’t use it like that.

An invisible material won’t draw the Scene Depth either, so not sure about a workaround for this one…

Making a little progress but now I need to mask out the objects outside of the static mesh.

If you look at the picture, the material is working as desired when the objects collide. The problem is when there is another object close to the cube, it is being impacted as well. Is there a way to mask anything that is outside of the cube mesh?

I basically want to use an object to mask a material