I clear a framebuffer...
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
...I enable blending as such...
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
[self render]
glDisable(GL_BLEND);
In that render code, I simply add a quad and draw it. In my fragment shader I have...
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
This yields a clear quad. Great. No color, no alpha, no nothing...got it. However, I change the fragment shader to...
gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
I get the quad filled with white. Can someone explain to me how filling a quad with fully transparent red would yield opaque white, and not just clear?
GL_ONE
as the first argument toglBlendFunc()
. So you add the fragment color to the destination value, independent of the alpha value. – Reto Koradi