Search code examples
colorsopengl-estexturesopengl-es-2.0opacity

Color is getting darker when using alpha channel / opacity


I draw to a texture with a fragment shader in opengl.
I set my color to 100% red and 50% opacity, but when i then read this color i discover that it is no longer 100% red.

The same can be noticed with gimp.
I choose 100% red color but draw it with 50% opacity, when i then use the color picker tool, it tells me the red color is only 80%.

Is there a way to preserve the color value in opengl es 2.0?


Solution

  • The color is modified by the Bending function and operation. You have to disable blending.

    There is no opacity, there is just an alpha channel. The alpha channel and the blend function define how a source color is mixed (blended) with the color in the target buffer. Hence if blending is enabled, then the final color is equal to the source color. If blending is disabled, the the color and the alpha channel are copied to the target without manipulation.