How to Optimize Projects in Adobe After Effects CS5
- Build a system that even a fool can use and only a fool will want to use it.
- —George Bernard Shaw
Sometimes you take the attitude of a master chef—you know what can be prepped and considered "done" before the guests are in the restaurant and it's time to assemble the pièce de résistance. At other times, you're more like a programmer, isolating and debugging elements of a project, even creating controlled tests to figure out how things are working. This chapter helps you both artistically and technically (as if it's possible to separate the two).
- understand how to use multiple compositions
- know when to precomp (and when it's safe to avoid it)
- know how to optimize rendering time
you may find the After Effects experience closer to what you might consider "real time." This type of efficient rendering depends not only on optimized software and a speedy workstation, but on well-organized compositions and the ability to plan for bottlenecks and other complications.
Nested Comps, Multiple Projects
It's easy to lose track of stuff when projects get complicated. This section demonstrates
- how and why to work with some kind of project template
- how to keep a complex, multiple-composition pipeline organized
- shortcuts to help maintain orientation within the project as a whole
These tips are especially useful if you're someone who understands compositing but sometimes finds After Effects disorienting.
Precomping and Composition Nesting
Precomping is often regarded as the major downside of working in After Effects, because vital information is hidden from the current comp's timeline in a nested comp. Artists may sometimes let a composition become unwieldy, with dozens of layers, rather than bite the bullet and send a set of those layers into a precomp. Yet precomping is both an effective way to organize the timeline and a key to problem solving and optimization in After Effects.
Typically, precomping is done by selecting the layers of a composition that can sensibly be grouped together, and choosing Precompose from the Layer menu (keyboard shortcut Ctrl+Shift+C/Cmd+Shift+C). Two options appear (the second option grayed out if multiple layers have been selected): to leave attributes (effects, transforms, masks, paint, blending modes) in place or transfer them into the new composition.
Precomping prevents a composition from containing too many layers to manage in one timeline, but it also lets you do the following:
- Reuse a set of elements and manage them from one place.
- Fix render order problems. For example, masks are always applied before effects in a given layer, but a precomp can contain an effect so that the mask in the master comp follows that effect in the render order.
- Organize a project by grouping elements that are interrelated.
- Specify an element or set of layers as completed (and even pre-render them, as discussed later in this chapter).
Many After Effects artists are already comfortable with the idea of precomping but miss that last point. As you read through this, think about the advantages of considering an element finished, even if only for the time being.
The Project Panel: Think of It as a File System
How do you like to keep your system organized—tidy folders for everything or files strewn across the desktop? Personally, I'm always happiest with a project that is well organized, even if I'm the only one likely ever to work on it. When sharing with others, however, good organization becomes essential. The Project panel mirrors your file system (whether it's Explorer or Finder), and keeping it well organized and tidy can clarify your thought process regarding the project itself.
I know, I know, eat your vegetables, clean your room.
Figure 4.1 shows a couple of typical project templates containing multiple compositions to create one final shot, although these could certainly be adapted for a group of similar shots or a sequence. When you need to return to a project over the course of days or weeks, this level of organization can be a lifesaver.
Figure 4.1 A complex project such as a shot for a feature film might be generically organized (left) to include numbering that reflects pipeline order and multiple output comps with no actual edits, just the necessary settings. At minimum (right), you should have Source and Precomps folders, as well as a Reference folder, to keep things tidy.
Here are some ideas to help you create your own comp template:
- Create folders, such as Source, Precomps, and Reference, to group specific types of elements.
- Use numbering to reflect comp and sequence order so that it's easy to see the order in the Project panel.
- Create a unique Final Output comp that has the format and length of the final shot, particularly if the format is at all different from what you're using for work (because it's scaled, cropped, or uses a different frame rate or color profile).
Use guide layers and comments as needed to help artists set up the comp (Figure 4.2).
Figure 4.2 Here is a series of non-rendering guide layers to define action areas and color.
- Organize Source folders for all footage, broken down as is most logical for your project.
- Place each source footage clip into a precomp. Why? Unexpected changes to source footage—where it is replaced for some reason—are easier to handle without causing some sort of train wreck.
The basic organization of master comp, source comp, and render comp seems useful on a shot of just about any complexity, but the template can include a lot more than that: custom expressions, camera rigs, color management settings, and recurring effects setups.
Manage Multiple Comps from the Timeline
Ever had that "where am I?" feeling when working with a series of nested comps? That's where Mini-Flowchart, or Miniflow, comes in. Access it via in the Timeline panel, or simply press the Shift key with the Timeline panel forward to enable it.
Miniflow shows only the nearest neighbor comps (Figure 4.3), but click on the flow arrows at either end and you navigate up or down one level in the hierarchy. Click on any arrows or items in between the ends and that level is brought forward. You're even free to close compositions as you're done editing them (Ctrl+Alt+W/Cmd+Opt+W) and reopen only the ones you need using this feature.
Figure 4.3 Mini-Flowchart view is a navigable pop-up showing dependent comps above and below (right and left of) the current comp in the hierarchy.
What about cases where you'd like to work in the Timeline panel of a subcomp while seeing the result in the master comp? The Lock icon at the upper left of the Composition viewer lets you keep that Composition viewer forward while you open another composition's Timeline panel and close its view panel. Lock the master comp and double-click a nested comp to open its Timeline panel; as you make adjustments, they show up in the master comp.
Ctrl+Alt+Shift+N (Cmd+Opt+Shift+N) creates two Composition viewers side by side, and locks one of them, for any artist with ample screen real estate who wants the best of both worlds.
To locate a comp in the Project panel, you can
- select an item in the Project panel; adjacent to its name by the thumbnail at the top of the panel is a small pull-down caret, along with the number of times, if any, the item is used in a comp (Figure 4.4)
Figure 4.4 Click the caret next to the total number of times an item is used to see a list of where it is used.
- context-click an item in the Project panel and choose Reveal in Composition; choose a composition and that comp is opened with the item selected (Figure 4.5)
Figure 4.5 Context-click any item, and under Reveal in Composition, choose from a list, if applicable; that timeline opens with the item selected.
- context-click a layer in the timeline and choose Reveal Layer Source in Project to highlight the item in the Project panel (Figure 4.6)
Figure 4.6 Context-click any footage item in the timeline and you can choose to reveal it either in the Project panel or in Flowchart view.
- context-click in the empty area of a timeline—and choose Reveal Composition in Project to highlight the comp in the Project panel (Figure 4.7)
Figure 4.7 Find the empty area below the layers in the timeline and context-click; you can reveal the current comp in the Project panel.
- type the name of the comp in the Project panel search field
Ways to Break the Pipeline
Precomping solves problems, but it can also create more problems—or at least inconveniences. Here are a few ways that render order can go wrong:
- Some but not all properties are to be precomped, others must stay in the master comp? With precomping it's all-or-nothing, leaving you to rearrange properties manually.
- Changed your mind? Restoring precomped layers to the master composition is a manual (and thus error-prone) process, due to the difficulty of maintaining proper dependencies between the two (for example, if the nested comp has also been scaled, rotated, and retimed).
- Do the layers being precomped include blending modes or 3D layers, cameras, or lights? Their behavior changes depending on the Collapse Transformations setting (detailed below).
- Is there motion blur, frame blending, or vector artwork in the subcomp? Switches in the master composition affect their behavior, as do settings on each individual nested layer, and this relationship changes depending on whether Collapse Transformations is toggled.
- Layer timing (duration, In and Out points, frame rate) and dimensions can differ from the master comp. When this is unintentional, mishaps happen: Layers end too soon or are cropped inside the overall frame, or keyframes in the precomp fall between those of the master, wreaking havoc on, for example, tracking data.
- Are you duplicating a comp that contains subcomps? The comp itself is new and completely independent, but the nested comps are not (see Script at right).
No wonder people avoid precomping. But there is hope if you recognize any difficulty and know what to do, so that inconveniences don't turn into deal-killers.
Boundaries of Time and Space
Each composition in After Effects contains its own fixed timing and pixel dimensions. This adds flexibility for animation but if anything reduces it for compositing; most other compositing applications such as Nuke and Shake have no built-in concept of frame dimensions or timing and assume that the elements match the plate, as is often the case in visual effects work.
Therefore it is helpful to take precautions:
- Make source compositions longer than the shot is ever anticipated to be, so that if it changes, timing is not inadvertently truncated.
- Enable Collapse Transformations for the nested composition to ignore its boundaries (Figure 4.8).
Figure 4.8 The nested comp has a blue background and the leg of the letter "p" extends outside its boundaries (top); a simple quick fix is to enable Collapse Transformations, and the boundaries of the nested comp are ignored (bottom).
- Add the Grow Bounds effect if Collapse Transformations isn't an option (see sidebar on next page).
Collapse Transformations is the most difficult of these to get your head around, so it's worth a closer look.
In After Effects, when a comp is nested in another comp, effectively becoming a layer, the ordinary behavior is for the nested comp to render completely before the layer is animated, blended, or otherwise adjusted (with effects or masks) in the master comp.
However, there are immediate exceptions. Keyframe interpolations, frame blending, and motion blur are all affected by the settings (including frame rate and timing) of the master comp—they are calculated according to its settings (which can become tricky; see the next section). 3D position data and blending modes, on the other hand, are not passed through unless Collapse Transformations is enabled. Enable the toggle and it is almost as if the precomposed layers reside in the master comp—but now any 3D camera or lighting in the subcomp is overridden by the camera and lights in the master comp.
Not only that, but layers with Collapse Transformations lose access to blending modes—presumably to avoid conflicts with those in the subcomp. Now here comes the trickiest part: Apply any effect to the layer (even Levels with the neutral defaults, which doesn't affect the look of the layer) and you force After Effects to render the collapsed layer, making blending modes operable. It is now what the Adobe developers call a parenthesized comp. Such a nested comp is both collapsed and not: You can apply a blending mode, but 3D data is passed through (Figure 4.9).
Figure 4.9 Shown is the simplest example I could devise of the most complicated precomping situation. The nested comp (left) is a 3D box made up of solids, each with a Multiply blending mode. In the master comp (right) a Levels (effect with no adjustment) is set, allowing an Add mode to be applied, yet the box can still be rotated in 3D—those values are passed through.
Thus, if you want to collapse transformations but not 3D data, applying any effect—even one of the Expression Controls effects that don't by themselves do anything—will parenthesize the comp. It's a good trick to keep in your pocket. Will you run into this exact situation? It may be a while before that ever happens, but it's a case study to help you sort out exactly what is going on when you precomp and collapse transformations.
After Effects is not rigid about time, but digital video itself is. You can freely mix and change frame rates among compositions without changing the timing, as has been shown. However, because your source clips always have a very specific rate, pay close attention when you
- import an image sequence
- create a new composition
- mix comps with different frame rates
In the first two cases you're just watching out for careless errors. But you might want to maintain specific frame rates in subcomps, in which case you must set them deliberately on the Advanced tab of the Composition Settings dialog.
Advanced Composition Settings
In addition to the Motion Blur settings introduced in Chapter 2 and covered in detail in Chapter 8, Composition Settings > Advanced contains two Preserve toggles that influence how time and space are handled when one composition is nested into another.
Preserve Frame Rate maintains the frame rate of the composition wherever it goes—into another composition with a different frame rate or into the render queue with different frame rate settings. So if a simple animation cycle looks right at 4 frames per second (fps), it won't be expanded across the higher frame rate, but will preserve the look of 4 fps.
Preserve Resolution When Nested controls what is called concatenation. Typically, if an element is scaled down in a precomp and the entire composition is nested into another comp and scaled up, the two operations are treated as one, so that no data loss occurs via quantization. This is concatenation, and it's usually a good thing. If the data in the subcomp is to appear pixilated, as if it were scaled up from a lower-resolution element, this toggle preserves the chunky pixel look.