How to check which object shader writes to Stencil buffer first?

I just can’t get my shader example to work.

I use unlit shaders for all object types.

Idea is simple:

  1. First object, is closer to the camera then most, type of Sprite, it uses unlit Shader, which simply writes value 100 to stencil buffer based on texture alpha channel data.
  2. Second object is underneath the first object, uses unlit Shader, which instructs to pass stencil test if ref value is less then value in buffer.

Should work, but it doesn’t.

The Queue Tag might be what you’re looking for.