Summary: static meshes that should render to the CustomDepth and CustomStencil buffers fail to do so when they are occluded by other meshes. This ONLY occurs when said functionality is enabled from script rather than on the Static Mesh Component itself.
Apologies if this was already submitted but I couldn’t find anything. I ran into this when upgrading my game from 4.15 → 4.17.
Here’s a fresh sample project [(link)][2] with a 100% repro (20/20 attempts).
Steps:
- Place a cube static mesh and make it
a Blueprint with the following nodes:
- Add a post process material that
simply visualizes the CustomStencil
buffer. - Run the game from the default camera
position. The cube SHOULD appear as a
white box onscreen because of the
post process material, visible
through the occluding wall mesh, but it
doesn’t. If you strafe the camera around the wall
so that the cube isn’t occluded
anymore, it will suddenly be
visualized by the postprocess. - Now go to the cube’s static mesh
component and set “Render CustomDepth
Pass”=True and set “CustomDepth
Stencil Value”=1. Result: the cube
will always appear in the postprocess, regardless of whether
the mesh itself is occluded, as desired.
My game has a lot of meshes that are visualized through walls using the CustomStencil feature after certain scripted conditions are met, but unfortunately this bug totally breaks that functionality. It seems like I can work around it by turning on custom depth on all my meshes, turning it off in script, and then turning it back on again when I need it enabled, but that’s a pretty awkward workaround for the dozens of blueprints I need to do it for. Help would be appreciated, thanks!