Tutorial 3.2

Starting with an image of a ceiling and 5 images of a rotating fan, this tutorial makes the ol "gee, those fan blades sure have some air of mystery with that strange flickering light behind it, and it sure is dusty in here, even though there is a ventilation device" effect. You know the one. Here are some example pics to show what I mean:

 

We will break this comp down into four steps. The first is to set up the the basic composition, both in the frame, and in time. Since we only have five images of the fan, we have to loop the animation using the Time View. We will also add an animated RGrad behind the ceiling image to act as a light.

The second step will be to add flickering onto the RGrad. This shows the use of expressions, and how to use local variables to be able to better control them.

The third step will be to add the Radial Blur (RBlur) effect to give the volume rendering feel.

The last step will be to add some motion blur to the fan, even though it is already animated. Its cool.

 

Setting Up the Comp

 

Reading in the Files

Hit the Image - FileIn button to load in the images we want with the File Browser. Go to <ShakeDirectory>/doc/pix/fan and read in ceiling.iff and fan.1-5.iff.

You can read both of these in by one of two methods:

You should now have two FileIn nodes, named ceiling and fan, looking something like this. I've added a little bit of brightness to the fan blades for illustration purposes only.

 

We are also going to need an Image - RGrad, so go ahead and make one of those, too. You should now have a mind-bogglingly complex node tree looking something like this:

 

Compositing the Images Together

You can layer all of these together with a Layer - Over, or you can try the Layer - Layer node, which is a combination of most of the other layering commands. You can choose which operation you want (Over, Inside, IMult, etc), and quickly test other modes by selecting a different operation. By default, it is set up to be an Over operation. It behaves exactly like other nodes:

 

Attach a second Over or Layer node to the first Layer node, and use RGrad1 as the background:

Because RGrad1 is created at the default resolution of D1, make sure your Layer2 is set to take the foreground resolution:

This should leave you with something stunning like this:

 

Animating the RGrad

Since we are stuck with only five frames of material, we can add a little dynamism to the comp by animating the position of the RGrad so it approaches the hole in the ceiling.

Make sure you are on frame 1, view Layer2, and load the parameters of RGrad1 by clicking on its right side. The on-screen controls should appear. Turn on the Viewer's Autokey button: Go ahead and position the RGrad where you want. I moved mine up and to the right, and reduced the size of it:

Jump to frame 75 (or so...), and enter a second key position:

Drag the current frame on the Time Bar to see the dramatic animation. Those of you who are observant and not sound asleep by now will note that the fan blades disappear after frame 5, somewhat reducing the realism of the scene. Doh! We will fix this in the Time View.

 

Adjusting Clip Length in the Time View

If you click on the Time View tab, which is at the right of the Tools Tab window (nicely marked Tim in my illustration...), you will pop up the Time View window, showing you the clip length of your nodes so far:

The Select Group switch will list just the nodes you select in the Time View. Additionally, only Image generators like FileIn, Grad, etc and nodes combining two branches together (Over, IDisplace, etc) are listed. Since all nodes so far are those types of nodes, they are all displayed in the Time View.

You can see the little infinity symbols on the left and right edges of ceiling and RGrad1. This means that the clip has no beginning or end points. The short fan clip however, has a finite length of five frames. At frame six, the clip disappears.

Hold down Ctrl and grab the right edge of the clip and drag it out to frame 75, and the clip length is extended. By holding Ctrl down, we break the relationship between the clip from disk and the actual duration of the clip in the comp. If we didn't hold Ctrl down, it would have dragged the from-disk range out, suggesting that there were in fact 75 frames on disk. That would be bad.

By default, it will show blue to indicate it is frozen, meaning the last frame of the clip is repeated up to the out point. If you open up fan's FileIn parameters, you will see a timing sub-tree. Open it up by clicking on the plus sign

The two parameters inMode and outMode determine how the clip behaves if you extend it beyond the normal range of the clip, as we have done here.

Icon Mode
Black extension
Freeze - last (or first) frame is repeated.
Repeat - the clip is repeated.
Mirror - the clip is repeated backwards, but the end frames are not repeated.
Mirror Increment - the clip is repeated backwards literally, so the end frame is displayed twice in a row.

Therefore, switch outMode to Repeat, and it will repeat continuously for the 75 frames.

 

By the way, startFrame and endFrame control where in time the clip is located, and firstFrame and lastFrame control what part of the clip is read from disk. Both can be controlled here or from the Time View.

Look back at the Time View, and you will see that it is indicating a repeat of the clip, with markers to tell you the looping point:

Go to the Time Bar, and hit the Playback button . This differs from the normal Viewer Flipbook button in that it doesn't load the images into RAM - it just renders and plays through as fast as it can. You should now see the fan blades looping. Click the mouse anywhere to stop the playback.

 

   Using Local Variables with Expressions

This step involves creating several new variables and combining them with expressions to create a controlled flickering effect on the background light (or whatever it is...)

Creating Flicker on the Light

The first step is to insert a Color - Fade between RGrad1 and Layer2:

We can of course turn on autokey and animate the value parameter to get flicker on the light, but you really want to show the people working next to you how superior you are in all ways moral, physical and technical. That is, after all, the point of CG. To that purpose, we will instead insert a function into the value textfield.

Double-click in the textfield. This will select the 1 in it - type the word time. If you are in the Shake-style interface, a plus-sign will appear next to the parameter. You can hit it to open the expression beneath the parameter in a textfield. If you are in the Tremor-style interface, the double-clicking will have locked that expression into the Expression box above the Function Bar on the left side. You can then continue to edit it there. The old parameter textfield will now display the result of the expression.

Shake-style Tremor-style

By entering the keyword time, it tells the software to take the current frame number and use it for value. Move the Time Bar slider to check. This of course over-brightens the image as you get to higher frames, since at frame 70 it creates a fade value of 70. We will therefore use a different expression.

Return to your expression box. We can put any expression here, so do something crafty like using a random function. Type in

rnd(time)

Shake-style Tremor-style

This will return a random value between 0 and 1, with time as your seed. The rnd function isn't truly random. If you use the same seed each time, you will get the same result. By using time as your seed, we guarantee that the values will differ from frame to frame. Hit the Playback button at the bottom so see the animation.

Where do you find more functions? Go to Functions By Class - Expressions.

If you move the slider on value, you will remove the expression. Simply re-type the expression, or hit Undo: or (Ctrl+Z) . The only exception to this behavior is if your expression is an animated curve that you create with keyframes, since curves are actually expressions. In that case, modifying the slider will enter or modify a value.

You can see the animated values in the Curve Editor by clicking on the Load Expression button and opening up the Curve Editor.

Your dreams of morally dominating your co-workers will no doubt be crushed when you try clicking on the yellow curve - nothing happens, because we aren't using keyframe animation. Each value is being generated by the expression. So this is how you control an expression:

 

Go back to the Parameter1 tab, and click the Right Mouse. On the popup menu, select Create Local Variable. This means we will be adding an extra parameter to Fade1 that we can do whatever the hell we want with. A window will appear prompting you to name your local variable, and what type of variable it is:

  • float - a number with a decimal place (.1, .5, 1.0, etc)
  • int - a rounded number (0,1, 2, etc)
  • string - characters ("Hey, what's up?")

Enter a name of rndVal and keep it on float. A new sub-tree named Fade1.localParameters will appear in Fade1's parameters. In the Shake-style interface, this appears at the end of the parameter list. In the Tremor-style, it appear on the left side below the node input parameters. Open it up, and you will see your new parameter named rndVal.

If you adjust the slider, you will see that absolutely nothing happens. How exciting!

Go back and create another local variable, naming it animVal. Turn on the autokey for animVal, and enter three keyframes at frames 1, 40, and 75. Make at least one of them a value of 1. The values really don't matter right now. And still, nothing happens! Oh, rapture!

We now want to swap the rnd function from value on to the rndVal parameter. Double-click on value's expression textfield that says rnd(time) , copy it with the now-classic Ctrl+C and paste it into the rndVal textfield with always-a-hit Ctrl+V.

Returning to the value expression box, change the expression to:

rndVal * animVal

Therefore,

value = rndVal * animVal
rndVal = rnd(time)
animVal = animated curve



By entering the expression into value, we multiply the results of rndVal and animVal together. Make sure value and animVal, but not rndVal, are loaded in the Curve Editor. You can see that the curve is modifying the shape of the otherwise random curve - go ahead and grab its keyframes or insert new one (by Shift+clicking on a segment), and you change the form of the random shape. If you can't see the shapes, make sure at least one of animVal's keys equals 1, and then hit Home in the Curve Editor to frame the curves.

We like this trick. It makes us warm and happy.

If you are using the Playback button, close the Curve Editor by going to a different tab - it, and the Color Picker, slightly slow down playback speed.

 

   Using RBlur

These steps will now build the atmosphere by using the RBlur function. RBlur stands for Radial Blur, by the way.

Inserting the RBlur

We want the RBlur to come off of Fade1, so select Fade1, and then Shift+click on Filter - RBlur. This will create a new branch off of Fade1:

By default, you aren't going to get much difference between a normal RGrad and a RBlur, since both are kind of the same shape:

To help give the RBlur more definition, click on Layer1 and Shift+click create another Layer node. Rename it Layer_Outside in the Parameter tab. Then take the output of Fade1 and drag it into the second input of Layer_Outside. Switch Layer_Outside's operation to Outside. This will cause the RGrad to only appear wherever there is no alpha in the ceiling/fan composite. Finally, reattach RBlur1 to Layer_Outside:

and look at it. It now has a slightly more interesting effect:

 

If you get the inputs mixed up on Layer_Outside, grab one of the input noodles and swap it over to the other input knot. The other input noodle will automatically be switched, too. Also, make sure the clipMode of Layer_Outside is set to background.

 

Since we now have something interesting, we can go ahead and tune RBlur1's parameters. Set the following:

  • iRadius = 0. This will mean there is no area of the center that is non-blurred
  • oRadius = 300. This sets the blur amount. Since the image is 400x300 pixels, I choose 300.
  • amplitude = 1. This is a sort of multiplier on oRadius. The greater this number, the more blur you have. This will also effect the rendering speed.
  • quality - this sets the quality of the rendering, so if things slow down too much, lower this to .1.

Linking the RBlur to the RGrad

If you jump to a different frame, you will notice that the light is moving, but the rays are shooting off from same position. It looks better if we animate the center of the RBlur, and match it up to the center of RGrad1. The best way of doing this is by linking the x- and yCenter parameters of RBlur1 to the x- and yCenter parameters of RGrad1. Therefore, in RBlur1's xCenter parameter, type:

RGrad1.xCenter

and in RBlur1's yCenter:

RGrad1.yCenter


These are expressions just like rnd(time) or animVal * rndVal, except that they tell the software to go check the x and yCenters in the RGrad1 node for their values.

Now as you move to a different frame, the origin point of the rays will be animated with the center of the light. If you adjust the RGrad, the RBlur will update as well. However, if you move the on-screen control for the RBlur, it will break the link. Use Undo to retrieve it.

 

Hooking the RBlur into the Composite

Click on RBlur1, and click on Layer - LayerMacro. Rename the node Layer_Add, and attach its output back to the second input of LayerMacro2. Now drag the output of LayerMacro1 to the second input of Layer_Add. Finally, switch over the operation parameter of Layer_Add to be IAdd.

Setting the operation to IAdd will add the two images together. We then re-use Layer2 to place the atmosphere and the fan/ceiling elements over the RGrad.

 

Concatenation of Color Corrections

Now to do a little color correction. We can control the intensity of the RBlur by attaching another Color - Brightness after it, and then modify the color by attaching a Color - Mult after that. Both of these go between the RBlur and Layer_Add:

For the Brightness, I want to use the same animation as we have in Fade1, but I want to increase its value, so I link Brightness1's value parameter to Fade1, and multiply it by 2:

Fade1.value * 2
Shake-style Tremor-style

When tuning this, you want to find a frame where there is a high value in Fade1. It doesn't make sense when value is around 0.

To do the color correction, I use the Mult node and the Color Picker. Click on the big color button in Mult's parameters, and the Color Picker will appear. Go ahead and drag the cursor in the Color Picker and your color will update in Mult1. Not that you need this right now, but when Sample from Viewer is turned on, you can also pick up color from the Viewer.

Another way to do this is to drag in the Virtual Color Pickers - hold down V and drag left on the Color line in Mult. This will bring down the value. Now hold down B and drag right - this will boost up the blue color.

You may not have picked up on this, because it is rather subtle, but you can witness the concatenation of color corrections occurring here between Brightness1 and Mult1. The Mult should be turning the entire RBlur blue, but you can see that the center remains white. This is because the calculations don't clip off at 1 for the color corrections. The Brightness has raised the values of the center to around 1.5 in my sample image to the right. When the Mult brings that value down by multiplying by .7 and .6 in the red and green channels, it only lowers the pixel value to around 1.05 and .9, respectively. This leaves those pixels with a whitish color.

To see what would have happened if there was no concatenation, insert a Color - Clamp between Brightness1 and Mult1 - everything turns a flat, disagreeable blue.

Concatenating Non-concatenating.

Delete the Clamp...

   Adding Motion Blur to Pre-Animated Elements

By this stage, the comp is too slow to use the Playback button, so use the normal Flipbook button in the Viewer to see your 75 frame animation. If only 1 frame comes up, go to Globals, and set your timeRange to 1-75, and re-launch the flipbook. As you look at the animation, you will notice that the fan looks real choppy. To help it out, we are going to add motion blur to it without actually moving it.

Match the Movement

The trick here is to take any disposable element and match the movement to what is already animated. I am a big fan of using Image - Text. I've already created an appropriately sized element here by setting resolution and the xFontScale. To put it into the comp, copy it in your html Browser (probably Ctrl+C), making sure you get the last line with the semicolon, then activate the Shake window by clicking on it (if using NT), and hit Ctrl+V with the cursor over the Node View. This should paste the Text node right in:

Text1 = Text(150, 150, 1, "X", "Courier", 307.74, 270.414, 1, 74.5, 134, 0, 2, 2, 1, 1, 1, 1, 0, 0, 0, 45 );

It should paste under your cursor.

If you are looking at printed documentation, create the Text node, set your width and height to 150, your font to Courier, use X as your text, and set your xFontScale to 307 and your yFontScale to 270.

The next step is to mix the Text node in with the fan node. Attach a Layer - Mix, and attach the second input to fan. Because the fan is so dark, either boost up the brightness on the fan, or just look at the alpha channel. All of this is just temporary, so don't bother inserting it into the rest of the tree.

We can now match the fan animation. First, go to frame 1. Insert a Transform - Move3D between Text1 and Mix1, or just copy and paste my node from below:

Move3D1 = Move3D(0, 153.7649, 86.88863, 0, -7.659575, -22.97875, -196.597, 1, 0.9259, 0.9259, yScale, 75, 75, 0, 15, "default", xFilter, "trs", 0, 0, 0.5, 0, 0, time );

This should give you something like this:

I've matched up the center of the tool with the fans. I set my parameters as follows. Set the fieldOfView first, or else it will be an orthographic manipulation without any perspective shift:

  • fieldOfView = 15. I got this from my 3D package's camera settings.
  • xPan = 153
  • yPan = 87
  • xAngle = -7.6
  • yAngle = -22.9
  • zAngle = -196
  • x/yCenter = leave at 75

If you are at frame 1, click on zAngle's autokey button to enter a key. We are only going to be modifying zAngle from now on.

Now go to frame 5, and turn the zAngle parameter to around -122. To test the animation, use the left- and right arrow keys to step through your animation. It should match up fine between frames 1 and 5, but the animation stops at frame 5 and does not continue. We can fix this in the Curve Editor.

Pop the zAngle curve into the Curve Editor, select the curve, and choose its repeat behavior from KeepValue to KeepSlope. Instead of having a flat value before and after our two keyframes, this will keep the zAngle parameter spinning into infinity.

KeepValue mode KeepSlope mode

Now test the animation again with the left- and right arrow keys, and it continues to match up after frame 5.

We are almost done. Honest.

We are now done with the X, since we have matched the animation. Click on Move3D1 and hit E to extract that node. This pulls it out of the node tree, but doesn't delete it. Reattach it between fan and Layer1, and delete Text1 and Mix1.

You will probably notice that the fan isn't looking quite right at the moment. This is because the transformation is being applied to the fan, which isn't what we want.

To fix this, go to the bottom of Move3D1's parameters, and turn on motionBlur, setting it to .5 when testing. This still isn't right - it transforms the fan. To turn this off, at the very bottom is a parameter called useReference. Turn that on, and the fan snaps back to its original position, but it now has the motion blur we want.

When useReference is on, it turns off the transformation, but will still apply motion blur as if it was being moved.

Load the last node into the Viewer and hit the Flipbook button.