I'm using OpenGL ES 3. I want to draw transparent images. Some pixels of the image may have transparency from 0% to 100%. I also want to be able to set an argb value to change the whole image's color and transparency.
I have ended up with the following solution.
Rendering:
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);
GL.Uniform4(shader.UniformColor, color);
GL.BindTexture(TextureTarget.Texture2D, sprite.TextureId);
...
Fragment Shader:
void main()
{
fragColor = texture(text, textureCoordinate) * color;
}
The Problem is now that when i set a transparent color, the blending is done wrong, and the image gets brighter. It doesn't seem to be blended with the background correctly. When I use BlendingFactorSrc.SrcAlpha the transparency is right but there is a dark border around the image.
Does anyone have a solution to this problem? I have researched a lot and the solution for the dark border was to use the blending source factor one. But as decribed above i get another problem with that.
Thanks for your help!
Edit: Here's an illustration of the problem: https://i.stack.imgur.com/LAw3K.png