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’ 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, that create real- istic 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 chapter12\scenes directory on the DVD.
2. In the Render Layer Editor, select the helmet layer.
Figure 12.18 Upgrade the shader to mia_material_x_
passes.
3. Click the Render Settings icon in the Render Layer Editor to open the Render Settings window, and choose the Passes tab.
4. Click the icon at the top of the stack of icons in the upper right. This opens the Create Render Passes window.
5. From the Pass list, select the Camera Depth pass, and click the Create button at the top of the window.
6. Use the same steps to create Reflection, Shadow, and Specular passes (Figure 12.19).
The passes have been created, but at the moment they are not associated with a render layer. You can create as many render passes as you like and then associate them with any combination of render layers in the scene—as long as those render layers are rendered using mental ray.
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, follow these steps:
a. Select the pass in the Associated Passes section.
b. Click the icon with the red X between the two sections.
Figure 12.19 Render passes are created and listed in the Scene Passes section on the Passes tab for the Helmet render layer.
This moves the pass back to the Scene Passes section. To delete a pass from either section, follow these steps:
a. Select the pass.
b. Press the Backspace key.
7. Close the Create Render Pass window.
8. In the Passes tab of the Render Settings window, Shift-select the depth, reflection, shadow, and specular passes in the Scene Passes section.
9. Make sure that the Render Layer menu at the top of the Passes section of the Render Settings window is set to helmet.
10. Click the clapboard icon with the green check mark (between the Scene Passes and Associated passes sections). This moves the selected scene passes to the Associated Passes section, meaning that the helmet render layer will now render the passes you’ve created.
11. Double-click the Depth pass in the Associated Passes list; this will cause its Attribute Editor to open.
12. Turn on Remap Depth Values, and set Far Clipping Plane to 20 (see Figure 12.20).
The scene size for this scene is 20 units in Z; by setting 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).
Figure 12.20 Edit the settings for the Depth pass in the Attribute Editor.
13. Double-click Reflection to open its settings in the Attribute Editor.
14. Raise Maximum Reflection Level to 10.
15. Create another test render from the Render View window using the renderCam camera.
You won’t notice anything special about the render; the render passes have already been saved to disk in a subfolder of the project’s Images directory, but they are not visible in the Render View window.
16. In the Render View window, choose File Load Render Pass Reflection (Figure 12.21).
This will open the IMF_Display application.
Sometimes this opens behind the Maya interface, so you may need to minimize Maya to see it. On the Mac, the IMF_display icon appears as three colored squares on the Dock.
17. Save the scene as helmetComposite_v03.ma.
The reflection pass shows only the reflections on the surface of the objects; the other parts of the image are dark. Thus, the reflections are isolated. You can view the other passes using the File menu in the Render View window. Figure 12.22 shows each pass.
Figure 12.21 Use the File menu in the Render View window to open the render pass images in IMF_Display.
Figure 12.22 Clockwise from the upper left:
Reflection, Shadow, Depth, and Specu- lar render passes as seen in IMF_display. The elements of the passes appear dark because they have been separated and rendered against black.