Material Scene Mask

I was wondering how I could achieve an object going through my scene to go invisible or blend with the background to make it not noticeable. I want this to happen only when there isn’t an actor between said object and background.

In other words, I would have 3 layers, background, middle-man and actor called bob. So I want bob to blend with the background when middle-man isn’t between bob and the background. And when middle-man is between bob and the background, then we can see bob.

I tried using scene2d capture but the problem is that my middle-man isn’t at a fixed location so I can’t pre-build a mesh to fill all the holes with a render to target material. I also though about using decal and just make my background not accept decals but it didn’t really give me the desired effect either. I don’t think I was using the decal properly anyway, but I figure there must be a simpler way.

If there was a way for middle-man to transmit a mask layer to bob so that that he is only rendered when in front of middle-man that would be ideal?

You can probably do this in the material editor. Make bob either transparent or project the uv’s in world space on bob and the background based on the view angle of middle-man compared to bob.

If you can’t figure it out, Make some drawings of what you want exactly.

I was looking at the math hall content example and thought maybe I could use a dot product of bob and middle and as it goes further from being near a middle it would pan a mask? I don’t know. Bob always moves in the same direction if that helps, but middle is not always at the same place

If I understand the video correctly you should be able to solve this using a custom depth mask for bob.

Here is a great tutorial by Tom Looman:

I’m not a hundred percent sure about what you want to accomplish, but you might be able to test the result of the mask that bob generates against the actual depth, and discard bobs pixels when the actual depth buffer is further away (background) using the opacity mask.