I am having some trouble understanding how openGL blend modes work. At first I was using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and it all looked fine except that I couldn't use any additive glowing effects simultaneously without changing blend modes all the time. So I was advised to use
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) and textures with premultiplied alpha and now both additive and "normal" textures appear fine except that for some reason some textures have slightly jagged/thick outlines. I found that this only happens to images that have semi-transparent pixels but I'm not sure why.

This is an example of anti-aliased text with this kind of outline. The first is how it used to look and how I want it to look and the second is how it looks with the mode I'm trying to use. I don't want its color blended with the background. Is what I'm asking possible?

jagged edges


1 Answer 1


You are now using blending factors which assume pre-multiplied alpha (usually a good idea), but some of the textures don't have pre-multiplied alpha. You can either:

  1. Persuade your image editor to multiply your colour channels by the alpha channel (it may then not display properly in the editor), or otherwise pre-process your image files to the same effect.

  2. Multiply the colour channels by the alpha channel when you load the image.

  3. Multiply the colour channels by the alpha channel in the fragment shader.

  4. Switch to your old blending factors when using those textures

  • \$\begingroup\$ Cool that was it! I thought my image was premultiplied but it wasnt... I ended up with option #2. If anyone else wanders an easy way to premultiply an image's alpha in java is to use: bufferedimage.coerceData(true); \$\endgroup\$
    – user40079
    Commented May 7, 2014 at 22:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .