Translucent material can't read custom depth/stencil

Hi. My translucent material does not see the stencil buffer and I’d like to figure out why. I’ve reproduced the steps that other people have documented and am not getting the same results.

The screenshots below show that:

  • The custom stencil is being written
  • The post process sees stencil=4 where the cylinder is
  • The translucent material sees stencil=1 everywhere

The stencil buffer is being populated properly. A post process material successfully reads from the buffer. But the translucent surface material does not.

Settings:

  • Custom Depth-Stencil Pass: Enabled with Stencil

Cylinder mesh, which draws the stencil:

  • Render in Main Pass: OFF (also tried ON)
  • Render in Depth Pass: OFF (also tried ON)
  • Render in Custom Depth Pass: ON
  • CustomDepth Stencil Value: 4

Cone mesh, whose material reads the stencil:

  • Render in Custom Depth Pass: ON or OFF
  • CustomDepth Stencil Value: 0 OR 4

Cone material:

  • Surface, Transparent
  • Lit OR Unlit
  • Opacity Mask Clip Value: -1
  • Disable Depth Test: ON or OFF
  • Allow Custom Depth Writes: ON or OFF

The scene:

  • A cylinder writes 4 to the stencil
  • The cone behind it has a material which changes color/opacity based on stencil value

The stencil buffer view:

The material on the cone:

The cone at runtime:

A similar post-process material:

With the post-process material:

What are the most likely causes of this issue?

Thank you for any help. I’ve spent a whole day on this and am out of leads.

Bumping, I have this issue as well

1 Like