Taicoon

10-21-2010, 07:17 AM

I need my render result to contain valid alpha so I can later take my output and hang it in front of some other graphics and blend correctly.

An object with a=0.5 should output a=0.5, but two objects both with a=0.5 rendered in front of each other should result in a=0.75. First lets 50% of the light from the back through and the next lets 50% of the 50% (being 25%) through so a=0.75.

This gives a blend like

a = 1 - (1-src)*(1-dst) or in the example 1-0.5*0.5=0.75

.. but I do not see how I specify this blend. Using separate blending i have

glBlendFuncSeparate(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);

but how do I define that the results should be multiplied and then subtracted from one?

An object with a=0.5 should output a=0.5, but two objects both with a=0.5 rendered in front of each other should result in a=0.75. First lets 50% of the light from the back through and the next lets 50% of the 50% (being 25%) through so a=0.75.

This gives a blend like

a = 1 - (1-src)*(1-dst) or in the example 1-0.5*0.5=0.75

.. but I do not see how I specify this blend. Using separate blending i have

glBlendFuncSeparate(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);

but how do I define that the results should be multiplied and then subtracted from one?