I have an object translating and when it passes through another object(transparent), I would like for it to change color while intersecting. I am using a fresnel and it is giving me a partial desired effect. The problem is that it is highlighting at any point behind the object and not only at the intersection. Adjusting the lerp values is not working. How can I resolve this?
DepthFade might be able to do you what you’re looking for. Try plugging it into the Base Color and moving your object inside other objects to see how it interacts.
I’ve tried DepthFade and I cant seem to get it to work properly. One of the objects is transparent and when the other object is behind and not intersecting, it is still applying the change to the material. See attached images. thanks!
Lower the FadeDistance to something like 10, pass the output from the Depth Fade through a One Minus node to invert it, and then combine it with your fresnel. It also looks better if your material is two sided.
I have that working but I am looking to highlight all parts of the object that are intersecting. If I tweak the current values, the fade leaks out of the intersection area. The image below is showing what I have now and I want everything inside of the transparent box to have the highlight.
You could use customdepth, if you aren’t already.
It gives you the depth of the outside of the object where the effect begins, and you can use the pixeldepth of the inside of the object to say where the effect ends.
Unfortunately it wouldn’t work with objects overlapping in screenspace.