You are on page 1of 53

Compositing and Rendering: Discussion

By Colin Litster

Discussion Exercise: A Steam Gauge

Although other chapters have contained a more academic discussion section, the compositor lends itself to
an extended example. Its usefulness comes not from individual settings, but from combining components
and practical understanding. If you are interested in a blow-by-blow rundown of Render settings, they can be
found in a third section to this chapter: Render Settings: Discussion.

This section, however, will show you how to approach the compositing process, as well as several common
compositing setups.

To do this, you'll become the compositing and rendering department of a virtual movie studio, tasked with
finishing a shot from the highly anticipated feature film, "Blender Hothouse." The modeling, texturing and
lighting have all been completed by other departments. Your job will be to devise the look and feel of the
scene by compositing its various elements into a completed 10 second animation without altering the
models, lighting or materials.

A steam gauge from the "movie" Blender Hothouse

From the screenplay:


An oily brass steam gauge within a dark steam room. The dial initially increases from zero to a quarter of its
travel as though steam pressure is rising. The dial hovers at this position, gradually becoming more agitated,
as though the pressure is about to blow. The dial then rapidly turns to maximum and shakes: pressure is at
its highest level and explosion is imminent...

The node network for this composite.

The Composite Node network for this exercise appears to be staggeringly complex. However, it can be
broken down into four distinct portions, each one covered here in depth. There are a number of files that will
help with this chapter, all found in the "examples" folder on the included CD. The first exercise will require
you to create the node network from scratch, but later ones will use pre-made files for you to examine and
play with.

Let’s start with the file as delivered to you from the production department. Load “CompositeStage1.blend”
and perform a test render (F12). If you find that the render takes longer than a couple of minutes, you may
want to consider working with the renderer set to 50% size in the Render buttons.
The file as provided.

If you examine the scene, you will see that some of the materials use raytracing. A simple textured plane
outside of the camera's view provides something for the dial's face to reflect.

Creating the Source Renders, Scenes and Components to Composite

Change the wide window at the top of the screen from a 3D view to a Node Editor. Switch to Composite
Nodes with the face icon on the header, and make sure the Use Nodes button is enabled.

The window on the left side of the screen shows the Render buttons. Both windows at the bottom have been
set to UV/Image Editors for showing Preview and Composite result nodes. You'll be focusing on the main
gauge for the majority of this discussion, so disable Layers 2 and 11 to hide the background and wall
elements.
Shift-LMB click on these two layer buttons.
A good setup to begin compositing.

When turning on Use Nodes for the first time, the default is to have a Render Layers node connected
directly to a Composite node. However, you are not limited to a single render input. It is possible to set up
different Render Layers, each with their own node input, pulling elements from various modeling layers and
scenes which can then be dealt with separately in the Compositor.

These controls are found in the Render Layers tab of the Render buttons, nested into the same panel as the
Output tab.
The Render Layers tab.

Render Layers

From this tab it is possible to control exactly what will be rendered, as well as what will be passed to the
compositor for processing. In short, a Render Layer is a selection of scene layers that will be rendered in a
single pass: a set of Layers that will be rendered together. Each Render Layer can have its own Input node,
allowing you to perform different composite operations on different sets of objects from your scene, as you'll
see later.

Let's look at the controls on the Render Layers tab:

Scene
Scene layer buttons

This refers to the set of layer buttons at the top of the panel. These controls are a duplicate of the layer
buttons found on the 3D view headers, and are included here as a convenience. As you will be indicating
which layers should be included with which render input in this same tab, it is nice to be able to check the
contents of layers without leaving the panel.

Below this is the name and selector for the active Render Layer. Like other name popups, new Render
Layers may be created by selecting Add New and may be removed by clicking the "X" to the right of the
control.

Layer

Figure RCD.05.2: Layer Layer buttons

Further down is the Layer control, which again shows the familiar layer selector. Unlike the one above,
which controls what displays in the 3D view, this selector is the one that determines which scene layers will
be included in this Render Layer. When a Render Layer is created, it defaults to including all scene layers.

Why would you need separate access to so many scenes and layers? You could, for example, divide a
scene between background and foreground objects, sending the background objects to the compositor in a
different Render Layer for blurring. It’s also possible to have part of your project in a completely different
Scene, allowing you to composite objects with completely different render settings.
A render composited from two scenes. The ocean scene used standard render settings, while the mine and
buoy scene used the Edge settings.

Render Process

RCD.05.3: Render process buttons

Below the Render Layer selector are toggles for which portions of the renderer to use. Blender treats
different types of objects in different ways, and each of these can be enabled or disabled here. For example,
if you were to turn off the Solid button, no objects with solid faces would be rendered, leaving only the
background.

The other buttons can be used to disable rendering of Halos, Edges, Transparent (zTra) objects and the Sky
background or BackBuffer image, on a Render Layer by Render Layer basis.

Just below the render process buttons are two text fields: Light and Mat. If the name of an object group is
entered in the Light field, the Render Layer will use lamps from that group, ignoring any other lamps in the
scene. A material name entered into the Mat field will cause all objects in the Render Layer to be rendered
as though they were temporarily linked to that material. These fields are useful for doing test renders and
special effects. For example, you might need to substitute a simplified lighting rig and material to test object
placement without actually replacing lamps and materials throughout your entire scene.

Render Passes

RCD.05.4: Render passes buttons

At the bottom of the Render Layers tab are the controls for render passes. As Blender renders an image, it
performs a number of calculations that are combined to deliver the final color of the rendered pixel. Render
Passes allow you access to each stage of these calculations individually from within the Compositor. For
instance, you could separate the Diffuse, Specular, and shadow calculations, and recombine them in the
compositor. By adjusting the way they mix, you could make the shadow darker or blur and lighten the
specular highlights. Using a work flow like this gives you the freedom to drastically improve and alter the
look of the final output without re-rending, potentially saving enormous amounts of time.
On new Render Layers, only two render passes are enabled:

- Combined, which delivers the final RGB and alpha results; and

- Z, the depth information of objects from the camera's viewpoint. Each pixel in a render has a Z value,
which refers to the distance between the camera and the face that was rendered. If you look in the Node
Editor, you will see that the Render Layers node has three outputs: RGB, Alpha and Z. These outputs
correspond directly to the Render Pass settings.

Enabling any of the other pass buttons adds additional outputs to the associated Render Layer node.

The other twelve passes are:

Vec: Provides vector motion data for the rendered geometry. Mostly useful for calculating fast, vector-based
motion blur.

Nor: Provides the Normal information from objects in the render layer. If looking at the output of this pass in
a Viewer node, the strange colors are the visual encoding of the Normal.

UV: The UV information from objects that have UV mapping. This pass makes it possible to replace the
colors on objects that use UV mapped textures, without re-rendering or changing the materials directly.

IndexOb: You can assign any object an index value in the Object buttons and use this to create selection
masks.

Col: Provides an un-shaded color pass, as though everything had been rendered with a Shadeless material.

Diff: The diffuse shading of objects, including colors, but without shadows or specular highlighting.

Spec: Specular shading.

Shad: A pass representing shadowing information. This pass is Multiplied with others to get a final image, so
non-shadowed areas appear in white, with shadowed areas being progressively darker.

AO: The result of Ambient Occlusion, without any materials applied.

Refl: The reflection pass, if Ray is enabled on the Render panel and an object has a reflective material.

Refr: Refraction, if Ray is enabled on the Render panel and an object uses ray refraction.

Rad: A radiosity pass. Radiosity is another method of lighting that is not covered in this book.

If you would like to see the actual outputs from any of these passes, it's as simple as connecting their output
sockets to a viewer node and re-rendering. Of course, if you already rendered after the different passes
were enabled, no re-render would be needed.
The Col, Diff, Spec and Shad passes.

Recombining Passes

For the first part of this exercise you will recombine the Diffuse and Specular passes to make the brass of
the gauge's body a little brighter and shinier.

You can either follow the simple instructions to set this up yourself, or if you prefer, load up the completed
stage for examination. The file "CompositeStage2.blend" can be found in the "examples" folder.

If you want the practice of building your own, here's what to do:

In the Render Layers tab of the Render buttons, enable the Diff and Spec passes.
Enabling the Diff and Spec passes.

Add a color Mix node (Add->Color->Mix), connecting the Render Layer node's Diff output socket to Mix's
upper image input and the Spec output to the bottom image input.

Create a View node with Add->Output->Viewer, and connect the output socket of the Mix node to the Viewer
node. If something was already connected to the Viewer node, that connection will automatically be replaced
by the new one you make.

NOTE: The nodes systems doesn’t like loops or ambiguity, and will frequently delete connections when you
replace them with others, or warn you of problems should they occur.

The Mix Node

The Mix node is one of the most frequently used and important nodes in the compositing system. It defines
how color passes or images from two separate inputs will be blended into a single output.
The available mixing methods.

A list of available mixing methods can be viewed by clicking the popup selector.

In this case, choose Screen.

Screen brightens an entire image, based on the image being mixed into it. Light areas brighten more, with
white turning the other image white. Dark areas brighten less, with black leaving the image unaffected.
The Specular pass.

The specular pass in the example is mostly black with some lighter areas, so it won't brighten the other
image much. We would like you to enhance the specularity, though, so you need a way to increase the
brightness of the Spec pass. It could be run through an RGB Curves node and adjusted, but there is an
easier way.

The Fac (Factor) spinner on the Mix node controls the strength of the bottom image in the mix. Values of 0
through 1 represent 0 to 100%. The mix factor can go as high as 5, though, meaning that you can mix the
Spec pass at 500% of its actual intensity.

Set the Fac spinner on the Mix node to 4.77.


The current node network.
Increased specularity following the Screen Mix node.

As you adjust the mixing Factor, the Viewer node updates without having to re-render.

The brass gauge now looks a lot shinier, but could still be better. To do that, you'll apply a common post-
process effect: bloom.

Bloom/Glow

Real highlights, such a specular reflection, tend to behave differently than mathematically calculated
highlights in a 3D package. Light intensity in the real world can cover a huge range that our eyes find difficult
to view. As a result, very strong highlights can cause our eyes to actually overload in certain places,
perceiving this dramatic contrast between light and dark as a kind of glow. Adding this subtle effect can
make a render look more authentic and is a simple way of adding believability without the extra processing
requirements of more complex raytracing algorithms.

Load the file "CompositeStage3.blend" from the "examples" folder. The nodes will appear empty until you
render (F12). Also, it's okay that the dial appears blank right now. The dial is seen through a refractive object
and won't show until you make use of the Refract pass later.
The Bloom Node network. Viewer nodes have been attached so you can easily examine the various stages.

As you can see from the node tree, we have collapsed some of the nodes from the previous section using
the controls described earlier. That should make it easier to focus your attention on the bloom effect. Once
you are happy with a section of a complex composite node tree, it is a good idea to collapse it like this to
keep clutter to a minimum.

Source of the Bloom

Although there are several ways to produce a bloom effect, the simple approach we've taken is to use the
Specular pass again, brightening it and applying some blur before mixing it back into the existing image.

Using RGB Curves to Brighten an Image

The network uses an RGB Curves node, taking its input from the same specular pass you used before. In
the basic back-shadowing tutorial, you used the RGB Curves node to invert and colorize an image. Here it is
used to brighten the Spec pass by drawing the top right point of the Combined curve over three quarters of
the way to the left.
Here's a neat trick: enable the "Backdrop" button on the Node Editor's header. Now, clicking on a Viewer
node shows that preview right in the background of the Node Editor. This is particularly useful if you are
working with your nodes in a Maximized window (Ctrl-Up Arrow/Down Arrow), or if there is no room in your
screen layout for a UV/Image Editor window. The backdrop preview may be moved around with Shift-MMB.
Backdrop enabled on the header. This preview shows the result of the RGB Curves node on the Spec pass.

Blurring an Image

After the RGB Curves node, you have a Blur node, which can be found under Add->Filter->Blur.
The Blur node with settings for the bloom effect.

Although there are seven different blurring styles to choose from, two of the most commonly used are Gauss
and Mitch.

Gauss

Gaussian is a good, general purpose blur. It provides an even effect across the image.

Mitch

Mitchell-Netravali blur gives a more accurate effect for bright objects. It does not reduce highlights by evenly
spreading them like Gaussian blur. Because of that, this type of blur is excellent for working with highlights,
as you are here.

Of course, other blur methods like CatRom will produce similar effects, so the choice is yours. With the
speed of the Compositor, it's easy to switch between different blur methods to see which works best in your
final production.

Blur Settings

In the previous illustration, the Blur node's X and Y values are set to 35. Above the X and Y settings are two
buttons that, although not used here, are worth explaining.
Bokeh

This is a more complex blur setting that attempts to simulate optical blurring, the kind that would happen with
an out-of-focus camera, as opposed to the simple mathematical blurring of other methods. This setting will
slow renders and composite updates considerably, but when attempting to fake a camera blur effect, it is
much more realistic.

Gamma

This setting will give bright parts of the blur precedence over darker portions, instead of averaging them.
This will usually lead to a brighter blur.

Using the Mix node in Screen mode again.

Mixing the Bloom Effect

You need to mix this brightened and blurred image with the results of the diffuse and specular combination
from earlier. Notice how the title of the Mix node has changed to "Screen," making it easier to tell the mix
type at a glance, even on a collapsed node.
A new Mix node, in Screen mode.

We have used a Screen Mix node (Add->Color->Mix), as once again you have to blend an image that needs
to brighten another. In this case, the Factor has been adjusted to 0.37, but try taking it as high as 0.80 to see
if you like it better.

Reflection/Refraction Adjustment

So far, you have improved the look of the metal and added a nice bloom to the highlights. You're still missing
the reflection and refraction, though.

Load “CompositeStage4.blend” from the disk and render to fill all the buffers and passes.
The additional nodes for reflection and refraction.

You have both a reflection and refraction pass available because the brass material uses raytraced
reflections and the glass dial uses raytraced refraction. To see what these passes produce, follow the
connectors to their associated viewer nodes and select each in turn.
The reflection pass.
The refraction pass.

Neither is much to look at in this state, but there is a lot of information hidden in these apparently dark
passes.

You need to properly mix these passes with the output from your previous compositing result. To do this,
you'll need to use another Mix node.
The Mix node in Add mode.

The Add Mix node's lower Image socket receives its input from the Refract socket the whole way back on
the Render Layers node. This makes it the "primary" image — the one being layered over your previous
Diffuse/Spec/Bloom network result.

Setting the Factor to 0.50 means that the Refraction pass is only used at half-strength, de-saturating the
dial. This is actually ideal, because if mixed at full strength (1.0), the reflection pass would not be visible. Try
setting the Add Mix Factor to 1.0 and see what it does to the final composited image. Once you've done that,
change it back to 0.5. This is a great example of how using the Compositor can improve an image without
re-rendering.

Modifying a Pass Before Recombining

One of the down sides of using raytraced reflections is that they are razor-sharp. In the real world, unless a
reflection comes from a polished mirror, it will have some degree of blur. If you were not using the
Compositor, the only way to accomplish blur in a reflection would be to use high Filter settings with Env
Maps (see Chapter 9). By now, though, you should be able to see a simple solution to this problem.

Examine the Blur node that is connected to the Reflect output of the Render Layers node. It uses the Mitch
blurring method and only a small value, 4, for X and Y.
The Blur node set to affect the Reflection pass.

The blurred Reflection pass is then composited with the Diffuse/Specular/Bloom/Refraction result with a Mix
node in Add mode, set to 0.84.

Varying this factor will increase or decrease the amount of reflection and apparent oily film on the brass.
Experimentation is the key, and you are encouraged to modify any of these factors to see how it affects the
composite.
The render with reflection and refraction passes added.

Adding the Shadow Pass and Color Correcting the Image

Load the file "CompositeStage5.blend" and render to fill the passes.

The final pass to recombine is the shadows.


A Mix Multiply node to blend the shadow pass into the rest of the image.

Mixing the shadow pass is relatively straight forward. It uses a Mix node set to Multiply, with a Factor of 1.0.
The lower input socket runs the whole way back to the Shadow output of the Render Layers node. The
upper input socket connects to the previous Add Mix node that is producing the final composite.

Multiply mode is the opposite of Screen. When multiplied, black turns the underlying image black, while
white leaves it untouched. As you can see in the next illustration, areas not in shadow on the shadow pass
are white, so they will not affect the final image when blended in Multiply mode.
The shadow pass.

Screen and Multiply offer superb after-render control of both shadowing and highlights. If you like, increase
or decrease the Mix Factor to change the way the shadow blends into the final image.

Color Correction

As it is, the final composite looks a bit milky. Let's raise its contrast with an RGB Curves node.

Although the RGB Curves node was used in the basic tutorial to completely change the color of the drop
shadow, it can be used for more subtle effects too. One of those is enhancing contrast. In fact, this
technique is so common and useful that it has its own name in the world of image processing: the "S Curve."
The Contrast S Curve.

As you can see, it’s a subtle alteration to the default diagonal line, but when applied to an image it can
significantly enhance its appeal. It works by darkening the already dark areas (pulling down the bottom left of
the curve) and brightening already light areas (pushing up the upper right of the curve), while leaving the
middle areas alone.
A detail of the final rendered, sweetened image.

Even though you have split apart the different passes, tweaked them and put them back together into a
much better image, there is more you can do. Currently, the gauge just floats on a black background, rather
than existing as part of a steam room.

Adding a Background with Render Layers

Load the file "CompositeStage6.blend" and render to fill the passes. You will notice that the two layers with
additional objects, Layers 2 and 11, have been re-enabled.
The node network to composite the layers with different settings.

With the other layers showing, the gauge now rests against a simple plane, textured with an altered copy of
the brass material, and given a custom paint job to show oil staining with the Image painting tools. Also, a
bunch of duplicates of the gauge appear in the background, attached to a wall. The main gauge's wall is on
Layer 11. The gauges and wall in the distance are all set to Layer 2.

The node setup in this file uses two separate Render Layers: one for the foreground gauge you have been
dealing with up until now and its wall, and a separate one for the distant background elements. Having the
background appear on a separate Render Layer will let you perform a completely different set of composite
effects to those objects.
Render Layer settings for the foreground.
Render Layer settings for the background.

Notice that the bottom set of Layer buttons for the "1 Render Layer" layer only includes objects from scene
Layers 1 and 11. The Layer buttons for the "Background" layer include objects from scene Layer 2.

Looking at the node network, a new Render Layer node has been created with Add->Input->Render Layers,
and set to use the "Background" render layer at the bottom of the panel. As you will only be darkening and
blurring this layer, you can stick with the default "Combined" pass.
The "Background" Render Layer node.

Immediately after the "Background" Render Layer, we have added an RGB Curves node to darken and
reduce the contrast of the render. Contrast can be reduced by performing the opposite of the "S Curve" —
darkening the light areas and brightening the shadows.

Before putting both layers together, though, you can use an old trick to help bring out the foreground objects.

Quick and Dirty Depth of Field

A simple blur applied to the background makes it look as though the camera lens is focused on the gauge.
The Blur node for the background.

A Gaussian blur has been applied with X and Y settings of 5. We have used the Gamma button to
emphasize the bright parts of the image, ensuring that the out-of-focus dials remain visible. Also, as we're
pretending that the background is blurred due to camera focus, it might be worth it to use the Bokeh option.
The blurred, darkened background layer.

The combination of the steam gauge with the background can be accomplished, once again, with the Mix
node. This time, however, you will use the default Mix mode. How can you get the node to not blend the
entire area of the images together, though? As you've already learned, adjusting the Factor affects how
much of the image from the lower input socket is composited over the other. In addition to just being a
number, though, the Factor setting can also use an image as its input.

By connecting the Alpha pass from the original Render Layers node, portions of the image that were
completely opaque (the gauge itself) receive a Factor setting of 1.0, while the non-rendered areas receive a
Factor of 0.0. The result is that the Alpha pass is used as a mask for the Mix node.
The Alpha Channel from Render Layer 1.
Mixing the background with the rendered element.
The rendered, composited image with background.

Before you finish, you'll look at one more excellent use of the Compositor, one that's suited to animation but
that can also enhance single-frame renders.

Vector-Based Motion Blur

Load the file "CompositeStage7.blend" and render to fill the passes.


The node network for compositing the spinning pointer.

With this file, you will produce the animation. However, as the only thing that moves is the pointer on the
gauge's face, it would be a waste of time to render the entire image once for each frame. The animation for
this piece is 250 frames long, and each frame takes, on the computer used for this discussion, almost a
minute to render. That is almost four hours of render time. If you use a single minute-long render to produce
a background, then render only the pointer as it spins, you can reduce the per-frame render time to around
two seconds, saving nearly three hours and fifty minutes of render time!

In this new file, you will see that only three objects exist: the pointer and the main body and face of the
gauge. You will only use the render of the pointer when you make the final composite, but the shape of the
gauge itself will be useful too.

When producing an effect like this, you will need to have already rendered the rest of the image, without the
animated portions, to use as a background. We have already done that in the example file, bringing the
image into the Compositor with an Image node found in Add->Input->Image.

Also, the only 3D objects left in the file are the pointer itself, the main gauge body and face, and the lamps. If
you had wanted, you could have simply moved the extra objects to a disabled layer.

Blender has two methods of producing motion Blur. The older method, available with the "MBLUR" toggle in
the Render buttons, relied on rendering an entire scene several times on fractional frame numbers, then
combining the results. Of course, this came at the cost of having to render your whole scene up to sixteen
times per frame. Vector-based Motion Blur, on the other hand, uses the Compositor to examine how the
objects in a scene are moving, then builds a new image with moving objects smeared along their trajectories
and blended into the scene.
The Vector Blur node.

Vector Blur is found under Add->Filter->Vector Blur. To make it work, you will need to have some sort of
image to blur (either a Combined pass or a composited image), and the Z and Vec passes enabled in the
Render Layers tab of the Render buttons. In this example, all three input sockets connect directly to their
output counterparts on the "1 Render Layer" node.
The pointer blurred on Frame 189, before compositing.

Obviously, objects will need to be in motion on the rendered frame for Vector Blur to have any effect.

Note: As you need a good Alpha channel with which to composite, remember to switch the Renderer from
Sky to Key mode on the Render tab.
Key mode on the Render tab.

Completing the Shot

To finish this example, the dial needs to be mixed back over the background image.
The Alpha Over node.

When compositing an image with built-in Alpha (a render of a lone object like the pointer), the AlphaOver
node does the job. AlphaOver is found in Add->Color->Alpha Over. It follows the same socket stacking rules
as the other nodes, with the base image in the upper socket and the image with Alpha in the lower socket.

In the example, the saved image of the gauge is used as a backdrop in the top Image input, while the
vector-blurred pointer with built-in Alpha fills the bottom Image input. You can see from the final composite,
though, that something is wrong.
Composite with the pointer sticking out.

One last trick, then, to properly mask the pointer. This is why you still have the gauge body and face hanging
around.

In this file, both the gauge body and face have been placed on Layer 2, and a separate Render Layer
created for them called "Gauge Body." With the body itself selected, it has been assigned an Object Index
by using the "PassIndex" spinner on the Objects and Links panel of the Object buttons (F7).
The PassIndex of the body set to 1.

In the Render Layer settings for the "Gauge Body" layer, you can see that all passes have been disabled
with the exception of the IndexOb pass. You don't need to care about colors, materials or shading here: you
want a pass that will generate a mask of this object to use on the pointer. The PassIndex value of all objects
defaults to 0 unless changed by you. By assigning a PassIndex of 1 to the gauge body in the Object buttons,
you will be able to single it out in the Compositor.
The node network to build a mask from an Object Index pass.

The IndexOb pass from the Gauge Body Render Layer (note how with no Combined pass sent, there is no
image at all in the preview) is connected to an ID Mask node, from Add->Converter->ID Mask.

The ID value in the ID Mask node is set to 1, to correspond with the value you set on the 3D object. After
that, an RGB Curves node is used to invert the resulting mask. That image fills in the Factor input socket on
the AlphaOver node, correctly masking the spinning pointer and completing your shot.
The final shot, correctly composited with the animated blurred spinner.

Getting the Shot Out of Your Department

So, you’ve finally finished the job. The managers who have been planning the production had allocated five
hours to your department on this shot for rendering and sweetening. Because you’re a pro with the
Compositor, you were able to set up the nodes in only a half hour (perfectly reasonable once you’re
experienced), and rendered the finished animation frames before the rest of the first hour was up.

Have a sandwich. Grab some coffee. You’ve earned it.

Well, the Compositor’s earned it, but you can take the credit.