Here:
Straight Alphas vs. Premultiplied Alphas
To start, let's know one important thing: whether you're processing an image with Straight or Premultiplied alpha, in both cases
the alpha channel will look exactly the same. Confusingly, what's different between an image with straight alpha versus one with premultiplied alpha is what's happening in the RGB channels, not in the alpha channels!
Here is a blown-up image of a white sphere on a green background:
The edges are anti-aliased, which of course, makes the image look nice.
Here's the alpha channel for this render:
Makes sense so far. But here's a problem - watch what happens if I use the alpha channel on the image, to recomposite over a red background:
The green from the background is "trapped" in the anti-aliasing. This is called Premultiplying. The image is premultiplied with green.
Now, I used green to illustrate the point, but no matter what color is back there,
even just the standard black in a Maxwell render, it still pollutes the edges with its color. For the skeptics, I'll prove it - here's a standard Maxwell render of the sphere on black:
And here's what happens when you use its alpha channel to try and composite over red:
So even though there's nothing actually back there in the scene, the anti-aliased edges are still polluted with black, creating a dark halo around the object when composited.
Now, most compositing apps know how to subtract this premultiplied background color - you just tell them what color it is. You say, "here comes an image that's premultiplied with green," and it can pull it out.
But this only works if the original background color is absolutely uniform. So this will not work with a physical sky background, for example, or an HDR. The anti-aliased edges of objects set against physical sky will have a whole range of hues in them, so you can't pick a single value and remove the ring successfully. This is why many 3D apps use Straight Alphas. Here's how it works...
Remember I said the alpha channel was the same for both cases, so we start with the alpha channel render:
As I mentioned, the difference is in the RGB channels. A straight alpha image "oversprays" the edges
in the RGB channels, all the way to the anti-aliasing boundaries, making a fully aliased edge, like this:
That looks like ass, but when combined with the alpha, you get this:
A perfect composite, with nice anti-aliased edge, and no background color pollution. The overspraying ensures that the underlying alpha channel can cut through cleanly. Now it doesn't matter what image or color you put behind the sphere; it will always composite correctly.
Now, as you've noticed, the RGB image for the Straight Alpha looks like shit, with horrific aliasing. This would freak most people out, which is why most renderers
embed the alpha channel in the file, as RGBA, and not as a separate file. This way, when you open the images in After Effects or wherever, you already see it with the alpha applied, and never see the crappy aliasing edge. But if you were to extract the RGB channels, this is what it would look like. Here's a real-world example:
RGB channels:
Here I've temporarily disabled the alpha channel for this image, so we can see the raw, crappy RGB channels. Here's what the alpha channel looks like:
Put the two together and you get:
And because it's a straight alpha, I can use any background color or image, and get full gradients with no pollution:
Now, this is an unpleasant combination of colors, but you can see the composite working properly with no halos or fringes.
Now you know!
_Mike