But it isnt the correct value, I get a gray out of this. I wanted a half-transparent white.
There’s no such thing as “half-transparent white”. Colors don’t come with a transparency value.
If you have a non-premultiplied RGBA vector of (1, 1, 1, 0.5), the actual color of this is (0.5, 0.5, 0.5). That is, this is what you would see.
Similarly, while your blend function for “(1, 1, 1, .5) over (1, 0, 0, .5)” gives you “(1, .67, .67, .75)” back, the actual color is (1, 0.5, 0.5). Which is what you get if you do a straight linear interpolation between the source and destination based on the source alpha.
The reason OpenGL doesn’t support what you’re trying to do in it’s blending stage is because OpenGL is designed primarily for rendering colors. Not for rendering transparency. The way you normally deal with transparency is as follows.
First, you clear the screen. Then you render everything that is opaque. After that, you render all transparent objects in order from farthest from the camera to nearest.
Therefore, the destination color in a blending operation, the “under” as you keep calling it, will refer to either the background color (the one you cleared the screen to), an opaque color, or the composite between the background or opaque opaque colors and some number of previously-rendered transparent colors.
The destination alpha doesn’t mean anything. It doesn’t get factored into the blend equation. This is why a linear interpolation based on the source (“over”) alpha works.
If the destination color is the background color, then it’s effectively the same as if its opaque. There’s nothing “behind” the background to see, so there’s no value there to have blended with.
If the destination color is an opaque color, then the original alpha for this rendering was 1.0. So the “under.a” is 1.0, which doesn’t affect the equation. Linear interpolation gets you a proper color.
If the destination was a composite of an opaque/background color and some number of layered colors, it still doesn’t matter. Because the composite of all of these layers is still fully opaque, and therefore has an effective alpha of 1.0.
To put it another way, you don’t blend two transparent objects together. You’re always blending a transparent object with an opaque object.