Publishers of technology books, eBooks, and videos for creative people

# Selections: The Key to Compositing

• Print
This chapter is from the book

## Blending Modes: The Real Deal

After Effects includes 34 blending modes, each created with a specific purpose ( Figure 3.22 )—although no one is quite sure in what context Dancing Dissolve was ever useful (and I'm only half joking). For effects work, moreover, the majority of them are not particularly recommended. In fact, traditional optical compositing would effectively include only two of them: Add and Multiply.

So that's it? Use these two or none at all? Not quite—I'll point out a few other useful modes as well. Once you understand how your options work, you can make informed compositing decisions, rather than lazily playing Go Fish by trying one mode after the other until you see something you kind of like.

Remember, blending modes are all based on mathematical operations for combining pixels in the layer containing the given blending mode and the pixels behind it—either below it in the stack, if all the layers are 2D, or positioned behind it in 3D space, if all the layers are 3D.

To help you understand what the various blending modes are doing, Figures 3.24 through 3.30 blend a grayscale gradient over a fully saturated background. Contextual examples using these blending modes follow in the next section.

Add and Screen modes both brighten the image. Screen typically yields a subtler effect than Add, which results in brighter values overall.

Add mode is every bit as simple as it sounds; the formula is

newPixel = A + B

where A is a pixel from the foreground layer and B is a background pixel (although they are obviously interchangeable in this formula). The result is clipped at 1 for 8- and 16-bit pixels (but can exceed 1 in 32 bpc mode); any pixels that add up to a value of more than 1 take the value of 1, full white.

In 32 bpc mode, this is likely to be your most commonly used blending mode. It generally brightens the overall image, but any black in the foreground acts transparent by adding a value of 0 to the background. It is useful for laying fire and explosion elements shot in negative space (against black) into a scene, adding noise or grain to an element, or any other element that is made up of light and texture ( Figures 3.31a , b , and c ).

Screen mode has an influence similar to Add mode's, but via a slightly different formula. The pixel values are inverted, multiplied together, and the result is inverted:

newPixel = 1–((1–A) * (1–B))

Note that with this formula, fully white pixels stay white, fully black pixels stay black, but a midrange pixel (0.5) takes on a brighter value (0.75), just not as bright as would be with Add (1).

You use Screen much like Add when working in 8 bpc and 16 bpc modes. Screen is most useful in situations where Add would blow out the highlights too much—glints, flares, glow passes, and so on ( Figure 3.32 ).

#### Multiply

Multiply is another mode that is as simple as it sounds; it uses the formula

newPixel = A * B

This would seem to make the values much higher until you recollect that we are calculating values between 0 and 1; when you multiply by a fraction, the result is lower than the source value. Multiplying two images together, therefore, actually has the effect of reducing midrange pixels and darkening an image overall, although pixels that are full white in both images remain full white.

In optical compositing (the crude method used to do this stuff photochemically before we had computers that could manage it) the equivalent of multiply was layering two images, one over the other, combining their densities such that the dark areas of each image held out light from the other. This process was known as bi-packing.

Multiply literally has the inverse effect of Screen mode, darkening the midrange values of one image with another. It is useful in cases where you wish to emphasize dark tones in the foreground without replacing the lighter tones in the background, for example to layer in texture, shadow, or dark fog ( Figure 3.33 ).

#### Overlay and the Light Modes

Overlay uses the bottom layer to determine whether to screen or multiply. Above a threshold of 50% gray (or .5 in normalized terms), it is screened. Below 50%, it is multiplied. Hard Light operates similarly, instead using the top layer to determine whether to screen or multiply, so the two are inverse effects. Reversing layer order and swapping Overlay for Hard Light yields an identical result.

These modes, along with Linear and Vivid Light, can be most useful for combining a layer that is predominantly color with another layer that is predominantly luminance, or contrast detail ( Figure 3.34 ). This is how you create textures; for example, some of the lava texturing in the Level 4 sequence of Spy Kids 3–D was created by using Hard Light to combine a hand-painted color heat map with moving fractal noise patterns.

This type of usage is fine in 8 bpc or 16 bpc projects, but try to avoid fishing in the various Light modes when combining more detailed and specific elements. These methods don't work properly with 32 bpc overbright levels (explored in Chapter 11), and this method of adjusting images is a warning sign that you haven't thought things through in terms of what you're trying to do.

#### Difference

Difference is a subtraction mode that inverts a pixel in the background according to how bright the foreground pixel is. There is one very specific use for Difference that has nothing to do with creating a blended look: You can line up two identical layers using this mode. When all of the pixels line up properly, layer details disappear ( Figure 3.35 ).

#### HSB and Color Modes

The Hue, Saturation, and Brightness modes each combine the given value from the foreground layer with the other two from the background layer. Saturation applies the foreground saturation to the background hue and luminance values, Hue combines the foreground hue with the background saturation and luminance, and Brightness uses the foreground luminance in combination with the hue and saturation of the background.

Color takes both the hue and saturation of the top layer, using only the luminance from the underlying background ( Figure 3.36 ).

Keep these modes in mind as shortcuts to channel operations in which you might want the color from a foreground combined with the detail (luminance) of the existing background.

#### Stencil and Silhouette

The Stencil and Silhouette blending modes apply transparency information to all of the layers below them in the composition. The Stencil modes use the light pixels, and Silhouette the dark pixels, of either the Alpha or Luminance values to determine the areas that remain visible in the layers below the current layer. You can keep these in mind for occasions in which they save you extra setup work.

#### Alpha Add and Luminescent Premultiply

Alpha Add and Luminescent Premultiply are special-case blending modes that affect semi-transparent edge pixels only.

Have you ever tried matting a layer with an alpha channel over the same layer with the alpha channel inverted? Figures 3.37a through d show the typical result: a semi-opaque line tracing the edge of the alpha, where the pixels remain semi-transparent because they are blended together in the same manner as semi-opaque layers. Alpha Add adds the actual values of the alpha pixels without compensating for the opacity effect, so two 50% opaque pixels become 100% opaque.

Why would you combine a layer with itself, inverting the alpha? You probably wouldn't. But you might combine two layers with overlapping transparency that would require this method—for example, two parts of the same layer.

Luminescent Premultiply is an alternative method of removing premultiplication from source footage, retaining bright values that would otherwise be clipped. Premultiplication over black causes all semi-transparent pixels to become darker; removing the black values while adding transparency, which is what removing premultiplication does, can cause them to appear dimmer than they should. This is useful for bright overlaid elements that come in with alpha channels and premultiplication, such as flares and explosions; you can set the footage to interpret as Straight on import and use this mode instead of Normal to overlay the element. It's another trick to keep in your arsenal should you ever see the symptoms (dim translucent elements) for which it is recommended.