Figured out in UE5, the solution there is to just turn off the “Render in Depth Pass” box, and keep the “Render CustomDepth Pass” selected. Then the object will only render as a mask to the custom depth as a stencil. Caveat is that it needs custom stencils activated.
4 Likes