Chapter 12. Rendering for Compositing

Maya offers a number of options for separating the individual elements of a render into separate passes. These passes can then be reassembled and processed with additional effects using compositing software, such as Adobe After Effects or Autodesk Toxic. In this chapter, you'll learn how to use Maya's Render Layers and mental ray's Render Passes features to split rendered images into elements that can then be used in your compositing software.

In this chapter you will learn to:

  • Use render layers

  • Use render passes

  • Perform batch renders

  • Use mental ray quality settings

Render Layers

The Render Layers feature is best used to isolate geometry, shaders, and lighting to create different versions of the same animation. Render Layers can be used to create a balance between efficiency and flexibility.

If you've used Render Layers in previous versions of Maya, you'll find that much has been changed in Maya 2009. Render Layers now offers the ability to create multiple render passes for each individual layer. This means it is no longer necessary to create separate render layers for ambient occlusion, reflection, beauty, shadows, and so on. Instead these separate renders can be created for each layer using Render Passes. Render Passes is discussed later in this chapter. To avoid confusion, it's best to forget what you know about Render Layers and start over from the beginning.

There is an enormous amount of creative flexibility using Render Layers. This chapter explains the more typical workflow; however, you may develop your own way of using Render Layers over time.

Render layers are created and managed using the Render Layer Editor. This is found in the Layer Editor in the lower-right corner of the default interface layout, just below the Channel Box. The Layer Editor has three modes: display, animation, and render. You change the mode by clicking one of the radio buttons at the top of the Layer Editor. These are the three types of layers you can create in Maya. Figure 12.1 shows the Layer Editor in render mode. The example shows a scene that has two custom render layers and the default render layer.

The Render Layer Editor is a mode of the Layer Editor found below the Channel Box on the lower right of the default interface.

Figure 12.1. The Render Layer Editor is a mode of the Layer Editor found below the Channel Box on the lower right of the default interface.

By default, every Maya scene has at least one render layer labeled masterLayer. All the lights and geometry of the scene are included in the master layer. When you create a new render layer, you can specify precisely which lights and objects are included in that layer. As you add additional render layers, you can create alternate lights for each layer, use different shaders on each piece of geometry, render one layer using mental ray and another using Maya Software, use indirect lighting effects on one layer and not on another, and so on. A render layer can be rendered using any camera, or you can specify which camera renders which layer. In this section, you'll use many of these techniques to render different versions of the same scene.

Creating Render Layers

In this exercise, you'll render Anthony Honn's vehicle model in a studio environment and in an outdoor setting. Furthermore, the car is rendered using a different shader on the body for each layer. The first step is to create a new render layer for the scene.

  1. Open the carComposite_v01.ma scene from the chapter12scenes directory on the DVD. Open the Render View window, and create a test render using the renderCam camera. It may take a minute or so to create the render (Figure 12.2).

    The carComposite _v01.ma scene shows a typical studio lighting and shading arrangement for the car.

    Figure 12.2. The carComposite _v01.ma scene shows a typical studio lighting and shading arrangement for the car.

    The scene is set up in a studio environment. The lighting consists of two point lights that have mental ray Physical Light shaders applied. These lights create the shadows and are reflected in the body of the car. An Area light and a Directional light are used as simple fill lights.

    The car itself uses several MIA materials for the metallic, glass, chrome, and rubber parts. The body uses a shading network that combines the mib_glossy_reflection shader and a mi_metallic_paint_x shader. An HDRI image is used to create some reflections on the surface. The HDRI image is mapped to an mib_lookup_sphere node. This same texture is used to create reflections on some of the other metallic parts.

    The shader used for the car body is named blueCarBody. You can select it in the Hypershade and graph the input and output connections in the Work Area to see how the shader is arranged (select the shader in the Hypershade and choose Graph

    Cheating Reflections
    The blueCarBody shader is graphed in the Work Area of the Hypershade.

    Figure 12.3. The blueCarBody shader is graphed in the Work Area of the Hypershade.

    The renderCam camera has a lens shader applied to correct the exposure of the image. As you learned in Chapter 10, MIA materials and physical lights are physically accurate, which means their range of values does not always look correct when displayed on a computer screen. The mia_exposure_simple lens shader is applied to the camera to make sure the scene looks acceptable when rendered.

    To create two alternative versions of the scene, you'll want to use two separate render layers. The first render layer will look exactly like the current scene; the second render layer will use a different shader for the car body and the Physical Sky and Sun network to create the look of outdoor lighting. Generally when you start to add render layers, the master layer is not rendered; only the layers that you add to the scene are used for rendering.

  2. Set the Layer Editor mode to Render.

  3. You can quickly add all the scene elements to a new layer by simply copying the layer. Select the masterLayer label in the Layer Editor, right-click, and choose Copy Layer. This creates a duplicate of the layer in the editor using all the same settings. See Figure 12.4, left image.

  4. In the Layer Editor, double-click on the label for the new layer and rename it studioLighting. This is shown in the second image from the left in Figure 12.4.

  5. In the menu bar for the Render Layer Editor, select Options and make sure Render All Layers is not activated (click on this option until the check mark disappears). This is shown in the second image from the right in Figure 12.4.

    Right now you're interested in rendering only a single layer at a time. If this option is on, Maya will render all the layers each time you create a test render in the render view.

  6. Click on the blue sphere and cube icon to the left of the masterLayer label so a red X appears. This deactivates this render layer so it is not renderable. This is shown in the right image in Figure 12.4.

  7. Select the studioLighting layer in the Layer Editor so it is highlighted in blue. Open the Render View window and create a test render using the renderCam camera. It should look exactly the same as the render from step 1.

    Graph the blueCar-Body shader in the Work Area of the Hypershade, then copy masterLayer (top left image) and rename it studioLighting (top right). Deactivate the Render All Layers option (bottom left), and turn off the masterLayer render option (bottom right).

    Figure 12.4. Graph the blueCar-Body shader in the Work Area of the Hypershade, then copy masterLayer (top left image) and rename it studioLighting (top right). Deactivate the Render All Layers option (bottom left), and turn off the masterLayer render option (bottom right).

    Copying a layer is a fast and easy way to create a render layer. You can also create an empty layer by choosing Create Empty Layer from the Layers menu in the Render Layer Editor. You can then select objects in the scene, right-click on the new layer, and choose Add Selected Objects from the pop-up menu. Another way to create a new layer is to select objects in the scene and choose Create Layer From Selected from the layers Menu. A new render layer containing all of the selected objects is created.

    You can add new objects at any time by right-clicking on the render layer and choosing Add Selected Objects. Likewise, objects can be removed by selecting the objects and choosing Remove Selected Objects. You can delete a render layer by right-clicking on the layer and choosing Delete Layer. This does not delete the objects, lights, or shaders in the scene, just the layer itself.

  8. Save the scene as carComposite_v02.ma. To see a version of the scene to this point, open the carComposite_v02.ma scene from the chapter12scenes directory on the DVD.

An object's visibility can be on for one render layer and off for another. Likewise, if an object is on a display layer and a render layer, the display layer's visibility affects whether or not the object is visible in the render layer. This is easy to forget, and you may find yourself unable to figure out why an object that has been added to a render layer is not visible. Remember to double-check the settings in the Display Layer Editor if you can't see a particular object.

You can use the Relationship Editor to see which layers an object belongs to. Choose Window

Graph the blueCar-Body shader in the Work Area of the Hypershade, then copy masterLayer (top left image) and rename it studioLighting (top right). Deactivate the Render All Layers option (bottom left), and turn off the masterLayer render option (bottom right).

Render Layer Overrides

To create a different lighting and shading setup for a second layer, you'll use Render Layer Overrides. An override changes an attribute for a specific layer. So, for example, if you wanted Final Gathering to calculate on one layer but not another, you would create an override in the Render Settings window from the Final Gathering attribute. To create an override, right-click next to an attribute and choose Create Layer Override. As long as you are working in a particular layer that has an override enabled for an attribute, you'll see the label of the attribute highlighted in orange. Settings created in the master layer apply to all other layers unless there is an override.

This next section shows how to use overrides as you create a new layer for the outdoor lighting of the car.

  1. Continue with the scene from the previous section or open the carComposite_v02.ma scene from the chapter12scenes directory on the DVD.

  2. In the Outliner, select the Vehicle group. Shift+click the ground object. In the Render Layer Editor, choose Layers

    Render Layer Overrides
  3. Select the new layer so it is highlighted in blue, and rename it outDoorLighting.

    If a group such as the Vehicle group is added to a render layer, all of its children are part of that layer. If you want to add just a part, such as the wheels, select the geometry (or subgroup) and add that to the render layer rather than the entire group.

    Currently this layer has no lighting, so if you render it the layer will appear dark (the default light in the render settings is off). That's fine because at this point you want to create a Physical Sky and Sun network for this layer.

  4. Make sure the outDoorLighting layer is selected in the Render Layer Editor. This ensures that you are currently in this layer and that any changes you make to the lighting or shading will appear in this layer.

  5. Click the small clapboard icon just to the left of the outDoorLighting label. This opens the render settings for this layer.

    In the Render Settings window, you'll notice outDoorLighting is selected in the Render Layer menu at the top. You can use this menu to switch between settings for the different layers.

  6. Switch to the Indirect Lighting tab, and click the Create button for the Physical Sun and Sky.

    This button creates a series of nodes including the Sun Direction light, the Physical Sky node, and a mia_exposure lens shader for all the lights in the scene. It also enables Final Gathering in the Render Settings window.

  7. In the Render Settings window, RMB-click over the label Final Gathering and choose Create Layer Override (Figure 12.5). You'll see that Final Gathering turns orange, letting you know this setting has an override for the current layer (outDoorLighting).

    Create a layer override for Final Gathering in the Render Settings window for the outDoor-Lighting layer.

    Figure 12.5. Create a layer override for Final Gathering in the Render Settings window for the outDoor-Lighting layer.

  8. You want Final Gathering only for the outDoorLighting layer. In the Render Settings window, select masterLayer from the Render Layer drop-down menu. Turn off Final Gathering while this layer is selected.

  9. Select the studioLighting layer from the Render Layer menu in the Render Settings window. Final Gathering should now be off for this layer as well. Select outDoorLighting, and you'll see that Final Gathering is enabled and the label is still orange.

    This is the basic workflow for creating a render layer override. How do you know which settings can be overridden? Most attributes related to lighting and shading can be overridden on most nodes. You can always right-click next to the attribute layer and see if the Create Layer Override setting is available.

  10. In the Render View window, create a test render, but make sure outDoorLighting is still the selected render layer. The render will take four or five minutes (depending on your computer's speed and available RAM).

    The render is obviously quite different from the render created for the studioLighting layer (Figure 12.6).

  11. Store the render in the Render View window (from the File menu in the Render View window choose Keep Image In Render View). In the Render Layer Editor, select the studioLighting layer and create another test render.

    The lighting in the outDoorLighting layer is very different from the lighting in the studioLighting layer.

    Figure 12.6. The lighting in the outDoorLighting layer is very different from the lighting in the studioLighting layer.

    Something has gone wrong because the lighting has changed for this layer. Final Gathering is not calculating, but you'll see that the render takes a long time and the lighting no longer matches the original studioLighting render. The reason for this is not because of render layers per se but because of the Physical Sun and Sky network that was added to the scene. Remember from Chapter 9, when you add a Physical Sun and Sky network, a number of nodes are added to the scene, including the renderable cameras. Normally this feature saves time and work, but in this case it's working against the scene.

    The easiest way to fix the problem is to create a duplicate render camera. One camera can be used to render the studioLighting layer; the other can be used to render the outDoorLighting layer. You can make sure that the correct lens shaders are applied to both cameras. You can use overrides to specify which camera is available from which layer.

  12. Select the renderCam camera in the Outliner. Rename it outdoorCam.

  13. Duplicate outdoorCam and rename the duplicate studioCam. Open the Attribute Editor for studioCam. Switch to the studioCamShape tab and expand the mental ray section.

    You'll see there are no lens or environment shaders attached to the studioCam camera. If you switch to the outdoorCam camera, you'll see the mia_physicalsky1 shader in the Environment Shader slot and the mia_exposure_simple2 shader in the Lens Shader slot. The original renderCam camera had a mia_exposure_simple1 node in the Lens Shader slot, but this was replaced by mia_exposure_simple2 when the Physical Sun and Sky network was added to the scene. The solution here is to reattach the mia_exposure_simple1 node to the lens shader of studioCam.

  14. Open the Hypershade window and switch to the Utilities tab. MMB-drag mia_exposure_simple1 (you can see the full name if you hold the cursor over the icon) down to the Lens Shader slot for studioCam (Figure 12.7).

  15. In the Hypershade, select the mia_physicalsky1 node from the Utilities tab, and open its Attribute Editor to the mia_physicalsky1 tab. Right-click next to the On attribute and choose Create Layer Override. The attribute label should turn orange.

  16. After adding the override, deselect the checkbox for this attribute to turn it off for this layer.

    Attach the mia_exposure_simple1 node to the Lens Shader slot of studioCam.

    Figure 12.7. Attach the mia_exposure_simple1 node to the Lens Shader slot of studioCam.

  17. Create a test render in the Render View window, and make sure that studioCam is chosen as the rendering camera. The render now looks like it did at the start of the section.

  18. Save the scene as carComposite_v03.ma. To see a version of the scene to this point, open the carComposite_v03.ma scene from the chapter12scenes directory on the DVD.

Creating Overrides for Rendering Cameras

Notice that you do not need to add cameras to render layers when you add them to a scene. You can if you want, but it makes no difference. The cameras that render the scene are listed in the Common tab of the Render Settings window.

If you're rendering an animated sequence using two cameras with different settings as in the carComposite example, you'll want to use overrides so you don't render more images than you need.

  1. Continue with the scene from the previous section or open the carComposite_v03.ma scene from the chapter12scenes directory on the DVD.

  2. Open the Render Settings window. Set the Render Layer menu at the top of the Render Settings window to studioLighting.

  3. Switch to the Common tab and expand the Renderable Cameras section.

  4. Use the Renderable Camera menu to choose the studioCam camera. Right-click next to the menu and choose Create Layer Override (Figure 12.8).

  5. Set the Render Layer drop-down at the top of the Render Settings window to outDoorLighting.

  6. From the Renderable Camera menu choose outdoorCam. Right-click next to the menu and choose Create Layer Override (in some cases Maya may create the override for you if you already have an override for the same setting on another layer).

  7. Switch between the studioLighting layer and the outDoorLighting layer, and make sure the correct camera is selected for each layer.

  8. Save the scene as carComposite_v04.ma. To see a version of the scene to this point, open the carComposite_v04.ma scene from the chapter12scenes directory on the DVD.

After creating the overrides for the cameras, it is still possible to render with either camera in the render view. The overrides ensure the correct camera is used for each layer during a batch render.

Create a layer override for the rendering camera on the studioLighting layer.

Figure 12.8. Create a layer override for the rendering camera on the studioLighting layer.

Using Different Shaders on Render Layers

The flexibility of render layers becomes even more apparent when you apply different shaders to the same object on different layers. This allows you to render alternate versions of the same animation.

  1. Continue with the scene from the previous section or open the carComposite_v04.ma scene from the chapter12scenes directory on the DVD.

  2. In the Render Layer Editor, select the outDoorLighting layer. Open the Hypershade.

  3. In the Outliner, expand the Vehicle group and select the carBody subgroup (Figure 12.9).

  4. In the Hypershade, find the stripedCarBody shader (its icon is the same as for the mib_glossy_reflection shader). Right-click on the shader and choose Assign Material To Selected Objects.

    Apply the striped-CarBody shader to the carBody group.

    Figure 12.9. Apply the striped-CarBody shader to the carBody group.

    This shader uses a projected texture map to color the surfaces in the carBody group. The projection node is already placed in the carBody group.

  5. With the outDoorLighting render layer selected, create a test render in the Render View window. Make sure the outdoorCam camera is selected as the rendering camera (Figure 12.10).

    The outDoorLighting layer uses a different shader to color the body of the car.

    Figure 12.10. The outDoorLighting layer uses a different shader to color the body of the car.

    The car renders with a different material applied to the body. If you render the studioLighting layer (using the studioCam camera), you'll see the car is still blue. The new shader appears only when the outDoorLighting layer is rendered.

    You don't need to create overrides to apply different materials on different render layers; however, you can create overrides for the attributes of render nodes used on different layers (for instance, one shader could have different transparency values on different render layers).

    Shaders applied to the components of a surface, such as selected polygon faces, can differ from one render layer to the next.

  6. Save the scene as carComposite_v05.ma. To see a finished version of the scene, open the carComposite_v05.ma scene from the chapter12scenes directory on the DVD.

Material Overrides

A material override applies a material to all of the objects within a particular layer. To create a material override, right-click on one of the layers in the Render Layer Editor and choose Overrides

Material Overrides

Render Layer Blend Modes

Render layers can use blend modes, which combine the results of the render to form a composite. You can preview the composite in the Render View window. Typically you render each layer separately, import the render sequences into compositing software (such as Adobe After Effects or Autodesk Toxic), and then apply the blend modes using the controls in the compositing software. Maya gives you the option of creating a very simple composite using render layers, which you can view in the Render View window.

Blend modes use simple algorithms to combine the numeric color values of each pixel to create a composite. A composite is created by layering two or more images on top of each other. The image on top is blended with the image below. If both images are rendered as Normal, then the top image covers the bottom image completely. If the blend mode is set to Multiply, then the light pixels in the top image are transparent and the darker pixels of the top image darken the pixels in the bottom image. This technique is often used to add shadowing to a composite. If the blend mode of the top image is set to Screen, then the darker pixels are transparent and the lighter pixels brighten the pixels of the lower image. You can use this to composite glowing effects.

The blend modes available in Maya are Lighten, Darken, Multiply, Screen, and Overlay:

Lighten

This mode compares the layered images and uses the lightest pixel value of the two layers to determine the resulting color. For example, the lower image has a pixel in a particular spot with an RGB value of 0, 125, 255, and the pixel at the same location in the top image has an RGB value of 0, 115, 235. The resulting RGB value for that pixel will be 0, 125, 255.

Darken

This is the opposite of Lighten, and the darker value is used. In the example cited previously, the resulting RGB value for the pixel would be 0, 115, 235.

Multiply

The pixel values of the top image are multiplied by the pixel values of the bottom image and then divided by 255 to keep the values within the range of 0 to 255. The lighter pixels in the top image are semitransparent, and the darker values of the top image result in a darkening of the lower image.

Screen

A slightly more complex algorithm is used for this mode. The formula is 255-[(255-top color RGB pixel value)*(255-bottom color RGB pixel value)/255]= blended RGB pixel value. This has the effect of making darker pixels in the top image semitransparent and lighter, resulting in a lightening of the lower image.

Overlay

This combines Multiply and Screen modes so the lighter pixels of the top image brighten the bottom image and the darker pixels of the top image darken the bottom image.

In this exercise, you'll use blending modes to create soft shadows for the render of the car in the studio lighting scenario.

  1. Open the carComposite_v06.ma scene from the chapter12scenes directory on the DVD.

    This scene shows the car in the studio lighting scenario. A single render layer exists already. Using the technique in this exercise, you'll eliminate the harsh cast shadows that appear on the ground in the rendered image (see Figure 12.2) and replace them with soft shadows created using ambient occlusion. First you'll remove the shadows cast on the ground by the physical lights in the scene (note that physical lights always cast shadows; there is no option for turning shadows off when you use these lights).

  2. Select the ground object in the Outliner. Open its Attribute Editor and switch to the groundShape tab. Expand the Render Stats section in the Attribute Editor and deactivate Receive Shadows (see Figure 12.11). Note that, for some attributes, changing a setting on a render layer automatically creates a layer override.

    Disable Receive Shadows for the ground surface.

    Figure 12.11. Disable Receive Shadows for the ground surface.

  3. In the Options menu of the Render Layer Editor, deactivate Render All Layers. Select the studioLighting layer, and create a test render in the Render View window using the renderCam camera (see Figure 12.12).

  4. In the Outliner, Shift+click the vehicle group and the ground surface. In the Render Layer Editor, choose Layers

    Disable Receive Shadows for the ground surface.
  5. Open the Hypershade window. Make sure the AOShadow layer is selected in the Render Layer Editor. Create two new surface shaders in the Hypershade (from the Hypershade menu bar choose Create

    Disable Receive Shadows for the ground surface.
  6. Name one of the surface shaders shadowShader and the other whiteMask.

    In this version of the render the ground does not receive cast shadows from the car.

    Figure 12.12. In this version of the render the ground does not receive cast shadows from the car.

  7. In the Outliner, select the vehicle group and apply the whiteMask shader to this group. Select the ground object and apply the shadowShader to this surface.

  8. Open the Attribute Editor for the whiteMask node, and set Out Color to white.

  9. Open the Attribute Editor for the shadowShader. Click the checkered box to the right of Out Color. Switch to the mental ray tab, and from the Textures section click Mib_amb_occlusion (Figure 12.13).

  10. Open the Attribute Editor for the Mib_amb_occlusion1 node and set Samples to 64.

  11. Make sure the AOShadow is selected in the Render Layer Editor; then create a test render using the renderCam camera.

    The car appears as flat white, but you can see the soft shadows created on the ground by the ambient occlusion node (Figure 12.14).

    Create an ambient occlusion texture and connect it to the shadow-Shader's Out Color channel.

    Figure 12.13. Create an ambient occlusion texture and connect it to the shadow-Shader's Out Color channel.

    The soft shadows created by the ambient occlusion texture appear on the ground while the car is masked in flat white.

    Figure 12.14. The soft shadows created by the ambient occlusion texture appear on the ground while the car is masked in flat white.

    Set the blend mode of the AOShadow layer to Multiply.

    Figure 12.15. Set the blend mode of the AOShadow layer to Multiply.

  12. Now you are ready to preview the composite in the Render View window. In the Render Layer Editor, set the mode of the AOShadow layer to Multiply (see Figure 12.15).

    Because the car in this render layer is flat white, when the pixels of the AOShadow layer are multiplied by the pixels of the studioLight layer, only the soft shadows appear in the composite.

  13. In the Render Layer Editor, select Options

    Set the blend mode of the AOShadow layer to Multiply.

    This setting renders both layers and then composites them in the Render View window. The Composite And Keep Layers setting create the composite, but it also keeps the rendered image of each individual layer available in the Render View window. The Keep Layers option will not composite the layers; instead it renders all renderable layers and keeps them as individual images in the Render View window.

  14. After choosing the Composite Layers option, click Apply And Close. Double-check and make sure that Render All Layers is now checked in the Options menu of the Render Layer Editor (Figure 12.16).

    Select the Render All Layers option in the Options menu.

    Figure 12.16. Select the Render All Layers option in the Options menu.

  15. In the Render Layer Editor, click the blue sphere and cube icon next to masterLayer so that a red X appears. You don't need this layer to be included in the composite. Select the AOShadow layer.

  16. Open the Render View window, and create a test render using the renderCam camera. You'll see the studioLighting layer render first, and then the AOShadow layer will render on top of it. Figure 12.17 shows the composited image.

  17. Save the scene as carComposite_v07.ma. To see a finished version of the scene, open the carComposite_v07.ma scene from the chapter12scenes directory on the DVD.

    The two images are composited in the Render View window.

    Figure 12.17. The two images are composited in the Render View window.

This is a good way to preview basic composites; however, in practice you will most likely want more control over how the layers are composited. To do this you should use more advanced compositing software such as Adobe Photoshop (for still images) or Adobe After Effects or Autodesk Toxic (for animations). Autodesk is working toward automating the Maya to Toxic workflow so render layers can be imported into Toxic while maintaining their respective blend mode settings.

Render Passes

Render passes divide the output created by a render layer into separate images or image sequences. Using Render Passes you can separate the reflections, shadows, diffuse color, ambient occlusion, specular highlights, and so on into images or image sequences, which can then be reassembled in compositing software. By separating things like the reflections from the diffuse color, you can then exert maximum creative control over how the different images work together in the composite. This also allows you to easily make changes or variations or fix problems in individual elements rather than re-rendering the entire image or sequence every time you make a change.

Render Passes replaces the technique of using multiple render layers to separate things like reflections and shadows in older versions of Maya. (Render Passes also replaces the layer presets; more on this in a moment.) In Maya 2009, each layer can be split into any number of render passes. When render passes are created, each layer is rendered once, and the passes are taken from data stored in the Frame Buffer. This means each layer needs to render only once to create all the necessary passes. Render time for each layer increases as you add more passes.

A typical workflow using passes is to separate the scene into one or more render layers, as demonstrated in the first part of this chapter, and then assign any number of render passes to each render layer. When you create a batch render, the passes are stored in subfolders in the Images directory of the current project. You can then import the images created by Render Passes into compositing software and assemble them into layers to create the final composite.

Render passes work only with mental ray; they are not available for any other renderer. To create render passes for Maya Software, the best approach is to use separate render layers.

It's also crucial to understand that at this point not all materials will work with render passes. If you find that objects in your scene are not rendering correctly, double-check that you are using a material compliant with render passes.

The materials that work with Render Passes are Anisotropic, Blinn, Lambert, Phong, Phong E, Environment Fog, Fluid Shape, Light Fog, Particle Cloud, Volume Fog, Volume Shader, Hair Tube Shader, Ocean Shader, Ramp Shader, Hair, Fur, Image Plane, Layered Shader, Shading Map, Surface Shader, Use Background, mi_metallic_paint_x_passes, mi_car_phen_x_passes, mia_material_x_passes, and misss_fast_shader_x_passes.

Note that the mental ray DGS, Dielectric, mib_glossy_reflection, and mib_glossy_refraction shaders, and the other mib shaders, are not yet supported by Render Passes. Even if you use a supported shader (such as mi_metallic_paint_x_passes) as a base material for these shaders, it will not render correctly. When using these shaders you may need to devise an alternate work-flow involving render layers and material overrides.

Creating an Ambient Occlusion Pass

As an example you'll start by creating an ambient occlusion render pass for the space helmet scene. In previous versions of Maya you could create a render layer and use the Ambient Occlusion preset. The preset would automatically shade all of the objects in the layer with a custom ambient occlusion shader network. In Maya 2009 the mental ray renderer has a built-in ambient occlusion pass, which creates ambient occlusion shadowing in a render pass without the use of a shader network. This gives you another option for creating ambient occlusion passes. Ambient occlusion passes are frequently used in compositing, so you'll start with this type of pass.

  1. Open the helmetComposite_v01.ma scene from the chapter12scenes directory on the DVD.

    This scene shows the space helmet constructed in Chapter 3. All of the shaders applied to the helmet are variations of the MIA Materials shader. The lighting in the scene is created using a point light with a Physical Light shader applied. The fill lighting is created using Final Gathering and an HDRI probe image (see Figure 12.8).

    The scene has a single render layer named helmet. This layer is a duplicate of the masterLayer. You can create render passes for the masterLayer, but for the sake of simulating a production workflow, you'll use a render layer in this demonstration.

    The helmet scene has been lit and shaded and is ready to render using Render Passes.

    Figure 12.18. The helmet scene has been lit and shaded and is ready to render using Render Passes.

    The mia_material_x shader is not compliant with Render Passes. To make the material compliant, it must be upgraded to an mia_material_x_passes shader. This process is necessary only when using the mental ray shaders.

  2. Open the Hypershade window and select the chromeShader. Open its Attribute Editor to the chromeShader tab.

  3. Scroll to the bottom of the Attribute Editor. Expand the Upgrade Shader rollout. Click the button labeled Upgrade Shader To mia_material_x_passes (see Figure 12.19).

  4. Repeat step 3 for the metalShader, plasticShader, rubberShader, thickGlass, and thinGlass shaders.

    Upgrade the chrome-Shader to the mia_material_x_passes shader.

    Figure 12.19. Upgrade the chrome-Shader to the mia_material_x_passes shader.

    The attributes of the shader won't change save for the addition of the Frame Buffer Contribution attribute. This can usually be left at the default settings.

    At this point you're ready to add the ambient occlusion pass.

  5. Open the Render Settings window and choose the Passes tab. At the top of the Render Settings window, make sure Render Layer is set to Helmet.

    The upper portion of the Render Passes area is the Scene Passes section. This holds all the passes available for the scene. This section is blank until you add a pass.

  6. Click the top icon to the right of the Scene Passes section to open the Create Render Passes window. From Pass List, select Ambient Occlusion (Figure 12.20).

  7. Click Create And Close to add the pass to the Scene Passes section.

  8. You'll now see the Ambient Occlusion pass listed in the Scene Passes section as AO. Select the AO pass and open the Attribute Editor (if the pass settings don't appear in the Attribute Editor, double-click AO in the Passes tab of the Render Settings window).

    Select the Ambient Occlusion preset from the list of available Render Passes presets.

    Figure 12.20. Select the Ambient Occlusion preset from the list of available Render Passes presets.

    The settings for the pass are listed in the Attribute Editor. These include the number of channels used for the pass and the bit depth. The available settings may differ depending on the selected pass preset.

    When Channels is set to 3, the pass will contain the red, green, and blue channels (RGB). When Channels is set to 4, an Alpha channel is also included (see Figure 12.21) along with the red, green, and blue channels.

    The settings for the render pass are displayed in the Attribute Editor when the pass is selected in the Passes tab of the Render Settings window.

    Figure 12.21. The settings for the render pass are displayed in the Attribute Editor when the pass is selected in the Passes tab of the Render Settings window.

    The pass is now available for the scene, but it needs to be associated with the current render layer.

  9. Select AO in the Scene Passes section. Click the icon with the downward-pointing arrow between the Scene Passes and Associated Passes sections to associate the pass with the current render layer.

    Once the pass is associated with the current layer, it is included in the Frame Buffer when the scene renders and saved as a separate image after rendering is complete. The Scene Passes and Associated Passes interface is a little confusing at first; just remember that only the passes listed in the Associated Passes section will be rendered for the current render layer. If you switch to another render layer, you'll see all the passes listed in the Scene Passes section. To disassociate a pass from a render layer, select the pass in the Associated Passes section and click the up-arrow icon between the two sections. This moves the pass back to the Scene Passes section. To delete a pass from either section, select the pass and press the Backspace key.

    The Ambient Occlusion pass will not calculate correctly until you enable Ambient Occlusion in the Features section of the Render Settings window.

  10. Click the Features tab of the Render Settings window. Under Secondary Effects, select the Ambient Occlusion option.

    This activates mental ray's built-in ambient occlusion. This is calculated without the need to create a shader network with an mib_amb_occlusion node.

  11. To set the quality of the ambient occlusion, click the Indirect Lighting tab in the Render Settings window. Expand Ambient Occlusion at the bottom. Make sure the Ambient Occlusion option is activated, and use the Rays field to specify how many rays will be used to calculate the effect. Set Rays to 256 (see Figure 12.22).

    For the Ambient Occlusion pass to calculate, you must activate Ambient Occlusion in the Features tab. Quality is determined by the settings in the Indirect Lighting tab.

    Figure 12.22. For the Ambient Occlusion pass to calculate, you must activate Ambient Occlusion in the Features tab. Quality is determined by the settings in the Indirect Lighting tab.

  12. Open the Render View window and create a render using the renderCam camera. The render will not look any different from Figure 12.18.

    The render will take three or four minutes to calculate depending on the speed of your hardware and available RAM. When it's finished, you'll most likely be wondering where the Ambient Occlusion pass is. The pass is stored in a temporary folder in the project's Images directory. If the scene uses layers, each layer has its own subfolder where the passes are stored.

  13. To see the Ambient Occlusion pass, use the File menu in the Render View window. Choose File

    For the Ambient Occlusion pass to calculate, you must activate Ambient Occlusion in the Features tab. Quality is determined by the settings in the Indirect Lighting tab.
  14. Save the scene as helmetComposite_v02.ma. To see a finished version of the scene, open the helmetComposite_v02.ma scene from the chapter12scenes directory on the DVD.

    You can load the Ambient Occlusion pass from the File menu in the Render View window.

    Figure 12.23. You can load the Ambient Occlusion pass from the File menu in the Render View window.

Creating Reflection, Specular, Depth, and Shadow Passes

The previous example demonstrated how to create a single render pass. In this example, you'll create multiple passes for reflection, specular, depth, and shadow.

Depth passes are particularly helpful in compositing. They can be used to add, among other things, camera depth of field in the composite. For example, using Adobe After Effects's Lens Blur filter, you can apply a depth pass to control the focal region of the render based on the luminance of the depth pass. There are also plug-ins available for After Effects, such as Lens Care by Frischluft, which create realistic lens effects far superior to the standard After Effects blurs. Using a depth pass for depth of field in After Effects dramatically reduces Maya render times, because mental ray's depth of field can take a long time to calculate. Furthermore any changes you make to the depth of field, such as the focal region, are done in After Effects and do not require re-rendering the entire scene. The same is true for motion blur. You can create a 2D or 3D motion vector pass and then use a plug-in such as Reel Smart Motion Blur to add motion blur in the composite rather than in the initial render. This is a huge time-saver.

  1. Continue with the scene from the previous section or open the helmetComposite_v02.ma scene from the chapter12scenes directory on the DVD.

  2. Open the Render Settings window and choose the Passes tab. Select AO in the Associated Passes section, and click the up-arrow icon to move this pass back to the Scene Passes section. This means the AO pass will not be rendered with the layer.

  3. Click the Create Render Passes icon to the right of the Scenes Passes section. From the Pass List select Camera Depth, and click the Create button to add this pass to the Scene Passes section.

  4. Add reflection, shadow, and specular passes as well. You can find complete descriptions of each Render Pass preset in the Maya documentation.

  5. Close the Create Render Pass window. In the Passes tab of the Render Settings window, select the depth, reflection, shadow, and specular passes, and use the down arrow to move them to the Associated Passes section.

  6. Double-click the depth pass in the Associated Passes list, and open the Attribute Editor. Turn on Remap Depth Values, and set the Far Clipping plane to 20.

    The scene size for this scene is 20 units in Z; by setting the Far Clipping Plane to 20, any parts of a surface beyond 20 units are clipped to a luminance value of 1 (meaning they are white).

  7. Double-click Reflection to open its settings in the Attribute Editor. Raise Maximum Reflection Level to 10.

  8. Create another test render from the Render View window using the renderCam camera. You can use the File

    Creating Reflection, Specular, Depth, and Shadow Passes
  9. Save the scene as helmetComposite_v03.ma. To see a finished version of the scene, open the helmetComposite_v03.ma scene from the chapter12scenes directory on the DVD.

You can add render passes to a render layer in the Render Layer Editor. To do this, right-click on the layer and choose Add New Render Pass. You can choose the type of pass from the pop-up list (Figure 12.25). The pass then automatically appears in the Associated Passes section in the Passes tab of the Render Settings window.

Clockwise from the upper left are the reflection, depth, specular, and shadow passes for the helmet scene. The elements of the passes appear dark because they have been separated and rendered against black.

Figure 12.24. Clockwise from the upper left are the reflection, depth, specular, and shadow passes for the helmet scene. The elements of the passes appear dark because they have been separated and rendered against black.

You can add render passes to a render layer by right-clicking on the layer in the Render Layer Editor.

Figure 12.25. You can add render passes to a render layer by right-clicking on the layer in the Render Layer Editor.

Render Pass Contribution Maps

Render Pass Contribution Maps can be used to further customize the render passes for each layer. A contribution map specifies which objects and lights are included in a render pass. By default when you create a render pass and associate it with a particular render layer, all the objects on the layer are included in the pass. Using a contribution map you can add only certain lights and objects to the render pass. The whole point is to give you even more flexibility when rendering for compositing. This exercise demonstrates how to set up contribution maps.

  1. Open the minigunComposite_v01.ma scene from the chapter12scenes directory on the DVD.

  2. This scene contains a model of a minigun, a simple backdrop, and some directional lights.

    The scene also uses an HDRI image to create reflections on the metal of the gun. The shader applied to the gun is a standard Maya anisotropic shader. An ambient occlusion texture is connected to the Reflectivity of the material, and the texture is set to Reflective Occlusion mode.

    A single render layer named miniGun contains all of the lights and surfaces in the scene.

  3. In the Outliner, expand the turret object. Select the right_mount1 subgroup. In the Render Layer Editor, right-click on the miniGun layer and choose Pass Contribution Maps

    Render Pass Contribution Maps
  4. A small arrow is added to the miniGun render layer label. Click this label to expand the layer. You'll see the contribution map listed as passContributionMap1. Double-click on this and change the name to rightGun (see Figure 12.27).

    Create a render pass contribution map from the selected objects in the Outliner.

    Figure 12.26. Create a render pass contribution map from the selected objects in the Outliner.

    Rename the new map rightGun.

    Figure 12.27. Rename the new map rightGun.

  5. Repeat steps 3 and 4 for the left_mount group. Name the new contribution map leftGun.

  6. Select the miniGun render layer, open the Render Settings window, and switch to the Passes tab. Click the Create New Render Pass icon to the right of the Scene Passes section, and add Reflection and Specular pass presets.

  7. Select both the Reflection and Specular passes in the Scene Passes section. Click the down arrow to move them to the Associated Passes section.

  8. Below the Associated Passes section you'll see the Associated Pass Contribution Map section. Set the Associated Passes Contribution Map drop-down menu to rightGun.

  9. Select the Reflection pass in the Associated Passes section, and click the down arrow below this section to move the Reflection pass preset to the Passes Used By Contribution Map section.

    This means that only the objects in the rightGun contribution map (the right_mount1 group) appear in the Reflection pass created for the miniGun layer.

  10. Repeat steps 8 and 9, but this time set the Associated Pass Contribution Map drop-down menu to leftGun, and move the Specular preset down to the Passes Used By Contribution Map section (Figure 12.28).

  11. Open the Render View window, and create a render using the renderCam camera. Once again the render looks the same as if you had not added any render passes.

  12. When the image has finished rendering, use the File menu in the Render View window to load the Specular and Reflection passes.

    Notice that in these passes only one part of the gun appears. In the Specular pass, the left_mount1 group appears; in the Reflection pass, the right_mount1 group appears (Figure 12.29). The rest of the gun and the backdrop are absent from each pass. Although this is not a practical application of contribution maps, it demonstrates clearly that the point of a contribution map is to specify exactly which objects appear in a render pass.

  13. Save the scene as minigunComposite_v02.ma. To see a version of the scene to this point, open the minigunComposite_v02.ma scene from the chapter12scenes directory on the DVD.

    Associate the Specular pass with the leftGun contribution map.

    Figure 12.28. Associate the Specular pass with the leftGun contribution map.

    After you render the image, the Reflection and Specular passes show only the objects added to the contribution map for each pass.

    Figure 12.29. After you render the image, the Reflection and Specular passes show only the objects added to the contribution map for each pass.

Lights and Contribution Maps

Lights can also be included in contribution maps. If no lights are specified, all of the scene lights are added. In the minigun scene the directional light is the only light that casts shadows; the other two lights have shadow casting turned off. You can use pass contribution maps to create a shadow pass just for this light.

  1. Continue with the scene from the previous section or open the minigunComposite_v02.ma scene from the chapter 12scenes directory on the DVD.

  2. In the Outliner, Shift+click ground and directionalLight1. In the Render Layer Editor, right-click on the miniGun render layer, and choose Pass Contribution Maps

    Lights and Contribution Maps
  3. Double-click passContributionMap1 and rename it groundShadow.

  4. Open the Render Settings window and switch to the Passes tab. Select Reflection and Specular in the Associated Passes section, and use the up arrow to move them to the Scene Passes section. Doing this prevents the passes from being included in the render.

  5. Click the Create New Render Pass button, and add a Raw Shadow pass to the Scene Passes section.

  6. Move shadowRaw from the Scene Passes section to the Associated Passes section (make sure miniGun is the currently selected render layer when you do this).

  7. Set Associated Pass Contribution Map to groundShadow. Use the down-arrow button to move shadowRaw into the Passes Used By Contribution Map section.

  8. Double-click the shadowRaw pass to open its Attribute Editor. In the Attribute Editor, disable Hold-Out (see Figure 12.30).

    Associate the shadowRaw preset with the groundShadow contribution map. In the settings for shadowRaw, disable the Hold-Out option.

    Figure 12.30. Associate the shadowRaw preset with the groundShadow contribution map. In the settings for shadowRaw, disable the Hold-Out option.

    The Hold-Out setting creates a geometry mask for geometry that is not included in the render pass. By disabling this, you'll see only the ground surface and the cast shadow in the render.

  9. Open the Render View window, and create a test render from the renderCam camera (see Figure 12.31).

    In the composite, the shadow pass should be inverted and color corrected. When creating a shadow pass contribution map, you may want to include just the shadow-casting lights. In some cases including all of the lights can produce strange results.

  10. Save the scene as miniGun_v03.ma. To see a finished version of the scene, open the miniGun_v03.ma scene from the chapter12scenes directory on the DVD.

    The ground-Shadow contribution map shows only the directionalLight, the ground, and the shadow cast by the gun geometry.

    Figure 12.31. The ground-Shadow contribution map shows only the directionalLight, the ground, and the shadow cast by the gun geometry.

Render Pass Sets

Render pass sets are simply a way to organize large lists of render passes in the Passes tab of the Render Settings window. You can create different groupings of the passes listed in the Scene Passes section, give them descriptive names, and then associate the set with the render layer or the associated contribution maps. If you have a complex scene that has a large number of passes, you'll find it's easier to work with the pass sets rather than all of the individual passes.

You can create a render pass set as you create the render passes or add them to the set later. In the Create Render Passes window, check the box that says Create Pass Set, and give the pass set a descriptive name (Figure 12.32). The new pass set appears in the Scene Passes section in the Render Settings window along with all of the newly created passes (Figure 12.33). To associate a render layer with the new pass set, you only have to move the pass set to the Associated Passes section. All of the passes included with the set will be associated with the layer even though they do not appear in the Associated Passes section.

You can create a pass set in the Create Render Passes window using the options at the bottom.

Figure 12.32. You can create a pass set in the Create Render Passes window using the options at the bottom.

Associating the set with the current render layer associates all of its contained passes with the layer. You can use the Relationship Editor to add and remove passes from the set.

Figure 12.33. Associating the set with the current render layer associates all of its contained passes with the layer. You can use the Relationship Editor to add and remove passes from the set.

To verify which passes are included in the set, open the Relationship Editor for Render Passes (Window

Associating the set with the current render layer associates all of its contained passes with the layer. You can use the Relationship Editor to add and remove passes from the set.

You can add a new set in the Passes tab of the Render Settings window by clicking the Create New Render Pass Set icon. You can then use the Relationship Editor to add the passes to the set. A render pass can be a member of more than one set.

Batch Rendering

Batch rendering is the process of translating a Maya animation into a sequence of images. The images are processed and saved to disk. The rendered image sequences can then be brought into compositing software, where they can be layered together, edited, color corrected, combined with live footage, and have additional effects applied. The composite can then be converted to a movie file or a sequence of images for distribution or imported to editing software for further processing.

Generally you want to render a sequence of images from Maya. You can render directly to a movie file, but this usually not a good idea. If the render stops while rendering directly to a movie file, it may corrupt the movie, and you will need to restart the whole render. When you render a sequence of images and the render stops, you can easily restart the render without re-creating any of the images that have already been saved to disk.

When you set up a batch render, you can specify how the image sequence will be labeled and numbered. You also set the image format of the final render, which render layers and passes will be included and where they will be stored, and other aspects related to the rendered sequences. You can use Maya's Render Settings window to determine these properties or perform a command-line render using your operating system's terminal. In this section you'll learn important features of both methods.

Batch rendering is also accomplished using render farm software, which distributes the render across multiple computers. This subject is beyond the scope of this book.

File Tokens

File tokens are a way to automate the organization of your renders. If your scene has a lot of layers, cameras, and passes, you can use tokens to specify where all the image sequences will be placed on your computer's hard drive, as well as how they are named.

The image sequences created with a batch render are placed in the Images folder of the current project or whichever folder is specified in the Project Settings window (see Chapter 1 for information regarding project settings). Tokens are placed in the File Name Prefix field found in the Common tab of the Render Settings window. If this field is left blank, the scene name is used to label the rendered images (Figure 12.34).

The File Name Prefix field in the Common tab of the Render Settings window is where you specify the image name and tokens.

Figure 12.34. The File Name Prefix field in the Common tab of the Render Settings window is where you specify the image name and tokens.

By default if the scene has more than one render layer, Maya creates a subfolder for each layer. If the scene has more than one camera, a subfolder is created for each camera. For scenes with multiple render layers and multiple cameras, Maya creates a subfolder for each camera within the subfolder for each layer.

You can specify any directory you want by typing the folder names into the File Name Prefix field. For example if you want your image sequences to be named marshmallow and placed in a folder named chocolateSauce, you can type chocolateSauce/marshmallow into the File Name Prefix field. However, explicitly naming a file sequence lacks the flexibility of using tokens and runs the risk of allowing you to overwrite file sequences by mistake when rendering. You can see a preview of how the images will be named in the upper portion of the Render Settings window (Figure 12.35).

The whole point of tokens is to allow you to change the default behavior and specify how subfolders will be created dynamically for a scene. To use a token to specify a directory, place a slash after the token name. For example, to create a subfolder named after each camera, type <camera>/ into the File Name Prefix field. To use a token to name the images, omit the slash. For example <scene>/<camera> results in a folder named after the scene containing a sequence of images named camera.iff.

A preview of the image name appears at the top of the Common tab of the Render Settings window.

Figure 12.35. A preview of the image name appears at the top of the Common tab of the Render Settings window.

Here are some of the more common tokens:

<Scene>

This token names the images or subfolder after the scene name.

<Camera>

This token names the images or subfolders after the camera. For example, in a scene with two cameras named renderCam1 and renderCam2, <Scene>/<Camera>/<Camera> creates a single folder named after the scene, within which are two subfolders named renderCam1 and renderCam2. In each of these folders is a sequence named renderCam1.ext and renderCam2.ext.

<RenderLayer>

This token creates a subfolder or sequence named after each render layer. If there are passes associated with the layer, then the pass names are appended to the layer name. For example if you have a layer named spurtsOfBlood and an associated specular pass, the folder or image sequence would automatically be named spurtsOfBlood_specular.

<RenderPass>

This token creates a subfolder or sequence named after the render pass. Since render passes are available only for mental ray renders, this token applies only when using mental ray.

<RenderPassType>

This token similar to <RenderPass> except it abbreviates the name of the render pass. A reflection pass, for example, would be abbreviated as REFL.

<RenderPassFileGroup>

This adds the name of the render pass file group. The file group name is set in the Attribute Editor of the render pass node (see Figure 12.36). Render pass file groups are assigned by mental ray, but you can create your own name for the group by typing it in the Pass Group Name field of the render pass node.

You can set the render pass group name in the Attribute Editor of the render pass node.

Figure 12.36. You can set the render pass group name in the Attribute Editor of the render pass node.

<Extension>

This adds the file format extension. It is usually added to the end of the filename automatically, but you can also use this token to label a directory based on the image format.

<Version>

This adds a custom label specified by the Version Label field in the Render Settings window (Figure 12.37).

The <Version> token adds the label specified in the Version Label field in the Render Settings window.

Figure 12.37. The <Version> token adds the label specified in the Version Label field in the Render Settings window.

Note that the capitalization of the token name does matter. If you had a scene named chocolateSauce that has a render layer named banana that uses a specular and diffuse pass with two cameras named shot1 and shot2, and you want to add the version label v05, the following tokens specified in the File Name Prefix field

<Scene>/<RenderLayer>/<Camera>/<RenderPass>/<RenderPass>_<Version>

will create a file structure that looks like this:

chocolateSauce/banana/shot1/specular/specular_v05.#.ext
chocolateSauce/banana/shot1/diffuse/diffuse_v05.#.ext
chocolateSauce/banana/shot2/specular/specular_v05.#.ext
chocolateSauce/banana/shot2/diffuse/diffuse_v05.#.ext

Use underscores or hyphens when combining tokens in the directory or image name. Avoid using periods.

Specifying Frame Range

For multiframe animations, you have a number of options for specifying the frame range and the syntax for the filenames in the sequence. These settings are found in the Common tab of the Render Settings window. To enable multiframe rendering, choose one of the presets from the Frame/Animation Ext menu. When rendering animation sequences the safest choice is usually the name.#.ext option. This names the images in the sequence by placing a dot between the image name and the image number and another dot between the image number and the file extension. The Frame Padding option allows you to specify a number of zeros between the image number and the extension. So a sequence named marshmallow using the Maya IFF format with a Frame Padding of 4 would look like marshmallow.0001.iff.

The Frame Range settings specify which frames in the animation will be rendered. The By Frame setting allows you to render each frame (using a setting of 1), skip frames (using a setting higher than 1), or render twice as many frames (using a setting of 0.5, which renders essentially at half speed).

It is possible to render backwards by specifying a higher frame number for the Start Frame value than the End Frame value and using a negative umber for By Frame. You would then want to use the Renumber Frames option so the frame numbers move upward incrementally.

The Renumber Frames option allows you to customize the labeling of the image sequence numbers.

Renderable Cameras

The rendering cameras are specified in the Renderable Camera list. To add a camera, expand the Renderable Camera menu and choose Add Renderable Camera. To remove a rendering camera, click the trash can icon next to the renderable camera. As noted earlier in the chapter, you can use a layer override to include a specific camera with a render layer.

Each camera has the option of rendering alpha and Z depth channels. The Z depth channel stores information about the depth in the scene. This is included as an extra channel in the image (only a few formats such as Maya IFF support this extra channel). Not all compositing software supports Maya's Z depth channel. You may find it easier to create a camera depth pass using the custom passes (passes are described earlier in this chapter). The render depth pass can be imported into your compositing software and used with a filter to create depth of field effects.

You can add and remove renderable cameras using the Renderable Camera menu.

Figure 12.38. You can add and remove renderable cameras using the Renderable Camera menu.

File Formats and the Frame Buffer

When Maya renders a scene, the data stored in the Frame Buffer is converted into the native IFF format and then translated to the file type specified in the Image Format menu. So if you specify the SGI format, for example, Maya translates the SGI image from the native IFF format.

Most popular compositing packages (such as Adobe After Effects and Autodesk Toxic) support the IFF format, so it's usually safe to render to this file format. The IFF format uses four 8-bit channels by default, which is usually adequate for most viewing purposes. If you need to change the file to a different bit depth or a different number of channels, you can choose one of the options from the Data Type menu in the Framebuffer section in the Quality tab. This is where you will also find the output options, such as Premultiply (see Figure 12.39).

Render passes uses the secondary Frame Buffer to store the image data. You can specify the bit depth of this secondary buffer in the Attribute Editor for each render pass.

A complete list of supported image formats is available in the Maya documentation. Note that Maya Software and mental ray may support different file formats.

Specify bit depth and other output options using the Framebuffer settings in the Quality tab of the Render Settings window.

Figure 12.39. Specify bit depth and other output options using the Framebuffer settings in the Quality tab of the Render Settings window.

Starting a Batch Render

When you are satisfied that your animation is ready to render, and all the settings have been specified in the Render Settings window, you're ready to start a batch render. To start a batch render, set the main Maya menu set to Rendering and choose Render

Starting a Batch Render

One of the most useful options is the Verbosity Level. This refers to the level of detail of the messages displayed in the Maya Output window as the render takes place. On the Mac, progress messages should be displayed in the Console Window (Window

Starting a Batch Render
Detailed progress messages for each frame can be displayed in the Output Window.

Figure 12.40. Detailed progress messages for each frame can be displayed in the Output Window.

To start the render, click the Batch Render (or the Batch Render And Close) button. As the batch render takes place, you'll see the Script Editor update (Figure 12.41). For detailed information on the progress of each frame, you can monitor the progress in the Output Window.

To stop a batch render, choose Render

Detailed progress messages for each frame can be displayed in the Output Window.

When the render is complete, you'll see a message in the Script Editor that says Rendering Completed. You can then use F Check to view the sequence (File

Detailed progress messages for each frame can be displayed in the Output Window.
The Script Editor shows the progress of the batch render.

Figure 12.41. The Script Editor shows the progress of the batch render.

Command-Line Rendering

A batch render can be initiated using your operating system's command prompt or terminal window. This is known as a command-line render. A command-line render takes the form of a series of commands typed into the command prompt. These commands include information about the location of the Maya scene to be rendered, the location of the rendered image sequence, the rendering cameras, image size, frame range, and many other options similar to the settings found in the Render Settings window.

Command-line renders tend to be more stable than batch renders initiated from the Maya interface. This is because when the Maya application is closed, more of your computer's RAM is available for the render. You can start a command-line render regardless of whether Maya is running or not. In fact, to maximize system resources, it's best to close Maya when starting a command-line render. In this example you can keep Maya open.

In this exercise you'll see how you can start a batch render on both a PC and a Mac. You'll use the solarSystem_v01.ma scene, which is a very simple animation showing two planets orbiting a glowing sun.

  1. From the DVD, copy the solarSystem_v01.ma scene to the scenes directory of your current project on your computer's hard drive.

  2. Open the scene in Maya.

This scene has a masterLayer render layer, which should not be rendered, and two additional layers. The solarSystem layer contains the sun and planets, which have been shaded. It uses the mental ray renderer. If you open the Render Settings window to the Passes tab, you'll see this scene uses two render passes: diffuse and incandescence. The second layer is named orbitPaths. It contains Paint Effects strokes that illustrate the orbit paths of the two planets (Figure 12.42).

In the Common tab of the Render Settings window, no filename prefix has been specified and a frame range is not set. Maya will use the default file structure when rendering the scene, and the frame range will be set in the options for the command line.

The solarSystem _v01.ma scene has been prepared for rendering.

Figure 12.42. The solarSystem _v01.ma scene has been prepared for rendering.

Windows Command-Line Render

The first example starts a command-line render using Windows.

  1. Go to the Windows Start menu and choose Start

    Windows Command-Line Render
  2. Use Windows Explorer to browse your computer's directory (right-click the Start button and choose Explore to open Windows Explorer), open the scenes folder in your current project where you placed the solarSystem_v01.ma scene.

  3. Select the Address line at the top of Windows Explorer, and choose Edit

    Windows Command-Line Render
  4. At the command prompt, type cd .... and hit Enter. This sets the command prompt to the root directory.

  5. Type cd, space, and then right-click the command line and select Paste. This pastes the path to the scenes directory in the command prompt. Press the Enter key to set the current directory to the scenes directory (Figure 12.43).

    Set the command prompt to the current directory where the solar System_v01.ma scene is stored (the exact directory path will look different on your machine).

    Figure 12.43. Set the command prompt to the current directory where the solar System_v01.ma scene is stored (the exact directory path will look different on your machine).

    When starting a batch render, you can either specify the path to the scenes directory in the command-line options or set the command prompt to the directory that contains the scene.

    To start a batch render, use the render command in the command prompt followed by option flags and the name of the scene you want to render. The option flags are preceded by a hyphen. The flags are followed by a space and then the flag setting. For example, to start a scene using the mental ray renderer, you would type render -r mr myscene.ma. The render command starts the batch renderer, the -r flag specifies the renderer, and mr sets the -r flag to mental ray. The command ends with the name of the scene (or the directory path to the scene if you're not already in the directory with the scene).

    There are a large number of options, but you don't need to use them, except if you want to specify an option that's different from what is used in the scene. If you want all the layers to render using mental ray regardless of the layer setting in the scene, then you specify mental ray using the -r mr flag. If you omit the -r flag, then Maya uses the default renderer, which is Maya Software. If you have a scene with several layers that use different renderers (as in the case of the solarSystem_v01.ma scene), then you would type -r file. This sets the renderer to whatever is specified in the file, including what is specified for each layer.

    Other common flags include:

    • -s <float> sets the start frame (replace <float> with the starting frame, for example -s 120 would set the start frame to 120. A float is number with a decimal point).

    • -e <float> sets the end frame.

    • -x <int> sets the X resolution of the image (an integer is a whole number without a decimal point).

    • -y <int> sets the Y resolution of the image.

    • - cam <name> sets the camera.

    • -rd <path> specifies the directory for the images (if this is not used, the directory in the project settings is used).

    • -im <filename> sets the name of the rendered image.

    • -of <format> sets the image format.

    There is a complete list of the flags in the Maya documentation. You can also print a description of commands by typing render -help. To see mental ray-specific commands, type render -help -r mr.

  6. For example, if you want to render the scene using renderCam1, starting on frame1 and ending on frame 24, type the following in the command prompt (Figure 12.44):

    render -r file -s 1 -e 24 -cam renderCam1solarSystem_v01.ma
    Enter the render command with options and the scene name in the Command Prompt window.

    Figure 12.44. Enter the render command with options and the scene name in the Command Prompt window.

    You'll see the render execute in the command prompt. When it's finished, you can use F Check to view each sequence. In the Images folder, you'll see two directories named after the layers in the scene. The orbitPath directory has the Paint Effects orbit paths rendered with Maya Software. The solarSystem directory has the rendered sequence of the planets and sun as well as subdirectories for the diffuse, incandescence, and MasterBeauty passes (the MasterBeauty pass is created by default when you add passes to a scene).

  7. Let's say you want to render only the orbitPaths layer using renderCam2 for the frame range 16 to 48. You want to specify Maya Software as the renderer. You may want to name the sequence after the camera as well. Type the following into the command prompt (use a single line with no returns):

    render -r sw -s 16 -e 48 -rl orbitPaths -cam renderCam2 -im solarSystemCam2 solarSystem_v01.ma

Mac Command-Line Render

For a Mac, the Maya command-line render workflow is similar except that instead of the command prompt you use a special Terminal window that is included when you install Maya. This is an application called Maya Terminal.term and it's found in the Applications

Mac Command-Line Render
The Maya Terminal window is installed with Maya in the Maya 2009 folder.

Figure 12.45. The Maya Terminal window is installed with Maya in the Maya 2009 folder.

You need to navigate in the terminal to the scenes directory that contains the scene you want to render.

  1. Copy the solarSystem_v01.ma scene from the DVD to the scenes directory of your current project on you computer's hard drive.

  2. In the Finder, open the current project directory.

  3. Start the Maya Terminal application, and type cd at the prompt.

  4. In the Finder, drag the scenes folder from the current project on top of the Maya Terminal. This places the path to the scenes directory in the Terminal.

  5. Press the Enter button. The Terminal window is now set to the project's scenes folder, which contains the solarSytem_v01.ma scene.

The commands for rendering on a Mac are the same as they are for Windows. You can continue starting with step 6 in the previous exercise.

Creating a Batch Script

It's possible to create a text file that can initiate a series of batch renders for a number of different scenes. This can be useful when you need a machine to perform several renders overnight or over a long weekend. This can save you the trouble of starting every batch render manually. This section describes how to create a batch script for Windows and Mac.

Windows Batch Render Script

  1. Move the scenes you want to render into the renderScenes directory of the current project. Give them a name that distinguishes them from the original scenes in the scenes directory just to avoid confusion.

  2. Create a new plain-text file using Notepad.

  3. In the text file, type out the render commands exactly the same way you would initiate a batch render. Use a new line for each render. For example:

    render -r file -s 20 -e 120 -cam renderCam1 myScene.mb
    render -r file -s 121 -e 150 -cam renderCam2 myScene.mb
    render -r file -s 1-e 120 -cam renderCam1 myScene_part2.mb
  4. Save the scene as a .bat file, and save it in the same directory as the scenes you wish to render, usually the renderScenes directory. The file can be named anything, but it should end in .bat. Make sure the format is plain text, for example, weekendRender.bat.

  5. When you are ready to render, double-click on the batch script (for example, weekendRender.bat) (see Figure 12.46).

You'll probably want to close Maya to maximize system resources for the render. Maya will render each scene in the order it is listed in the batch file. Be very careful in naming the files and the image sequences so one render does not overwrite a previous render. For example, if you render overlapping frame sequences from the same file, use the -im flag in each batch render line to give the image sequences different names.

An example of a batch script file

Figure 12.46. An example of a batch script file

Mac Batch Render Script

There are a few extra steps involved in creating a Mac batch render script, but for the most part it is similar to the Windows workflow.

  1. Move the scenes you want to render into the renderScenes directory of the current project. It's a good idea to give the scenes a name that distinguishes them from the original scenes in the scenes directory just to avoid confusion.

  2. Create a new plain-text file using TextEdit.

  3. In the text file, type out the render commands exactly the same way you would initiate a batch render. Use a new line for each render. For example:

    render -r file -s 20 -e 120 -cam renderCam1 myScene.mb
    render -r file -s 121 -e 150 -cam renderCam2 myScene.mb
    render -r file -s 1-e 120 -cam renderCam1 myScene_part2.mb
  4. Save the scene as a .batch file, and save it in the same directory as the scenes you wish to render, usually the renderScenes directory. The file can be named anything, but it should end in .batch. Make sure the format is plain text, for example, weekendRender.batch.

  5. In the Maya Terminal window, navigate to the location of the batch file (in the renderScenes folder of the current project). Convert the batch file to an executable by typing chmod 777 weekendRender.batch.

  6. In the Maya Terminal window, navigate to the location of the batch file and type ./weekendRender.batch.

The scenes will render in the order in which they are listed in the batch file.

mental ray Quality Settings

The quality of your render is determined by a number of related settings, some of which appear in the Render Settings window and some of which appear in the Attribute Editor of nodes within the scene. Tessellation, anti-aliasing, sampling, and filtering all play a part in how good the final render looks. You will always have to strike a balance between render quality and render time. As you raise the level of quality, test your renders and make a note of how long they take. Five minutes to render a single frame may not seem like much until you're dealing with a multilayered animation that is several thousand frames long. Remember that you will almost always have to render a sequence more than once as changes are requested by the director or client (even when you are sure this is the absolute final render!).

In this section, you'll learn how to use the settings in the Quality tab as well as other settings to improve the look of the final render.

Tessellation and Approximation Nodes

At render time, all the geometry in the scene, regardless of whether it is NURBS, polygons, or subdivision surfaces, is converted to polygon triangles by the renderer. Tessellation refers to the number and placement of the triangles on the surface when the scene is rendered. Objects that have a low tessellation will look blocky compared to those with a high tessellation. However, lower-tessellation objects take less time to render than high-tessellation objects (Figure 12.47). Tessellation settings can be found in the shape nodes of surfaces. In Chapter 3, the settings for NURBS surface tessellation are discussed. The easiest way to set tessellation for NURBS surfaces is to use the Tessellation controls in the shape node of the surface. You can also set tessellation for multiple surfaces at the same time by opening the Attribute Spreadsheet (Window

Tessellation and Approximation Nodes

You can also create an approximation node that can set the tessellation for various types of surfaces. To create an approximation node, select the surface and choose Window

Tessellation and Approximation Nodes
In the top image, the background structure has a low tessellation setting. In the bottom image, the same geometry is rendered with a high tessellation setting.

Figure 12.47. In the top image, the background structure has a low tessellation setting. In the bottom image, the same geometry is rendered with a high tessellation setting.

The editor allows you to create approximation nodes for NURBS surfaces, displacements (when using a texture for geometry displacement), and subdivision surfaces.

To create a node, click the Create button. To assign the node to a surface, select the surface and select the node from the drop-down menu in the Approximation Editor; then click the Assign button. The Unassign button allows you to break the connection between the node and the surface. The Edit button allows you to edit the node's settings in the Attribute Editor, and the Delete button removes the node from the scene (see Figure 12.48).

You can assign a subdivision surface approximation node to a polygon object so the polygons are rendered as subdivision surfaces, giving them a smooth appearance similar to a smooth mesh or subdivision surface. In Figure 12.49 a polygon cube has been duplicated twice. The cube on the far left has a subdivision approximation node assigned to it. The center cube is a smooth mesh. (The cube is converted to a smooth mesh by pressing the 3 key. Smooth mesh polygon surfaces are covered in Chapter 4.) The cube on the far right has been converted to a subdivision surface (Modify

In the top image, the background structure has a low tessellation setting. In the bottom image, the same geometry is rendered with a high tessellation setting.
The Approximation Editor allows you to create and assign approximation nodes.

Figure 12.48. The Approximation Editor allows you to create and assign approximation nodes.

Three duplicate cubes are rendered as smooth surfaces using an approximation node, a smooth mesh, and a subdivision surface.

Figure 12.49. Three duplicate cubes are rendered as smooth surfaces using an approximation node, a smooth mesh, and a subdivision surface.

When editing the settings for the subdivision approximation node, the Parametric Method option is the simplest to use. You can use the N Subdivisions setting to set the smoothness of the render. Each time you increase the number of subdivisions, the polygons are multiplied by a factor of four. A setting of 3 means that each polygon face on the original object is divided 12 times.

Anti-Aliasing and Sampling

The anti-aliasing settings in the Quality tab of the Render Settings window are used to control and reduce flickering and artifacts that can appear along the edges of 3D objects or within the details of high-contrast or detailed textures applied to surfaces. Flickering in high-contrast textures is not noticeable in still frames, only when a sequence of frames is rendered and played back. This is why it's often important to test short sequences of your animations when adjusting the quality.

To minimize flickering and artifacts, you can adjust the settings found in the Anti-Aliasing Quality section of the Render Settings window (see Figure 12.50).

You can control the anti-aliasing quality in the Anti-Aliasing Quality section of the Quality tab in the Render Settings window.

Figure 12.50. You can control the anti-aliasing quality in the Anti-Aliasing Quality section of the Quality tab in the Render Settings window.

The two main controls are the Sample Levels and Anti-Aliasing Contrast. When adjusting the sampling level, you can choose among Fixed, Adaptive, and Custom sampling modes.

Sampling refers to how mental ray determines the color of a pixel in a rendered image of a 3D scene. A camera emits a number of rays into the scene (known as Primary Eye Rays) to determine the initial color value that will be created for the individual pixels in the final image. After sampling occurs, filters are applied to average the color values for each pixel in the final image. Secondary rays may be cast into the scene to determine raytracing effects such as reflections and refractions.

The type of Primary Eye Ray is determined by the Primary Renderer setting in the Features tab of the Render Settings window. Usually this is set to Scanline for most renders. Secondary rays are specified by the options in the Secondary Effects section of the Features tab (see Figure 12.51).

The settings in the Features tab determine the type of Primary Eye Ray cast by the rendering cameras to sample a 3D scene.

Figure 12.51. The settings in the Features tab determine the type of Primary Eye Ray cast by the rendering cameras to sample a 3D scene.

mental ray evaluates the render using tiles. A tile is a square section of what will become the rendered image. As mental ray renders the image, it stores the samples for each tile in the sampling Frame Buffer. Once the samples have been collected for a tile, filters are applied to average the colors. The filtered samples are translated into color values and then stored in the image buffer. A tile defines a region of samples that will become pixels in the final image.

The Min and Max Sample Levels determine the sampling range. mental ray uses the Min Sample Level as a starting point and then evaluates the scene and determines whether any parts of the scene require additional samples. If so, more samples are taken. The number of additional samples is determined by the Max Sample Level.

Sample levels increase by a factor of 4. A Sample Level of 0 means that each pixel in the image receives 1 sample. A sample level of 1 means 4 samples per pixel. A sample level of 2 means 16 samples per pixel and so on.

Negative values mean that each sample contains a number of pixels. A sample level of −2 means that one sample is used for an area of 16 pixels in the rendered image. Again, the number of pixels in negative sampling increases by a factor of 4. As you change the sampling, the number of samples that will be used is displayed in the Render Settings window under Number Of Samples (see Figure 12.52).

As the sampling rate is increased, the render time increases significantly. The Sampling Mode option can be used to increase the efficiency of the sampling process. When Sampling Mode is set to Fixed, mental ray uses the sampling level specified by Max Sample Level. This is often useful for rendering with Motion Blur. When Sampling Mode is set to Adaptive Sampling, mental ray uses one level below the Max Sampling Level as the minimum and one level above the Max Sampling Level as the maximum. In other words, when Max Sampling Level is set to 2, the minimum becomes 1 sample per pixel and the maximum becomes 16 samples per pixel. When Sampling Mode is set to Custom Sampling, you can enter your own values for Min Sample Level and Max Sample Level.

As you adjust the Min Sample and Max Sample Levels, the range of samples is displayed next to Number Of Samples.

Figure 12.52. As you adjust the Min Sample and Max Sample Levels, the range of samples is displayed next to Number Of Samples.

So how does mental ray know when a pixel requires more sampling? Mental ray uses the Anti-Aliasing Contrast value to determine if a pixel requires more sampling. Lower Anti-Aliasing Contrast values increase the likelihood that addition sampling will be required.

The best approach to take when setting the sampling level is to adjust Anti-Aliasing Contrast gradually before increasing the Min and Max Sampling Levels. You'll notice that the Production Quality preset uses Adaptive Sampling with a Max Sampling Level of 2 and an Anti-Aliasing Contrast setting of 0.1. If you find this is not sufficient, try lowering the Anti-Aliasing Contrast setting. Try a setting of 0.05. If your image still has artifacts, you may then consider raising the Max Sample Level.

If you image has large blank areas and only small portions of detail, try setting a Min Sampling Level of 0 or −1 and a Max Sampling Level of 2. This way sampling is not wasted in areas where it is not needed.

Other options include adjusting the textures, applying filtering to the textures, or using the mental ray overrides on individual surface shape nodes to adjust the sampling for whichever surface is causing problems.

You can get a sense of how the sampling is being applied in a render by activating the Diagnose Samples option (found in the Raytrace/Scanline Quality section in the Quality tab of the Render Settings window) and performing a test render. The rendered image will show areas of higher sampling in white and lower sampled areas in black (Figure 12.53).

You can visualize areas of high sampling in a test render when Diagnose Samples is activated.

Figure 12.53. You can visualize areas of high sampling in a test render when Diagnose Samples is activated.

Filtering

Filtering occurs after sampling as the image is translated in the Frame Buffer. There are a number of different filters you can apply, found in the menu in the Multi-Pixel Filtering section of the Render Settings Quality tab. Some filters blur the image while others sharpen the image. The Filter Size fields determine the height and width of the filter as it expands from the center of the sample across neighboring pixels. A setting of 1 × 1 covers a single pixel, and a setting of 2 × 2 covers four pixels. Most of the time the default setting for each filter type is the best one to use.

The Box filter applies the filter evenly across the image's height and width. Triangle and Gauss filters both add a small amount of blurring to the pixels, while Mitchel and Lanczos both sharpen the image.

The Jitter option reduces flickering or banding artifacts. Jittering offsets the sample location for a given sample block in a random fashion.

The Sample Lock option locks the sampling pattern. This reduces flickering by forcing mental ray to sample the scene the same way for each frame. It can be useful in animated sequences and when using Motion Blur. If Sample Lock does not reduce flickering, try Jitter as an alternative.

Rasterizer

The Rasterizer is an alternative to the Scanline and Raytrace renderers that uses a different sampling algorithm. You can choose Rasterizer as your Primary Renderer in the Features tab of the Render Settings window. Rasterizer is most often used for scenes with motion blur or scenes with hair. It handles large amounts of overlapping thin surfaces (such as hair) quite well.

When Rasterizer is chosen as the Primary Renderer, the options for Raytrace/Scanline Quality sampling in the Quality tab become unavailable. Instead you can use the Visibility Samples and Shading Quality settings in the Rasterizer Quality section of the Quality tab (see Figure 12.54).

Visibility Samples works much like the Max Sample Level setting in the Raytrace/Scanline Quality options; however, the Rasterizer is not adaptive. The default setting of 0 means that one sample is used for anti-aliasing. Shading Quality sets the number of shading samples per pixel. The Rasterizer caches the samples with the geometry in the scene, so sampling actually travels with moving geometry. This is why it is an ideal algorithm for use with motion blur. Motion blur is discussed in Chapter 2.

When you choose Rasterizer as the Primary Renderer, the Rasterizer Quality options become available.

Figure 12.54. When you choose Rasterizer as the Primary Renderer, the Rasterizer Quality options become available.

Raytrace Acceleration

Raytrace Acceleration settings are found in the Raytrace settings in the Render Settings Quality tab. The purpose of these settings is to improve the speed of your renders when raytracing is enabled. Changing the settings does not affect how the image looks, only how fast it renders.

Raytracing is a process where rays are shot into a 3D scene from the rendering camera. When Raytracing is used as the Primary Renderer (this is set in the Features tab), each ray shot from the camera is compared with every triangle face of every piece of geometry in the scene to determine if additional rays are required for reflection or refraction (recall that all geometry is tessellated into polygon triangles when the scene is rendered).

To reduce the number of comparisons made between each ray and each triangle, mental ray offers several versions of the Binary Space Partition (BSP) algorithm (see Figure 12.55), which is meant to accelerate the process. The BSP algorithm divides the scene into sections; each section is a 3D container known as a voxel. The number of calculations required for each ray is limited to the number of triangles within a section of the scene as defined by the algorithm. In the Acceleration Method menu, you'll find Regular BSP, Large BSP, and BSP2. The Large BSP method is meant for use with large scenes; it does a better job of managing memory through disk swapping than Regular BSP. The BSP2 method does not allow you to set the Size and Depth options. BSP2 is also useful for large scenes and whenever a large number of instances are present.

The voxels created by the BSP method are adaptive. If needed, a voxel can be subdivided into smaller voxels. The lowest level of division is a voxel that contains only triangles; such voxels are known as leaf nodes.

You can set Bsp Size and Bsp Depth. Bsp Size refers to the maximum number of triangles a voxel can contain before it is subdivided. Bsp Depth sets a limit on the number of times a voxel can be subdivided. When tuning the performance of raytrace acceleration, you want to balance the size of the voxels against the voxel depth. A large voxel size means that each ray must make a large number of comparisons as it enters a voxel. A large depth value requires more memory to store the calculations for each voxel as well as more time for determining the placement and division of the voxels. Voxel depth has a larger impact on render time than voxel size.

You can use a separate BSP tree (a BSP tree is the hierarchy of voxels created in the scene) to calculate raytraced shadows. This is activated by turning on Separate Shadow Bsp.

mental ray offers three versions of the BSP Acceleration Method for improving the speed of raytrace calculations.

Figure 12.55. mental ray offers three versions of the BSP Acceleration Method for improving the speed of raytrace calculations.

Diagnose BSP

Tuning BSP settings often takes a fair amount of testing, trial, and error. You can create a visual representation of how BSP is calculated by activating the Diagnose Bsp setting. This allows you to see a color-coded version of the scene based on the BSP size or depth.

  1. Open the carSceneBSP_v01.ma scene from the chapter12scenes directory on the DVD.

    This scene uses very simple standard Maya shaders to create reflective materials on the car and the structure behind it.

    When diagnosing acceleration, you can speed up the process by lowering the sampling in the scene and, in the case of this scene, turning off Final Gathering.

  2. In the Indirect Lighting tab, deactivate Final Gathering. In the Quality tab, set Sampling Mode to Fixed and the Max Sample Level to −3.

  3. In the Acceleration section, set Diagnose Bsp to Depth. Then open the render view, and create a test render using the renderCam camera.

    The scene renders in a very low quality, but this is perfectly fine; you want to pay attention to the colors in the image. Areas that are red indicate that the maximum number of subdivisions for the voxels that contain those triangles has been reached. You'll see this around the detailed wheel section and on parts of the structure. Ideally you want to see orange and yellow in these areas and less red. To fix this, raise the Bsp Depth setting.

  4. Set Bsp Depth to 45 and create another test render (Figure 12.56).

  5. Set the Diagnose Bsp menu to Size and create another test render.

For the most part the scene appears in blue, indicating that the voxel size is more than adequate. You can try lowering this value, but for this particular scene a size of 10 is fine. If you prefer to have a more detailed report of the impact of the BSP Acceleration settings, set the Verbosity of the output messages to Progress Messages (you can do this in Render Current Frame

Diagnose BSP
The Diagnose Bsp option color codes the render based on the voxel depth set in the Acceleration options.

Figure 12.56. The Diagnose Bsp option color codes the render based on the voxel depth set in the Acceleration options.

The Bottom Line

Use render layers

Render layers can be used to separate the elements of a single scene into different versions or into different layers of a composite. Each layer can have its own shaders, lights, and settings. Using overrides you can change the way each layer renders.

Master it

Use render layers to set up alternate versions of the space helmet. Try applying contour rendering on one layer and Final Gathering on another.

Use render passes

Render passes allow you to separate material properties into different images. These passes are derived from calculations stored in the Frame Buffer. Each pass can be used in compositing software to efficiently rebuild the rendered scene. Render Pass Contribution Maps define which objects and lights are included in a render pass.

Master it

Create an Ambient Occlusion pass for the minigun scene.

Perform batch renders

Batch renders automate the process of rendering a sequence of images. You can use Maya's Batch Render options in the Maya interface or choose Batch Render from the command prompt (or Terminal) when Maya is closed. A batch script can be used to render multiple scenes.

Master it

Create a batch script to render five fictional scenes. Each scene uses layers with different render settings. Set the frame range for each scene to render frames 20 through 50. Each scene is named myScene1.ma through myScene5.ma.

Use mental ray quality settings

The settings in the Quality tab of the Render Settings window allow you to adjust the anti-aliasing quality and the raytrace acceleration of a scene (among other things). Sampling improves the quality of the image by reducing flickering problems. Raytrace acceleration does not affect image quality but improves render times when raytracing is activated in a scene.

Master it

Diagnose both the sampling and the BSP depth of the helmetComposite_v04.ma scene.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset