Creating Depth Of Field Using Maya Z-Depth Passes And Photoshop

Creating Depth Of Field Using Maya Z-Depth Passes And Photoshop

Tutorial Details

Final Product What You'll Be Creating

Depth of field can prove to be a very effective way to add an overall sense of depth to your final renders, and also helps to draw the viewers focus to a specific area of the image (similar to a real world camera.) In this short tutorial Pratik Gulati, will cover the process of setting up and rendering out Z-Depth passes from Maya, which can later be combined with the beauty pass in Photoshop, to achieve a realistic DOF effect.

The gray values within a depth pass represent the distance from the camera, where white is near and black is far. The range in Maya units that this represents is based on the rendered camera’s clipping planes. For this tutorial, I’ll be using Maya 2011 but the steps can be easily followed in both older and newer versions of Maya too.


Step 1

So the first thing to do is open your program.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 2

First create a simple scene using basic primitives, to test and render out our Z-depth pass (I’ve created a Plane and some Spheres.)

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 3

Next, select all the objects in the scene and create a new render layer with the selected objects.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 4

Maya method:

Right click (on the render layer) to open the "Attributes". This will open up a new window in the layer presets, select "Luminance Depth" from the menu.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 5

Select the camera (View>Select Camera) and open it’s Attributes, make sure "Depth" is checked under the "Output Settings".

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 6

In the Edit Render Settings, we change the "Image" Path to our desired location so that we can save out the rendered images.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 7

Now we can do a "Batch Render" (Render>Batch Render) of our render layers and we will get the following output.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field
Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 8

Now for the MentalRay method:

First, we need to assign "Mental Ray" as our renderer by changing "Render Using" to "Mental Ray".

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 9

In the Render Passes options, I create a new "Camera Depth" pass. Then click on the Green Tick Icon, which will associate the selected pass with the current render layer.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 10

In the "Quality" tab, I increase the Sampling Quality as shown below, to get more refined and crisp edges in the render.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 11

We now render out the images using the "Batch Render" (Render>Batch Render) option.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 12

We now bring both our Z-depth render and Normal render into Photoshop.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 13

Now we copy the Z-depth image (Ctrl+A + Ctrl+C) and paste (Ctrl+V) it into the "Alpha" channel of our normal render.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 14

We now have the Z-depth render in the alpha channel. We next apply a "Lens Blur" filter by going to Filter>Blur>Lens Blur.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 15

This opens a new console. We first turn on the "Preview" option (by checking the box), so we can see the effect in real-time, we also need to choose "Alpha" as our source.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

Step 16

The "Blur Focus Distance" and the "Radius" settings are the most important parameters and will define the type of blur. If we decrease the distance setting, the blur will happen from the back to front. And if we increase it, it’s the opposite.

Rendering Z-depth passes in Maya and compositing in Photoshop to achieve realistic depth of field

You can experiment with these settings to achieve an overall Depth Of Field you’re happy with for your renders.


Related Tutorials:


Add Comment

Discussion 3 Comments

  1. Shlak says:

    Remember to put the output in 32bits, ifesle you have only 256 value of grey, not good for lens blur… This is not a real lens blur, it’s just a way to do it really quickly, you can also do it with the camera depth of field.

    Also, in Photoshop,you can click in the preview for define the area which is sharp.

    Hope that it will help;
    (I’m not english so sorry for my language !)

    In french >

    C est mieux si on sort une image 32 bits (exemple TGA, en ayant défini dans les préférences de rendu > Feature > framebuffer) Sans quoi on a a peine 256 valeurs de gris qui définissent les différentes zones de l ‘image… Pour finir on peut cliquer dans la preview de Photoshop pour définir le point de netteté…
    Il existe aussi dans maya un moyen de faire du flou d’objectif “vrai” (physiquement plus réaliste si je puis dire…)
    Bon courage, j espere que ça vous aura aidé a etre curieux !

  2. vidya says:

    Thank u soooooooooooooooooooooo much for posting this tut….. :) thanks a lot..

  3. balanescu says:

    How to control Depth of field in camera is mainly depended by aperture size though other factors come into play including the focal distance of the lens and the space the background is from the subject.

    just for share same article, check it here:
    http://photograpyreview.blogspot.com/2012/02/how-to-control-depth-of-field.html

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.