2
\$\begingroup\$

I am writing some alpha-blending code, and I realized that premultiplied alpha is enough for most cases.

So I thought about using only premultiplied alpha on my engine code to simplify the structure. Anyway premultiplication itself drops color information on low-alpha pixels, so it can be problematic if I need some kind of serious composition.

But in games, I can't figure out when I need that composition which needs straight alpha. Do you have have case we need straight alpha in trivial(?) game graphics?

\$\endgroup\$
3
\$\begingroup\$

Using premultiplied alpha everywhere is a fine choice for composition. It allows you to include both additive and alpha-blended elements, as well as anything in between, and you can composite premultiplied-alpha images together using GPU hardware blend modes. In cases where alpha has the usual interpretation (opacity) I'm not aware of any reason not to use premultiplied alpha.

You would not, of course, use premultiplied alpha if the alpha channel represents something completely different, e.g. specular power packed in with the color or normal to save a texture lookup or something along those lines.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.