I have an image and a rectangle on the screen, using the using this stencil functions I managed to render or not render a certain part of my image.
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); glStencilFunc( GL_ALWAYS, 1, 0xFF ); graphics.render(texture, changeMaterial); glStencilFunc( GL_EQUAL, 0, 0xFF ); glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); graphics.render(rectangle);
I want my image to change color based on stencil. Is there a way for me to detect if a pixel is on the stencil so that I can color it to something else.
Here is an example, red one updates the stencil buffer to 1 and when some part of the cyan drawn to those places in the stencil buffer it changes color. Is there a way for me to change the color of those colliding pixels in the shader?