Chapter 8 alluded to methods for smoothing and destabilizing a camera that are preferable to the Smoother and the Wiggler, After Effects' built-in solutions that predate expressions. It's time to take a closer look at these expression-based methods; they're fairly easy to learn and will expand your capabilities quite a bit.
Steadicam and Camera Shake
Some applications offer specific effects for smoothing or destabilizing the camera, and I've seen at least one other author claim that After Effects has no tools for camera stabilization and destabilization. Let's see about that.
If you followed the steps in Chapter 8 for using a 3D camera to motion track a scene in such a way that the track is applied only to the layer and camera, you're ready to proceed. If not, please review that section briefly if you want an idea of how the setup can be applied to a motion-tracked camera. You can destabilize a camera using wiggle without tracking data (Figure 10.15).
Figure 10.15. The camera in this shot is parented to a null with a wiggle expression applied to its Position value to automatically destabilize the camera, making it feel handheld.
Once again, application of the expression is easy. Given a set of keyframes, you can smooth themaveraging them against the closest adjacent keyframes (you control how many)or add noise and jitter, respectively applying one of the following expressions:
smooth() wiggle(freq, amp)
The default text is more verbose, but I'm hoping that presenting them in their minimal form makes them appear easier to use than they do with the menu defaults (explained below).
You can apply smooth() as is, and see the result in the Graph Editor. This graph constitutes an additional advantage to applying smoothing with an expression, because you can see the amount of change without even previewing the animation (Figure 10.16).
Figure 10.16. A close look at the operation used to smooth a camera move from Chapter 8 shows how effective this method is, even with the default expression in place. If this was not smooth enough, you could raise the "width" or number of samples, described here.
You can of course tweak the amount of smoothing with the help the verbose parameters shown in the default expression:
smooth(width = .2, samples = 5, t = time)
These are the default settings; width, samples, and t are there to offer you a clue what each argument does, and they are designed not to break the expression if left in. The = sign followed by a value tells you that they have default values if you leave them out. Here's what each specifically does:
The wiggle expression requires two arguments by default, and has the option for as many as five. At a minimum, you must enter values for freq (frequency, the number of wiggles per second), and amplitude (the maximum amount the wiggle will change a valuein this case, the number of pixels). The full default expression reads
wiggle(freq, amp, octaves = 1, ampMult = 5, t = time)
Although it wasn't possible in earlier versions of After Effects, in 6.5 you can apply wiggle() to a property that has no keyframe data whatsoever, useful for adding the jitter of a handheld camera to a static setup.
For the most part, freq and amplitude are all you need, but to give a complete picture, octaves controls how many noise samples are averaged together, and won't usually need to be more than 1. A higher value for octaves doesn't mean more noise, it just means more samples, and ampMult multiplies the resultall to provide variety. If you want more noise, raise frequency and amplitude. Time, once again, is an offset.
Close-Up: Geek Alert: Wiggle versus Random
The wiggle() function adds random data to an animation channel. How does it differ from the functions in the Random Numbers submenu?
Random numbers are truly random; any number generated has no relationship to the number preceding it. They can be constrained to a particular range, and Gaussian random numbers will tend toward the center of that range (following a Gaussian distribution pattern that weights random numbers toward the median), but the effect is one of values that pop around completely randomly.
With wiggle(), the seeming randomness is generated by adding an organic noise function to existing data. The randomness is not quite so random: It takes existing data and deviates from it, within a set range (amplitude) and at a set number of times per second (freq). The wiggle() function, then, not only has the advantage of using animation data to determine its range, but of generating an effect that does not feel so chaotic as random data.
To apply smooth() and wiggle() expressions to a 3D camera that has been tracked to match the background, try opening the example from Chapter 8, 08_tracking.aep, and look again at the smoothCam composition.
Alternatively, to generate random numbers within a given range (rather than wiggling keyframe values), you can use the various random, Gaussian random, and noise functions found in the Random Numbers submenu (see the sidebar, "Wiggle versus Random"). Or, to wiggle the temporal position of keyframes themselves (to offset them randomly in time), try
It's not the most commonly used, but it is useful if you need the animation values to stay in exactly the same range (to follow a path, for example) but to move back and forth semi-randomly on that path.
Offsetting Layers and Time
Section I. Working Foundations
The 7.0 Workflow
Selections: The Key to Compositing
Optimizing Your Projects
Section II. Effects Compositing Essentials
Rotoscoping and Paint
Effective Motion Tracking
Film, HDR, and 32 Bit Compositing
Section III. Creative Explorations
Working with Light
Climate: Air, Water, Smoke, Clouds
Pyrotechnics: Fire, Explosions, Energy Phenomena
Learning to See