- Home /
Multi-shader Stencil Buffer not working as expected,Multi-shader Stencil not working as expected
I have 2 shaders, the first running on the Transparent Queue, and the second on Transparent+100, meaning that it should always run after the first shader.
The first shader has 2 passes that interact with the Stencil Buffer, the first sets always the Buffer to 4, and the second only operates on pixels where the Buffer wasn't set, and doesn't change the Buffer on its own.
The second shader has 1 pass that is supposed to run on only pixels whose Buffers are equal to 4, meaning pixels that were hit by the first shader.
The thing is, it seems like the second shader has 0 set in the Buffer of every pixel. Even though the first shader is supposed to set into the Buffer.
Any ideas?
It looks like the issue was with the first pass of the first shader using the "discard" keyword in its fragment shader.
I guess that discard discards the Stencil buffer of the pixel and not just the current pixel's color evaluation.