how to get complete custom depth stencil mask?

Hi, I’m trying to do some stylized rendering and learning to custom depth.

I want to get the mask of each custom stencil depth.

I found when all the objects have the render customDepth pass enabled, it seems that the occluded pixel selection will still be obtained in the Scene Texture.

If the render customDepth pass of the object in front is not enabled, the complete pixel selection of the object behind can be obtained. However, if the render customDepth pass of the object in front is enabled, occlusion will occur.

If I have multiple objects and all of these objects have render customDepth pass and custom depth stencil enabled, how can I get the pixel selection of their respective customDepth stencil mask?

Hi @iZerat,

I ran into the same issue a couple of months ago, so I knew there was a workaround.

This is a fantastic article that goes into great detail on how to fix this issue. Just note that the occluded area will be the sum of both stencil values, so you will have to search for that value separately.