Monday 28 January 2013

Time Remapping Expressions


Time Remapping Expressions

There are many ways to create interesting effects with time
remapping expressions. You’ve already seen one (the last
expression in the previous section). Here are a few more
illustrative examples.
Jittery Slow Motion
Here’s an interesting slow motion effect where frames 0, 1,
2, and 3 play, followed by frames 1, 2, 3, and 4, then 2, 3,
4, and 5, and so on. First, enable time remapping for the
layer and then apply this expression to the Time Remap
property:
cycle = 4;
f = timeToFrames();
framesToTime(Math.floor(f/cycle) + f%cycle);
The fi rst line sets the value of the variable cycle to the
number of frames After Effects will display in succession (4
in this case). The second line sets variable f to the frame
number corresponding to the current comp time. Next
comes a tricky bit of math using JavaScript’s Math.floor()
method and its % modulo operator. The result is a repeating
sequence (whose length is determined by the variable
cycle) where the starting frame number increases by 1 for
each cycle.


Wiggle Time
This effect uses multiple copies of the same footage to
achieve a somewhat creepy echo effect. This effect actually
involves three short expressions: one for Time Remap, one
for Opacity, and one for Audio Levels. First, you enable
time remapping for the layer. Then apply the three expressions
and duplicate the layer as many times as necessary to
create the look you want.
Note that this time-wiggling effect is interesting, even with
a single layer. The Opacity and Audio Levels expressions
are necessary only if you want to duplicate the layer.
The expression for the Time Remap property is
Math.abs(wiggle(1,1))
wiggle() is an extremely useful tool that can introduce
a smooth or fairly frenetic randomness into any animation,
depending on your preference. wiggle() accepts
fi ve parameters, but only frequency and amplitude are
required. Check the After Effects documentation for an
explanation of what the remaining three optional parameters
do.
The fi rst parameter, frequency, represents the frequency
of the wiggle in seconds; wiggle(1,1) varies the playback

speed at the rate of once per second. The second parameter
is the amplitude of the wiggle, given in the units of the
parameter to which wiggle() is applied, which in this case
is also seconds. So, wiggle(1,1) lets the playback time deviate
from the actual comp time by as much as one second in
either direction.
You use Math.abs() to make sure that the wiggled time
value never becomes less than zero, which would cause the
layer to sit at frame zero.
The Opacity expression gives equal visibility to each layer.
Here’s what it looks like:
(index/thisComp.numLayers)*100
This is simply the ratio of the layer’s index divided by the
total number of layers in the comp, times 100%. That
means if you duplicate the layer four times (for a total of
fi ve layers), the top layer will have an Opacity of 20%, the
second layer will have an Opacity of 40%, and so on, until
the bottom (fi fth) layer, which will have an Opacity of
100%. This allows each layer to contribute equally to the
fi nal result.
If the footage has audio, you have a couple of choices.
You can turn the audio off for all but one of the layers,
or you can use an expression for Audio Levels that normalizes
them so that the combined total audio level is
roughly the same as it would be for a single layer. I think
the second option enhances the creepiness of the effect;
here’s the Audio Levels expression for a stereo audio
source (for a mono source you could just leave out the
second line of the expression):
db = -10*Math.log(thisComp.numLayers)/Math.log(10);
[db,db]
This is just a little decibel math that reduces the level
of each layer based on how many total layers there are
(using the comp attribute numLayers). You’ll also notice
a couple of JavaScript elements you haven’t encountered
before: Math.Log() and an array (the second line of the

expression). In expressions, you specify and reference
the value of a multidimensional property, such as both
channels of the stereo audio level, using array square
bracket syntax.






No comments:

Post a Comment