Hi everyone. I’ve been racking my head trying to figure this out. Basically what I’m looking for is to have a camera render only one layer of objects, just like changing the culling mask on a camera, however I also need the object to be occluded by objects in other layers.
Here’s an example of what I mean:
I’ve got a scene with a Sphere and a cube. The sphere is in front of the cube, partially occluding it. Like so:
I managed to achieve that result by using a shader that uses a render texture of only the sphere as a mask for a second render texture of only the cube. However the issue is that if the occluding object (in this case the sphere) moves behind the object, you get the following:
Which is the same result you would get if the sphere were in front of the cube. When instead I’d want it to look like this:
Since the cube is covering the sphere, the cube is “in front” and is therefore “complete”, as opposed to having the sphere in front of the cube in which case the cube is missing a “sphere sized chunk”.
I know this is probably an obscure question but if anyone has any ideas on how I could achieve this, I would love to hear it!
Thanks in advance for any help you can provide.
PS: I’m using the URP. The ultimate goal is to pixelate the “special” masked layer while leaving all other objects rendering at full resolution.