CHAPTER ELEVEN: Rendering Passes and Compositing 345
Compositing With Premultiplied Alpha Channels
Compositing with premultiplied alpha channels is generally faster and sim-
pler than working with images that have not been premultiplied. Multiplica-
tion with the alpha channel is a part of the arithmetic used when layers are
composited together, so some compositors premultiply all elements in order
to save compositing time.
In Shake, an Over node works perfectly for putting together layers with pre-
multiplied alpha channels. Adobe Photoshop doesn’t expect alpha channels
to be premultiplied, but if you use a premultiplied alpha channel to delete
the background from a layer, the function Matting > Remove Black Matte
will perfect the key according to the premultiplied alpha channel.
If you render premultiplied layers, you can always switch them to un-
premultiplied and back in a compositing program. Figure 11.8 shows the
MDiv (matte divide, as in un-premultiply) and MMult (premultiply) nodes
in Shake. You don’t need to use these often. They would be useful, however,
if you encountered a color correction operation that didn’t look consistent
in half-transparent edge pixels around a layer. If some combination of exten-
sive color correction operations left you with visible fringes around the edges
of a premultiplied layer, you could fi x this problem by un-premultiplying
before the color correction and premultiplying again after it, as shown on
the right side of Figure 11.8.
[Figure 11.8]
When needed, you can un-
premultiply an image prior
to color correction, and pre-
multiply it again afterward.
346 Digital Lighting and Rendering
If you are rendering 3D graphics and passing layers off to someone else
for compositing, you will sometimes encounter compositors who are more
used to working with straight alphas than premult. Warning signs that your
compositor is unfamiliar with premultiplied graphics will come if you hear
a comment such as, “Your mattes were a little off, but we fi xed them” (this
means they may have pushed the edges in by a pixel or two, which would
not really fi x a problem and could badly degrade motion blurred frames) or
“Could you possibly render this over a different color than black?” (which
means that they are having problems separating the image from the back-
ground, being unaccustomed to premultiplied alpha channels).
A good test to make sure that your alpha channel compositing is working
awlessly is to render a scene of a white object in a white environment, as
shown in Figure 11.9. If you render the foreground object against a black
background as one layer, and render the environment as another layer, you
should be able to composite the two together seamlessly, without any dark-
ness creeping into the edge pixels around the foreground object.
[Figure 11.9]
Check to avoid black matte
lines in a composite, even
between two white objects.
If you aren’t sure how to get a particular compositing program to work with
premultiplied alpha channels, there is a fallback solution that will work in
any application. Instead of using the alpha channel to layer your foreground
over the background, use the alpha channel to cut a black hole in the back-
ground, as shown in Figure 11.10.
With the black hole cut in the background, you can then add your fore-
ground as the layer on top. Figure 11.11 shows how a simple “add” operation
(or “linear dodge” in Photoshop), without using any matte or mask, will put
your foreground over the background without any dark fringes or matting

Get Digital Lighting & Rendering, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.