wolfwings: (Default)
[personal profile] wolfwings
Specifically, why premultiplied alpha is all you should use for shipping products which boils down to three basic facts:

Less math (dramatically in more complex cases like shadowing and imposter's) to combine premultiplied images for compositing. Especially for more advanced things like imposter's (render a far-away tree once to a texture, render the texture) and other tricks useful for ultra-high-poly and ultra-low-power situations.

Removed halos, it's equivalent to the GIF versus PNG situation when changing the background color, PNG's won't halo. Neither will premultiplied alpha images. This also results in better compression. Yes, better compression. You don't have to bother with stupidity like flood-filling your transparent areas with their edge-colours, transparent is black, things just work, fewer colors = better compression.

You don't need separate additive and lerp/alpha-blending modes in your system. Hell, you can discard the 'opaque' mode in many cases, since premultiplied alpha can do additive, normal alpha-blending, and opaque rendering all at once, with overlapping handled correctly. Why? Because premultiplied alpha is associative (which is also why it works so well for imposter's) so you can render see-through window A before B, or B before A, and get the same result. Note that again, rendering order mostly doesn't matter with premultiplied alpha.

(no subject)

Date: 2007-04-09 12:10 am (UTC)
From: [identity profile] lironess.livejournal.com
Yay! You are alive! Talk to me sometime!

Yes, we should!

Date: 2007-04-09 08:52 am (UTC)
From: [identity profile] wolfwings.livejournal.com
I've just been so busy dealing with getting a job in order, and it's sounded like life's been chaotic enough there, I wasn't keeping in touch very well. *hugs*

(no subject)

Date: 2007-04-09 01:02 am (UTC)
From: [identity profile] premchai21.livejournal.com

This would basically seem to come down to that what you want for arbitrary linear compositing is something like:

output.rgb = texel.rgb ⋅ as + output.rgb ⋅ ad

but you don't have five components, so instead you set:

texel′.rgb = texel.rgb ⋅ as
texel′.a = 1 − ad

and then you can do:

output.rgb = texel′.rgb + output.rgb ⋅ (1 − texel′.a)

which now reduces to the first equation.

Does that sound about right?

Almost...

Date: 2007-04-09 08:51 am (UTC)
From: [identity profile] wolfwings.livejournal.com

The use as a final 'publication format' for premultiplied alpha is that there is never a reason to have the texel get multiplied by it's own internal values at any time during final use, and in fact a large reason to avoid doing that because such situations tend to break down when (bi/tri/)linear filtering is applied to the texel sources. This is because you can no longer 'correct' for the internal values being affected by each other, as you no longer have exact control over all accessed values in any but the simplest of synthetic cases.

Most of the other 'bennies' are actually side-effects of the fact that it makes multiple passes associative, and that the only other commonly-used texturing mode (additive) can be duplicated with this modified blending mode, which allows for further optimization to suddenly be unlocked. Such as combining the diffuse and 'blend' texturing passes on light fixtures in a Q3 level, for a straight-forward example.

Style Credit