PDA

View Full Version : Separate alphablend



Taicoon
10-21-2010, 08: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?

Alfonse Reinheart
10-21-2010, 11:02 AM
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.

It would be easier (read: possible) to reverse the meaning of alpha on your end. Instead of alpha meaning "% of light blocked," it should mean "% of light emitted."

This way, all you need to do is multiply the source alpha by the dest alpha. And that is easily done. When you need to use "% of light blocked," you can use 1 - alpha.

Taicoon
10-21-2010, 01:23 PM
I am sending my resulting rgba to a separate videocard (actual sdi video) and I do not know of a setting that will invert the alpha in hardware. This would then mean that I had to do it myself and fear it would be too involved to render my entire output to a texture, pass it to a shader and let it reverse the alpha.

Do you have any suggestions as to how I could otherwise accomplish this?

Taicoon
10-28-2010, 12:46 AM
I am closing this thread now. I will not be reading back in the near future.