The Magical Art of Compositing in Blender

Blended in Blender

Apart from being a great 3D modeller and one of the best animation programs, Blender is also a great compositing program (since the release of Blender 2.37a and later, till the release of 2.58). This article covers compositing in Blender.

Compositing is the art of combining several images into a final image. In a 3D program, the artist often wants to combine a 3D element into several 2D elements, including the background and other scene elements. This is specially so when it comes to 3D movie making.

You might have created a character, and naturally would like the character to move in a suitable location and a conducive atmosphere. It is not always possible to create detailed 3D environments if one’s system lacks the resources (RAM) to handle such heavy scenes. In such cases, it is always advisable to use 2D backgrounds to give the illusion of a setting for your 3D character. With a great compositor like Blender, this becomes easy.

All compositing is carried out in the Node Editor of Blender.

The Node Editor window

The illustration in Figure 1, from Blender 2.45, shows the Node Editor. You access it via the Shift+F3 keyboard shortcut.

Node Editor

Figure 1: Node Editor

Pressing the ball icon activates the material nodes, whereas pressing the small button that appears like a face of a woman next to the ball-like icon brings up the option for editing the compositing nodes. You will notice that the default cube of the 3D view appears as a rendering node, along with the composite node attached to it. You could now click the entry button that says Use Nodes. Now you could edit the nodes by making input and output connections. Figure 2 shows the appearance of the nodes in the Node Editor.

Node Editor with nodes

Figure 2: Node Editor with nodes

Understanding compositing nodes, accessing optional sockets

Once you have activated the compositing nodes, you will find that only a few sockets are available to work upon — namely, the Image socket, Alpha socket and the Z socket. To activate optional sockets, we have to enable the other buttons found under the Render Layer menu, which you access via the F10 keyboard function key. Figure 3 shows the optional sockets available to make output connections.

Sockets

Figure 3: Sockets

The Render Layer node

This is the most significant node when you composite a 3D scene with a 2D background or video footage. This is precisely the node we are going to use in the exercise that follows. This node shows your 3D objects along with the image you have set up in the background, and enables the back buffer.

The compositing sockets in the render layer node are:

  • Z: distance away from the camera, in Blender units
  • Normal (Nor): How the colour is affected by light coming from the side
  • UV: How the image is distorted by the UV mapping
  • Speed (Vec): How fast the object is moving, and in what direction
  • Color (Col): The RGB values that colour the image that you see
  • Diffuse: The softening of colours as they diffuse through the materials
  • Specular: The degree of shininess added to colours as they shine in the light
  • Shadow: Shadows cast by objects onto other objects
  • AO: How the colours are affected by “ambient occlusion” in the world
  • Reflect (Ref): This is for mirror-type objects, showing the colours they reflect and are thus not part of their basic material
  • Refract: How colours are bent by passing through transparent objects
  • Radio (Radiosity): Colours that are emitted by other objects and cast onto the scene
  • IndexOB: A numeric ordinal (index) of each object in the scene, as seen by the camera

Setting up for Susan, the monkey

Let’s begin with setting up the background and base. Before starting to composite the 3D model, you have to set up a background image as the scene in which to place the model in. You would also need a plane that will help in casting real shadows on the floor of the background image.

Shift back to the 3D view by pressing Shift+F5. This will show you the default “Cube” again. Press 0 (zero) on the numeric pad to shift to the Camera view. Press X to delete the cube, and by pressing the space bar once, add Susan, the monkey’s head under Add –> Mesh –> Monkey. Shift to the top view (7 on the numeric pad) Add –> Mesh –> Plane by pressing the space bar. Adjust the plane after coming out of edit mode by pressing the TAB key.

Background image for Blender tutorial -- sdc11136.jpg

Background image for this Blender tutorial — sdc11136.jpg (click for full size)

Load the background image (sdc11136.jpg, shown above) by navigating to the background button under the View menu. Once the image is loaded, adjust the monkey along with the plane, to suit the angle at which the monkey’s head would stand upright on the table.

The purpose of the plane is to cast a shadow on the table. This will become apparent when we adjust the material parameters of the plane. After selecting the plane, press F6 to go to the material panel. Make a few adjustments like enabling the Ztransparency and only cast shadow buttons.

Figure 4 shows the adjustments we made to the material of the plane, which is to be the shadow of the monkey we place on the table in the picture. Render the scene by pressing F12. You will find only the monkey head with a shadow, and the background not rendering. Let us fix this in the next step.

Adjustment of shadow

Figure 4: Adjustment of shadow

Back-buffering and rendering

Press F10 to shift to the rendering panel. Enable back-buffering by loading the same image and pressing the back-buffer button. Figure 5 shows the back-buffer enabled.

Back-buffer enabled

Figure 5: Back-buffer enabled

Now render the scene by pressing F12. Magic! You will see the monkey head as a part of the table scene, casting appropriate shadows on the table. Figure 6 is the rendered figure of our composite image.

The composite image

Figure 6: The composite image

Adding a cloud texture for a better effect

This is where to use the render layer node, so that we can composite more effects in our image/scene. Go to the Node Editor (Shift+F3). You will observe the monkey with the table in the background.

Now go ahead and add a texture node by pressing the space bar and going to the Add menu, then to Input and to Texture. An empty texture node is added to the scene. Go down to the button window. Press F6 to bring up the texture buttons. From the drop-down menu, select cloud as the texture.Figure 7 shows the texture node added to the scene, along with the mix and composite nodes.

Addition of texture node

Figure 7: Addition of texture node

Revert to the node editor, and in the texture node, use up/down arrows to select the cloud texture you just enabled. Now, the fun begins!

We have to mix the two together to get a cloud blurring effect. Press the space bar and navigate to the Colour –> Mix node. We get a small node showing two input sockets for two images to be brought together. With the left mouse button, drag from the yellow colour socket of the image node to the image socket of the mix node. Connect the yellow image socket of the render layer node with the yellow socket found on the mix node. The result will not show up till you add the composite node.

Go ahead, press the space bar and navigate to Output –> Composite. The node naturally gets connected. Do a quick render. You will not observe any difference. Press F10 and enable the Do Composite button in the Rendering menu. Press F12 to render again. Wow! A beautiful cloud texture is added to your composition. You could play around with the values to get the best effect. Figure 8 shows you the cloud texture added to the image.

Image with cloud texture

Figure 8: Image with cloud texture

Apart from a cloud texture, you could experiment by adding other textures, images or even colour ramp nodes for a better composition. You could even do all the compositing functions offered by Photoshop or by After Effects.

Final words

There can be no final words about a great art. Compositing is one of the finest of arts if the science behind it is properly understood. The sky is the limit. The greater your hard work and artistic thinking, the better will be the results.

Feature image courtesy: Blender Foundation. Reused under the terms of CC-BY 3.0 License.
  • bkandiyal

    Great post. But, why are you using KDE3? :P

All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherwise noted.
Open Source For You is powered by WordPress, which gladly sits on top of a CentOS-based LEMP stack.

Creative Commons License.