# Premultiplied alpha, yea or nay?

Should I be using premultiplied alpha? Reading Tom Forsyth's article it seems a nobrainer. Premultiplied alpha (AKA additive blending) is superior in every sense.
However, premultiplied alpha seems to have one major drawback, it's not well supported with tools.

Do you/have you used premultiplied alpha?

How is the tool support?

In particular, I don't think gimp will edit premultiplied alpha images well. Are there any gimp plugins to export premultiplied alpha? How about an external tool?

• I'm in exactly the same position as you - I want to use it everywhere, but am not sure how easily I can edit my assets with it if I need to develop some extra tooling for it. – Kylotan Aug 27 '10 at 10:39

I use XNA 3.1 at the moment with premultiplied alpha (native Premultiplied Alpha support was added in 4.0).

Mostly it saves me time going through and making sure the transparent areas of my images have the correct colours. I also port to Silverlight, which does premultiplication by default.

XNA has a content pipeline which makes adding premultplied alpha preprocessing super-easy.

That link contains the code for doing the conversion. For every pixel:

c.R = (byte)(c.R * c.A / 255);
c.G = (byte)(c.G * c.A / 255);
c.B = (byte)(c.B * c.A / 255);


There is a lot to be said for having a content pipeline. If you're not using XNA, but are using Visual Studio, then you could throw together one yourself. Any other IDEs/build processes should also be capable.

And finally, if you don't have a content processing step in your build (and so odds are you don't have a lot of content anyway), you could just as easily perform the premultiplication at runtime when you load your textures. It will add some constant factor to your texture load time.

(If the implication wasn't clear: you probably shouldn't be editing premultiplied alpha images. Export them premultiplied if you can, or better yet preprocess them.)

• Thanks. It shoulds like premultiplied alpha is well enough supported in XNA (or soon will be). I'm still looking for non-XNA tools to create my pipeline with. – deft_code Aug 27 '10 at 5:15

If you happen to be using XNA, there's quite a bit of support for pre-multiplied alpha. Usually the conversion is done in the content pipeline, but there's nothing stopping you from doing it yourself.

I use premultiplied alpha by default in my engine (the artist can force non-premultiplied in the material definition file, if it's needed for a special effect of some sort)

Tools, as you've noticed, do not deal well with premultiplied alpha - the artist can set the color and alpha channels totally independently. I've set things up so my artist can create the texture images with non-premul alpha (which seems to be easier on artist brains), and the tool that converts to the engine's texture format multiplies the alpha by default. There's a switch so non-premultiplied can be generated if it's absolutely needed.