I want to use Alpha Blending (SRC_ALPHA, ONE_MINUS_SRC_ALPHA), which basically is this:
frag_out.aaaa * frag.out + ((1.0, 1.0, 1.0, 1.0) - frag_out.aaaa) * pixel_color
Let's say the pixel color already on screen is (1.0, 1.0, 1.0, 1.0)
The color I am currently rendering is (1.0, 1.0, 1.0, 0.4)
When I render this the resulting color on screen has an alpha 0.76 (even though it was fully opaque BEFORE)
Indeed:
(0.4, 0.4, 0.4, 0.4) * (1.0, 1.0, 1.0, 0.4) + (0.6, 0.6, 0.6, 0.6) * (1.0, 1.0, 1.0, 1.0) = (1.0, 1.0, 1.0, 0.76)
So basically the color on the screen was opaque (white) and after I put a transparent sprite on top the screen become transparent (0.76 alpha) and I am able to look through the background. It would be perfect if I could blend it like this:
(0.4, 0.4, 0.4, 1.0) * (1.0, 1.0, 1.0, 0.4) + (0.6, 0.6, 0.6, 0.6) * (1.0, 1.0, 1.0, 1.0) = (1.0, 1.0, 1.0, 1.0)
Is it possible to achieve this? If yes, how?