Tone's Expressions Tutorial

The following is taken from Tony Jover's NAB 2005 presentation on Expressions. To get the original materials, pdf and presets, click here: Tone's Expressions ZIP

TREES 'n stuff

In this paper we're going to be looking pretty closely at Expressions. Firstly because they're pretty
new to most folks, and secondly because they are so very powerful. Also, by looking at the
relationships that you can build with expressions and trees, we'll simultaneously be considering how
to put trees together, and the relationship between nodes within trees.

I'd like to take this opportunity to thank Igor Boros, Bob Maple, and numerous folks at Softimage
for their assistance in providing information and examples for this paper.

This paper is by no means exhaustive, and the examples it gives are relatively simple, but should
give a good grounding on the use of Expressions.


Start off by restoring the "Trees" archive. Then open the "Expressions" sequence.

Let's firstly look at the simplest method of creating an expression.


Right at the beginning of the timeline you can see that we have a pretty, lazy, fluffy lion, courtesy of
Artbeats (as if you couldn't tell from the nice subtle logo up there top left!). There's a bypassed DVE
effect on that clip, but I'll ask you to ignore that for now. What we're going to do is to create the
same DVE effect ourselves, and the bypassed one is there to refer to in case there's any confusion at
any stage. So, let's apply a DVE to that clip as a clip effect, using the Quick Effects toolbar. I use
the Quick Effects toolbar a LOT for applying my commonly used effects ­ if you don't already
know about it, it's accessed off F2.

Let's take a quick look at this toolbar. If you right-click an area of the toolbar to get its properties,
you'll see that "Auto-Close" is selected. This means that once you've clicked an effect, the toolbar
will close down, getting it out of your way. There's nothing particularly special about the Quick
Effects toolbar; it's just a regular toolbar. So you can drag effects onto it, delete effects from it etc,

So, we apply our DVE as a clip effect. Let's open up its PPG and add an Expression between its
size and its Z rotation. To do this we right-click the X Scale keyframe button, and drag it over the Z
Rotation keyframe button. You'll notice that DS gives a little "Expression" symbol as you hover
over the Z Rotation button, and when you release the mouse or pen, Z Rotation takes on the value of
X Scale, causing the image to be rotated by 100 degrees. Strictly speaking, this isn't yet an
expression, it's just a link: one attribute has taken the value of another, but don't worry, we'll get to
that later. Now we can right-click the Z Rotation button and select Expression Editor.


The Expression Editor is where you'll make and adjust your expressions. At the bottom of the Editor
is a list of all the inputs that you have so far made available for this attribute. Currently, there's just
the one, and you'll see that it's labelled DVE X Scale (because that's what you dragged there). In the
top window is the expression that's currently applied to that input. In other words, the top window
says what mathematical expression you will apply, to achieve your desired output. You can
achieve some pretty clever and complex expressions with this tool, and you can also mix and match
inputs within the one expression. So for instance you can say "Rotate this image by x amount, but
only if y is valid". We'll look at an example or two of these later.

Looking at the buttons available, you'll see there are 4 below each of the windows. The ones at the
bottom are pretty obvious. You can add an input (which you will connect to a source later), you can
remove an input, you can disconnect an input from its current source, and you can select an input, to
see what it's doing ­ how it's used within the expression.

The four buttons for the top window take a little more explanation.

Insert enables you to build an expression using all of the parameters available for the expression
language. For reference, the language used for DS Expressions is the XSI scripting language, so it's
well tried and tested. Clicking Insert shows all the functions available to you. You'll notice that
there's a random function ­ so you can now make those wobbly "hand held" DVEs natively within

To see how to use Insert, select the value that you want to use ­ like sin - and you'll see that DS
sticks it in the expression window. The <expr> bits are simply placeholders which you then have to
replace with whatever you want, such as "Input 1" or a value. Alternatively, you can hold down Ctrl
when inserting a function, and it won't add the placeholders.

Revert is a kind of undo for expressions. Click it now and it'll remove the expression you just
added. So if you're fiddling around, wishing you'd paid more attention in those maths classes at
school, you can simply give up and revert back to the existing expression.

Validate is your friend. Validate will tell you whether or not your expression makes sense to DS.
It'll either tell you that it's valid, or it'll tell you where it's confused ­ like for instance forgetting a
closing bracket. The last button, Apply is pretty self-explanatory.

Having quickly looked at its various areas let's quit the Expression Editor for now and get back to
our DVE where we have Z rotation linked to X scale. You'll notice two important things here.
Firstly, the button is showing a double-arrow. This means that the expression is bi-directional.
What this means is that you can actually control either of the functions with the other one. So,
adjusting the X Scale gives a corresponding adjustment to Z rotation as we expected, but altering Z
rotation also gives the same adjustment to the X Scale. Here's where you'll notice the other
important thing. Adjusting the X Scale also adjusts the Y scale, because the "Link" button is
selected, however adjusting the Z Rotation doesn't adjust the Y Scale because X scale is being
adjusted by an expression; not directly. Read that again slowly if it didn't make sense the first
time ;-)

This might be what you want to achieve, but if it isn't, then you can just make Y a link from X
(right-click drag X onto Y) and they'll track together again.

Okay then.... what we want to happen here is that as the DVE scales down, so it rotates in Z. We
can see our first problem ­ it's starting off with Z rotated when X scale is 100%. So we need to
make Z = 0 when X Scale 100. This is nice and simple, we simply need to remove 100 from the
starting value. So open up the Expression Editor for Z Rotation and change the expression in the
top window to become < Input 1 ­ 100 > (without the angle brackets ­ I shall be using those purely
for identification of an expression).

Now, as we reduce the value of X Scale from 100 down to zero, we have Z rotation starting off in
the right place, but it doesn't spin enough for our client's tacky taste, he wants the image to spin
round and round. If we therefore multiply the value by something ­ like 5 - we should be getting
closer. So change the expression to become < 5*(Input 1 ­ 100) > .

Our client now likes the amount of rotation, but he wants the DVE to spin the other way. So we
need to change sign of the result. There are a few ways to achieve that, but for this example we'll do
it by changing that 5 to a minus 5, giving < -5*(Input 1 ­ 100) >.

Just when we thought we were safe, the client wants the size to increase past 100 and then settle
back down ­ but with no rotation once the image reaches 100% size. So here's where we continue
to think it through logically. We're saying if X Scale is less than 100, then our current expression is
fine, but if X Scale is greater than 100, don't do anything to Z rotation. So we're making a
Condition. On the condition that X Scale is <100 then go for it, otherwise don't. So, let's add
Condition. When you select it you'll see that it has three parts; the argument, and the two
alternatives. We know that our argument is <100 (in other words, only if the value is less than
100), so we'll insert that as the argument. We know what we want to happen if the argument is true -
the expression we've already made - so we copy/paste that into place. Finally, if the argument is
false, we simply want to return a value of zero, so that's the value after the comma. That should
now leave you with an expression that reads < cond( Input1<100, -5*(Input1 - 100), 0 ) > (If the
condition is met that Input 1 is less than 100, then do the first bit, otherwise return a value of zero)
which achieves exactly what we were after.


After our wonderful DVE move, all controlled from one fader, the next thing that you'll find on the
timeline is a funky transition between that sleepy furry lion and those glass and chrome structures of
Manhattan. The transition is a nice simple, linear tree, so let's have a look and see what we've got.

Before we do, I should just mention one fundamental that still to this day drives me nuts on a
regular basis. Before opening a tree, ensure that you have no PPGs open. If you ensure this, then
you won't find that double-clicking a node will recycle those PPGs, ending up with them opening up
behind your expanded tree view. So, with all our existing PPGs closed, let's open up the tree.

Inside the tree you can see that it's nice and simple as I mentioned above. We have a composite
node handling the actual transition between the two shots, then a blur, posterize and frame average.

Let's look at how this tree was built.

Firstly, the Composite Node is dead simple ­ just a fade up of input 2 over input 1. What I wanted
to achieve was for the blur to increase as the fade happened, reaching a peak at the mid-point, then
decreasing back to zero as the dissolve continued.

Looking at the Blur's PPG you will see that X and Y blur both have an expression. The one on Y is
dead simple ­ it's exactly the same as we did on the DVE earlier, to link the X and Y scale. So, this
simply ensures that the Y radius will track the X radius. Obviously this could be more complex if
required. Now, as stated above, we want the X radius to be controlled by the Opacity of the
Composite Node's Layer 2. This means creating expressions between effects. This is achieved by
dragging controls from one PPG to another.

Firstly, open the PPG for the Composite node, and pin it in place using the pin icon,
then open the PPG for the Blur node. It'll probably open up over the top of the pinned Composite PPG, so just
drag it to one side so that you can see both PPGs. You can see now how you can drag relationships
between the two PPGs and make interactive expressions. You simply drag across from one PPG to
the next.

Now open up the Expression Editor for the X Radius on the Blur node. Taking a look at the
expression shows us something very slightly more complex than before.

We had two objectives:

1. To create a value that rose and fell as the input value rose from zero to one hundred. In
other words, when the input was at 50 our expression wanted to reach its peak, dropping
back down as the input rose up to 100
2. To make the resultant value into a usable figure.

To obtain a value that rises and then falls we need to use a trigonometry function ­ in this case I
used Sine. The multiplier of 1.9 is an approximation to get the peak sine value of 1 with an input
value of 50. In other words, getting it to grow from zero to one and back to zero over a range of 100
as described above. That value is then multiplied by 40 to get a usable figure. So, we now have the
blur animating from zero to 40, then back to zero.

I wanted to follow the blur with a Posterize that starts at 8 (which on an 8 bit sequence is "No
change"), drops to 4, then goes back up to 8. Bearing in mind that the Blur X Radius starts at zero,
peaks at 40 and then drops back to zero, we must have something eminently usable there for a
starting point.

Open up the Posterize node and open the Expression for the Red channel.

I achieved what I wanted with the simple Expression that you can see here.

Taking the right-hand part inside the brackets first, this gives us a value that starts at zero, peaks at
4, and drops to zero again. Deducting this from 8 gives us the final result we're after.

The Green and Blue channels' Expressions are simply links to the Red channel.

The frame average node is in there just to smooth the transition a little because Posterize obviously
works in steps, and the result looked better with it there in my opinion..

There are almost certainly other formulae that would achieve the same or similar results, but this
seemed simple to my little brain.


Moving on to the next container - at 15 secs - we can see an example where there is both a time
function and a variable used. Process up the container and play it a couple of times.

Let's look at the tree. The first DVE at the top is the "Control" DVE. This is the only DVE with
animated parameters ­ all the others have Expressions from that DVE.

Each of the X and Y translate plus X and Y Scale values were dragged across to the second, third,
fourth and fifth DVEs to create the inputs for their Epressions. This is quite easy with the main
DVE PPG pinned into place; all you then need to do is to just click on each of the others DVEs to
recycle their PPGs.

Let's start off by looking at the 2nd DVE's Expressions.
Open up the Expression Editor for Translate X.


The first thing you'll see is a line all on its own < var offset = 20 >. This sets the value of a
Variable named "offset" at a value of 20. On the next line, we're using that variable in the
equation. The formula reads "Use the value of Input 1 at the current frame less the value of offset".
In other words, with the value of "offset" used in this Expression, delay this input by 20 frames.
This Expression was then copied and pasted to the other three animated properties.

Next, 2nd DVE was copied/pasted to create the 3rd, 4th and 5th DVEs. By popping into their
respective Expressions it is simple to edit the offset variable to be 40, 60, and 80 frames.

Note that this Expression didn't really require the use of a variable, I used one simply to give an
example of its usage.


By now I'm sure you're getting the idea, so you are going to remake the Ferris Wheel at 00:00:35:00
which was itself inspired by some comments made by the esteemed Bob Maple.

It's actually very simple to do, so you'll make it from scratch. If you get lost at any point, just refer
to this pre-built composite.

Open up the Compositing Container at 00:00:55:00

Firstly, add a DVE in the tree to each of the image's paths prior to the Composite Node (remember
Quick Effects).

Now let's use one of my favourite new Tree functions ­ removing unwanted inputs. You're not
going to need the Background Input on any of these DVE's so right-click the DVE node and remove
it. While you're at it, remove the Mask input from the Composite node. That makes things tidier
in the tree.

Add a Transform Node to the tree ­ just press "T". Feed it to the local transform inputs of both
DVEs. Now use the Transform Node to shrink the images to 50% Scale.

Offset the two DVEs by translating them in x by 180. Move one by X Translation = 180 and the
other by X Translation = -180

Now add another Transform node, this time to the DVEs' global inputs. Move to the beginning of
the Timeline and make a keyframe on the Z rotation of this new Transform Node. Now move to the
end of the Timeline, rotate Z to 720 degrees and make another keyframe. Change the Interpolation
to a linear transformation.

You now have the images spinning round, but you need them to counter-rotate in order to keep their
orientation constant. This is where the Expression comes in.

Drag the Global transform node's Z rotation to the local Z rotation of each DVE and use an
expression to invert the result, < - Input1 >. you now have them counter-rotating and looking like a
ferris wheel.

BUT... you've probably noticed the deliberate error ­ our ferris wheel only has two arms.

So, let's copy these two DVEs and paste them below the other two. If we feed their inputs as per the
ones above we now have four arms, but of course two of them are beneath the other two, so we can't
see them. We need to rotate them by a further 90 degrees with respect to the original two and to do
so we must do something a little different. Unfortunately, we don't have access to a DVE's
transform input, so we can't simply use an expression on that input.

But here's what you CAN do:

Firstly, disconnect the Transform node feeding the Global inputs of our two new DVEs and create a
new Transform Node feeding those inputs, set to 90 degrees Z rotation.

Now feed that transform node's global input with the original transform node, and as if by magic
you have the four arms!


As our last example of Expressions I just want you to look at a very clever although simple
expression that Igor Boros shared with me for this paper. It's another conditional one but I really like
his implementation of it.

It's an expression applied to the DVE Motion Blur Duration. Let's look at it. Firstly, process the
clip at 0:01:15:00. It'll take a little while to process as it has a heavy Motion Blur for part of its
duration. If you now play the clip and look carefully at it, you'll see that there's a pretty heavy
Motion Blur when the image moves from side to side on the X axis (in other words between
00:01:19:10 and 00:01:24:27), and not at any other time.

So let's look at the Expression on the Motion Blur Duration ("General" tab) to see how this was

We start of with a conditional, and the condition is If the value of Input 1 at the current frame
equals the value of input 1 in the current frame plus one (the next frame) then return a value of
zero. Otherwise return a value of 90.

What this achieves is that it looks at the value of Input 1, which in this case is X translation, and it
says "If it's moving, turn on Motion Blur, otherwise turn it off". If we step through the DVE we can
see that the DVE only moves on X between 00:01:19:10 and 00:01:24:27. Looking at the result of
our expression we see that Motion Blur is only on for that duration.

I've also dragged the Y and Z translations into the Inputs box, so you can experiment with changing
inputs in the Expression.


Process up the clips at 00:01:40:00 and take a look. Here's another tree just to get you thinking and
looking at relationships of nodes with one another.

Basically, I was given this logo as flat artwork and asked to fly it around and make the thing shake!!

Take a look at the tree clip effect on the "Shawes-SlammedIcon" clip.

There were several approaches I could have followed but in the end I used an HSL keyer to pick out
the orange colour. This is the foreground going into the Over node. I also grew the matte slightly
with a matte effect, and CC'd it to white. This is the background of the Over node and gives the
white outline. A Drop Shadow effect finishes it off. A very simple, but effective use of a little tree
to "Cut out" a flat logo and give me something to fling around.

With a random DVE on top! Take a look at the Expressions on X and Y translate to see how it was


Lastly, take a look at the tree at 00:01:55:00. Ain't that a fun tree? Someone sent this to me years
ago (apologies for forgetting who). It can replicate just about any telecine function including
vignette etc all in the one tree. I've replaced all the nodes with current 16/32 bit versions and I've
never ever used it... but it's still a fun tree.

I hope that's helped some of you. Any problems please email me at