<blockquote>
<p>BUT the alpha component will be 0.3×0.3 + 0×(1 - 0.3) = 0.3, so we then have a color of (0.3, 0, 0, 0.09) which is not correct, what we want to see on the screen is rather (0.3, 0, 0, 1).</p>
</blockquote>
<p>Your blending function did not use the destination alpha. So &quot;correct&quot; or &quot;not correct&quot;, its value is entirely <em>irrelevant</em>.</p>
<p>However, if you want to make the alpha more accurate in some way, you can provide a <a href="https://www.khronos.org/opengl/wiki/Blending#Blending_Parameters" rel="nofollow noreferrer">different set of blending factors</a>, and even a <a href="https://www.khronos.org/opengl/wiki/Blending#Blend_Equations" rel="nofollow noreferrer">different blend equation</a>, for the alpha component.</p>

CC BY-SA 4.0
2021-03-17T15:08:15.953Z
2021-03-17T15:08:15.953Z
Nicol Bolas
<p>I don't understand how OpenGL performs the blending of a texture on the screen. By default, the clear color is set to (0, 0, 0, 0). If we use the default blending equation GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA, it means that if our texture is all (1, 0, 0, 0.3), the resulting RGB will be (1, 0, 0)×0.3 + (0, 0, 0)×0.7 = (0.3, 0, 0) BUT the alpha component will be 0.3×0.3 + 0×(1 - 0.3) = 0.3, so we then have a color of (0.3, 0, 0, 0.09) which is not correct, what we want to see on the screen is rather (0.3, 0, 0, 1).</p>
<p>So how does OpenGL manages the final blending with the framebuffer? Does it drop the alpha component (because the screen can only display RGB colors)?</p>

CC BY-SA 4.0
2021-03-17T15:03:37.070Z
"*performs the blending of a texture on the screen.*" It doesn't. *Fragments* are blended with the screen. What that fragment data is is up to you and your fragment shader. It *can be* just a value fetched from a texture, but it doesn't have to be.
Nicol Bolas
CC BY-SA 4.0
2021-04-20T13:33:45.073Z
Here is a link to a basic introduction to the topic if you want to learn more about alpha blending in OpenGL specifically: https://learnopengl.com/Advanced-OpenGL/Blending . And I am sure everyone in the community will be happy that I will not give one of my long winded explanations that just goes on and on....
pmw1234
<opengl><blending><alpha>
OpenGL blending with the screen
Voko
# OpenGL blending with the screen

(Asked by: username_0 on 2021-03-17)

I don't understand how OpenGL performs the blending of a texture on the screen. By default, the clear color is set to (0, 0, 0, 0). If we use the default blending equation GL\_SRC\_ALPHA and GL\_ONE\_MINUS\_SRC\_ALPHA, it means that if our texture is all (1, 0, 0, 0.3), the resulting RGB will be (1, 0, 0)×0.3 + (0, 0, 0)×0.7 = (0.3, 0, 0) BUT the alpha component will be 0.3×0.3 + 0×(1 - 0.3) = 0.3, so we then have a color of (0.3, 0, 0, 0.09) which is not correct, what we want to see on the screen is rather (0.3, 0, 0, 1).

So how does OpenGL manages the final blending with the framebuffer? Does it drop the alpha component (because the screen can only display RGB colors)?

**Tags:** opengl, blending, alpha

> **Comments:**
> **username_1**: "*performs the blending of a texture on the screen.*" It doesn't. *Fragments* are blended with the screen. What that fragment data is is up to you and your fragment shader. It *can be* just a value fetched from a texture, but it doesn't have to be.  
> **username_2**: Here is a link to a basic introduction to the topic if you want to learn more about alpha blending in OpenGL specifically: https://learnopengl.com/Advanced-OpenGL/Blending . And I am sure everyone in the community will be happy that I will not give one of my long winded explanations that just goes on and on....  

---

## 1 answers

### Answer by username_1 on 2021-03-17. Score: 1

> BUT the alpha component will be 0.3×0.3 + 0×(1 - 0.3) = 0.3, so we then have a color of (0.3, 0, 0, 0.09) which is not correct, what we want to see on the screen is rather (0.3, 0, 0, 1).

Your blending function did not use the destination alpha. So "correct" or "not correct", its value is entirely *irrelevant*.

However, if you want to make the alpha more accurate in some way, you can provide a [different set of blending factors](https://www.khronos.org/opengl/wiki/Blending#Blending_Parameters), and even a [different blend equation](https://www.khronos.org/opengl/wiki/Blending#Blend_Equations), for the alpha component.


---

