Hi People.Haven't visited for long time here ))

I asked the question also here: https://computergraphics.stackexchan...odes-and-alpha

Here is what I want to do. I need to create screen space mask for some rendered geometry,which is generated out of another geometry rendering results.

The easiest way I see (and it works):

1. Render mask geometry into FBO A.

2. Render masked geometry into FBO B.

3. Screen space pass, shader program with input samplers of mask texture from FBO A,and masked texture from FBO B.

4. Draw screen quad, use alpha inside the fragment shader of texture A ,to mask texture B.

All right? That's the easiest but also the slowest approach. Because in my case, every object first is rendering into MSAA FBO to fix AA.
So I have to render 2 times,then blit twice,and then render one more time in screen space to apply actual masking.

So I went to this page: https://www.andersriggelsen.dk/glblendfunc.php

played around with blending functions,and came to this:

glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE);
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_SUBTRACT);

My attemp of doing it with hardware blending is described here:

And it doesn't work. I wonder how can make this effect with less passes.