Community
Maya Shading, Lighting and Rendering
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya materials topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to render the alpha channel of the depth of field of my camera

2 REPLIES 2
Reply
Message 1 of 3
elnelly91
1551 Views, 2 Replies

How to render the alpha channel of the depth of field of my camera

Hi! I have activated the depth of field of my camera and I have set his attribute.

Now I would like to render the resulting z depth channel of it. But how?

I won't the normal method to obtain the depth of field, i would like to have the depth of field channel derived from the attribute Depth of Field that I have activated in the Attribute editor of the camera.

It's possible?

Thanks! 🙂

2 REPLIES 2
Message 2 of 3

Z Depth AOV is what you're looking for. Give this short tutorial a try and let me know if you get the result you want.

 

Beauty render composited with Z Depth AOV (rollover image).

 

In this short tutorial we will cover the process of setting up and rendering out a 'Z' depth AOV from MtoA which can then be composited with the beauty render in Nuke to achieve a realistic depth of field effect. The 'Z' depth AOV contains the depth information of the shading points.

The scene file can be downloaded here.

 

To render and composite a 'Z' depth AOV, you must do the following:

  • First, open the Render Settings window and go to the 'AOVs' tab. Create a Z depth AOV. It is one of the AOVs available under the <builtin> 'AOV Group'. 

 

  • Under AOVs, to the right of the newly created 'Z' AOV there is a downward pointing arrow. Click on that and choose 'Select Driver' from the menu.

 

  • The Arnold driver should appear in the attribute editor. Select 'Merge AOVs'. This will combine the 'Z' AOV with the rendered EXR as one file.

Enable 'Merge AOVs' stores the AOVs in one EXR file

 

  • Render the scene and open the EXR file in Nuke. 

When viewing the depth AOV in Nuke it might only show red. The Depth channel will give you non-antialised, non-normalized depth data in the alpha channel. Non-normalized means that the Z depth values are not between 0 and 1 (distance in front of the camera), so you must divide the Z values by the far clipping plane value to get 0..1 values. This remapping is only required when viewing the depth channel in the viewer. It is not needed to make the zdefocus node work.

Z depth channel viewed within Nuke

 

  • Connect a 'Zblur' ('ZDefocus' in Nuke 7) to the EXR render and enable 'focal-plane setup'. The default setting of the Zblur node should work. Z should be set to 'depth.z' and 'math' should be set to 'depth' (the Z value in the depth channel is the distance in front of the camera).

 

  • Adjust the 'focus plane' until the green area is where you want the area of focus to be. The red color shows the area that has less depth of field. The blue color represents the area that falls outside the depth of field area. The green color represents the area that is inside the area of depth of field. If the depth parameter is set to 0, you will not be able to see any green. 

Focal-plane setup enabled (green area is in focus)

 

  • Once you are happy with the 'focus plane', disable 'focal-plane setup'. Increase the 'depth-of-field' to one. You should now see the RGB image being blurred by the 'Zblur' node.

 

That concludes this short tutorial. The benefits of using a Z Depth AOV are obviously speed and flexibility. Being able to make changes to the depth of field in the compositor in real time is a big advantage. Rendering with true depth of field, whilst looking better in most cases, can require a large number of AA samples in order to resolve issues with noise. Below is a comparison between rendering true depth of field and rendering the scene without DOF (using a composited 'Z' depth AOV). Even with 8 AA samples there is still some noise in the heavy depth of field areas of the image rendered with true depth of field. In this case, the render with true DOF took about twice as long to render as the image using a Z Depth AOV.

  

Limitations

There are limitations to using a 'Z' depth AOV. For example, it is not possible to focus on an object reflected in a mirror (see below):

Focusing on an object in a mirror is not possible using a 2d 'Z' depth AOV (above image rendered with true depth of field).

 


Faline Custodio Da Silva

Message 3 of 3

Tank you Faline!
I use Maya 2014 without Arnold. But I know the way to realized a depth of field map. I can use the Luminace Depth.

And I understand how to make a z defocus with zDefocus of Nuke. My question is different.

Is possible to have an image from the depth of field of the camera in Maya and then composite it in Nuke?
Or have I to render it only with my diffuse pass and cant composite in a second moment?
Cattura.JPG

I would like to make an approssimatively DOF in Maya Usinf Focus distance and F stop and then adjust in Nuke.
Not made an image of the depth of field and realized completely in nuke.

I hope I explained my question, Im not good in english Smiley Very Happy

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report