I am rendering to all the texels of a texture using a quad and I am rendering many instances(like 1000) of this quad to the same texture.
Every instance I render I will increase the alpha of each texel by 1(somethimes it will not, it depends on a operation inside the pixel shader), I want to stop rendering to a texel when the alpha value of this texel reaches a number.
I can't read the alpha value when rendering in this way to a texture, so I thought of moving the counter to a stencil buffer but I cant think of a way to configure the stencil so that it stops rendering to a texel when the stencil value of it reaches a number, lets say 255(that's the maximum number)
Can someone help me, is this possible?