Finished sample (click to play / pause)
Download the example file to follow along (Maya 2019.2 or later)
Download the complete example file (Maya 2019.2 or later)
Software you will need:
- Autodesk Maya 2016 Extension 2 or higher
- Nuke 10 (licensed or non-commerical)
Setting up the Scene
You do not need to start with an empty scene. If there's already animation/lighting/vfx in the scene does not matter.- Open your 3D scene in Maya and open the Render Setup window (In Windows -> Rendering Editors -> Render Setup)
- Create a new Render Layer, and rename it to "Color"
- Right-click the layer and add a new collection
- Name it "Elements"
- In the outliner, select all your geometry and lights
- In the Property Editor of the Render Setup window, click the [Add] button.
- Create a new Render Layer and rename it to "zDepth"
- Create a new collection, rename it to "Geometry" and add only the geometry of your scene to it
- Create a new collection, and add all of your lights to it
- Disable the collection containing your lights (this way they don't shine and mess up the depth map
- In the Outliner, go to Display -> and uncheck "Show DAG shapes only"
- type "rs" into the search box and select the "rs_zDepth" entry. If no items show up, in the MEL entry field at the bottom of maya, type
select rs_zDepth
- In the Attribute Editor, Click Presets and click "Luminance Depth"
- A Surface Shader has been created, and the attribute editor should have switched to it. If it did not automatically switch, go to the Hypershade (Windows -> Rendering Editors -> Hypershade) and click the Surface Shader. Click the black triangle-box next to [Color]
- The Attribute Editor should have switched to a setRange node screen. Right click "Old Min" and "Old Max" and break the connections
- "Old min" is the value that determines the closeness of objects. Leave this value alone.
- "Old Max" is the number of units before the depth map becomes completely black. For My own scene, I
set this t0 250.
- Switch back to the Render Setup window. Right click the "Geometry" collection and select "Create Material Override"
- Open the Hypershade window (Windows -> Rendering Editors -> Hypershade)
- Select the surfaceShader, and middle-mouse drag it to the Override Material box in the
Render Setup View
- Select the surfaceShader, and middle-mouse drag it to the Override Material box in the
Render Setup View
- Click the eye icon on the zDepth layer to make it visible. All the objects in the scene should have a white-to-black gradient. Move the camera to see it update.
- Play around with the "Old Max" value and try to make the 100% black area be just at the far edge of the scene.
- (Optional, but adds to the visuals) Create another Render Layer and rename it to "Fog"
Note that you will need a render engine that understands volume primitives for this layer.
The only built in render engine that can do this is Maya Software, which works well enough.
- To create the objects for the fog pass,
- create a volume cube and encompass your whole scene with it.
- In the cubeFog properties, assign a Cloud texture to the transparency attribute. You don't
need to change anything about the fog pass.
- Create two collections for the Fog layer: "Fog_Object" and "Disable_Lights"
- Add your volume box to the "Fog_Object" collection
- Add all your lights to the "Disable_Lights" collection, and then disable the collection.
- Click the Eye to make the Fog Layer visible. You should only see the volume box and nothing else.
- To create the objects for the fog pass,
- In the Render Settings window, click the clapboard next to the default "Scene" render layer to disable it.
(It should not be blue)
- Set up your render settings how you like (I've found Mental Ray to create the best depth map), and render
your scene!
- Make sure that the Depth pass does not render a colored background (have a transparent background)
- It should create 3 folders in the images directory: "Color" "zDepth" and "Fog", each containing the
correct data.
Compositing the scene
You are done with Maya now. Make sure you like the output of your three image sequences before continuing to the next steps.If you prefer a different compositor and know how to composite the depth, then you can skip the rest of this document.
The Basics of Nuke:
- Creating nodes in nuke: Right Click in Node graph -> find node OR Press tab -> search for node by name
- Connecting nodes: Click and Drag the arrows on top of compatible nodes
- Editing Nodes: Double-click on node to open property panel, then drag sliders to modify values.
- Close Node: Press the [x] at the top right of the node property panel (next to the ? and Window buttons)
- Disable Node: Click on the node and press [D] on your keyboard
- Launch Nuke, and create a new project.
- Go to Edit -> Project Settings (or press [S] on your keyboard)
- Set frame range so it matches your image sequences, then close the panel
- Drag your image sequences from the file explorer into the project viewer (or import them from File ->
Import File(s))
- They should have rendered into 3 folders: "rs_Color" "rs_zDepth" and "rs_Fog"
- They should have rendered into 3 folders: "rs_Color" "rs_zDepth" and "rs_Fog"
- Click the Node Graph tab at the middle-right of the window
- Drag your sequences from the Project viewer into the node graph
- In the Node Graph, create a ShuffleCopy node
- Connect the (1) to the Color sequence and the (2) to the Depth sequence
- Set the properties as follows:
- Set the properties as follows:
- Create a Constant node, and set it to any color that's not black
- Create an AddMix node, and connect the (A) to the Constant, and the (B) to the Fog sequence
- Create a ZMerge node, and connect the (1) input to the AddMix node and the (2) Input to the ShuffleCopy node
- Z channel: depth.Z
- Alpha channel: depth.Z
- smaller Z = further away: checked
- Create a ZDefocus Node, and connect the (Image) input to the ShuffleCopy node
- math: depth
- blur inside: unchecked
- Create a Merge node, and connect the (A) input to the ZMerge node and the (B) input to the ZDefocus node
- Decrease mix to around 0.225
- Decrease mix to around 0.225
- Connect the Viewer input to the Merge node.
- Your node graph is done! Connect any extra nodes for further compositing to the Merge Node
Tweaking the setup:
To change how the different nodes interact, change the following values:- Depth of Field distance: In the ZDefocus node, change the Focus Plane attribute. Larger values = closer blurring Alternatively, you can drag the focal_point handle in the viewer to interactively set the focus plane.
- Depth of Field strength: Change the size value of the ZDefocus node.
- Depth of field end strength: Change the maximum value of the ZDefocus node.
- Fog Color: Change the color of the Constant node. If you want the color to be something else, just replace the Constant node with a different setup. Just make sure the final output of that setup outputs to the (A) input on the AddMix node.
- Fog Density: Change the mix value of the AddMix node
- Fog Distance/Intensity: Change the mix value of the Merge node (Not the ZMerge node!)
Rendering the final composite
To export your composite as a video file or as an image sequence, do the following:- Create a Write node and connect the input to the Merge node (if the viewer is already connected, just drag
the Write node over the dashed line)
- For a Video output
- file type: mov
- Codec: h.264 (if present) or Apple ProRes 4444
- For an image sequence output
- file type: select any image format (I recommend .exr or .tiff for preserving ultrawhite values, or .png for regular clamping.
- To render the alpha channel, set channels to rgba
- Click the folder icon next to file and select a folder to write the file in (make sure to include the extension!)
- To exclude the DOF disable the ZDefocus node (optional)
- Go to Render -> All Write nodes (or press F5 on your keyboard)
- (Optional) check render in background, set the frame range if incorrect, and press [OK]
- Wait for the render to complete (this can take a while on slow hardware)
Download the example file to follow along (Maya 2019.2 or later)
Download the complete example file (Maya 2019.2 or later) Note: the .mb file requires Maya 2017 to open without errors.