I have geometry that have attached some "ID" data. I have generated stencil buffer, that holds these IDs. Now, in second pass, I render different geometry, but this time I need to mask it with already existing stencil. Each part of geometry can have different "ID". Is there a way, how to control stencil buffer test value from shader?
I give an example:
- render geometry with ID = 1, writes 1 to stencil
- render geometry with ID = 2 if ID in stencil != 1, writes 2 to stencil
- do some other rendering with stencil turn off
- render bunch of particles at one go, but some of them have ID 1, some of them ID 2 -> I want to mask them, so 1 is rendered only if 1 is in stencil and 2 only if 2 is in stencil
I need this for OpenGL ES 2.0