Thursday, November 12, 2009

2.49b Vector Blur



Vector blur is a great way to add realism to your animation. Your eye naturally sees moving objects moving as a blur, because that is how your brain processes the motion. Without some sort of blurring, animated moving objects don't look as if they are realistically moving. Blender's animations are by default rendered as a sequence of perfectly still images. This is unrealistic, since fast moving objects do appear to be 'moving', that is, blurred by their own motion, both in a movie frame and in a photograph from a 'real world camera'.

To obtain such a blurring effect with moving objects, Blender can be made to render the current frame and some more frames, in between the real frames, and merge them all together to obtain an image where fast moving details are 'blurred'. The goal of this tutorial is to demonstrate how to blur moving objects in Blender.

First, we'll create a simple animation. We will animate the movement of the cube across the screen, over 50 frames. With an animation speed of 25 frames per second, that produces a 2 second video, one second going across the screen, the other second going back.

1) Go to the SR-1: Animation view.
2) Press the N key to bring up the Transform Properties window. Set the X location to -7, the Y location to 0, and the Z location to 0.
3) At Frame 1, press the I key and insert a Location key frame.
4) Go to Frame 25. Set the X location to 4, the Y location to 0, and the Z location to 0.
5) Press the I key and insert a Location key frame.
6) Go to Frame 50. Set the X location to -7, the Y location to 0, and the Z location to 0.
7) Press the I key and insert a Location key frame.

8) Go to the Scene buttons (F10), and set the animation to 50 frames.
9) In the Format panel, set the animation type to your favorite. I used the compressed AVI format with the CamStudio Lossless Codec, version 1.4, for compression.
The video will be created in the Output directory (/tmp by default), with a filename of 0001_0050.avi. Set the output directory to the folder where you want the video to be saved. If you chose a QuickTime movie, the filename would be 0001_0050.mov.

10) Hit the ANIM button. I will pause the video while the animation is being rendered, as I will do for the other animations in this video. The render took 1 minute, 10 seconds.

The animation does indeed have the cube move back and forth, but the motion of the cube is not realistic. The cube just moves in a straight line uniformly, without the blurring effect of motion.

With the help of the Node editor, we can introduce vector blur to this animation and compare. To do this,

1) Go to the Render Layers tab of the Scene button. Vector blur takes a special Vector (VEC) rendering pass, which is not rendered by default. Find the VEC button and enable it. Vector Blur requires the COMBINED, Z, and VEC passes. The others you may need to render the scene exactly as you need it.

2) Change the 3D view to the Node Editor. Press Control-Down Arrow to maximize te Node Editor. Click on the face, for composite nodes. Then click the USE NODES button. There are two default nodes, the input node (Render Layers) is the scene as rendered without compositing. The other node, the Composite node, is the final result of the compositing process.

3) Move the Composite Node all the way to the right, to make room for the Vector Blur.

4) Add the Vector Blur filter (Space - Add - Filter - Vector Blur). Accept the defaults. Connect the Image socket of the Render Layer to the Image input of the Vector Blur node. Connect the Z socket of the Render Layer node to the Z socket of the Vector Blur node. The Z socket stores the Z information - the distance of the cube from the camera. Connect the Speed socket of the Render Layer node to the Speed socket of the Vector Blur node. The Speed socket is really the key to blurring the cube's movement. You can play with the defaults. Increasing the number of samples, for example, makes the vector blur more realistic but slows down the rendering. Also, you can control which moving objects are blurred. A speeding sports car should be blurred, but bystanders should not.

5) Connect the Image output socket of the Vector Blur node with the Image socket of the Composite node.

The noodle (the node setup) is complete. Go back to the Scene buttons and click the Do Composite button. Press the Render button. Look at Frame 1. The monkey is blurred.

6) Time to animate. Click the ANIM button. Pause until the 50 frames are rendered. The render took 1 minute, 47 seconds.
Now you see the cube blurred while it is moving --- a much more realistic animation. Think of a fast sports car speeding by you.

Blender has another way to implement blurring a moving object: the Motion Blur option. To demonstrate that, click the MBLUR button in the Scene panel. Turn off Do Composite because motion blur doesn't rely on nodes. MBLUR is very slow because it renders each frame up to 16 times. The number of samples is controlled by the OSA setting, which is 8 on my computer. Eight renders per frame is mighty slow. The renderer calculates the position of each object and then averages the positions out. It is more accurate than Vector Blur, but at the cost of a LOT of time. Here is the cube animation with motion blur.

To summarize, Blender provides you with two options, Vector Blur and Motion Blur, for making your moving object look more realistically blurred as the object moves in the scene. For most applications, especially in the Game Engine, Vector Blur will work well. Happy Blendering!