MayaRendering

Maya & Arnold – 4 Camera / Depth of Field Blur

By 1. November 2016 April 10th, 2018 No Comments

For animation and specific camera setup we need an extra camera for each shot. If you have not yet created a custom camera in the perspective viewport select > View > Create Camera From View (Ctrl+Shift+C). Rename the new camera and make it the active camera in the Viewport > Panels > Perspective > Your Camera Name. To activate the depth of field blur in the Attribute Editor go to the CameraShape node, activate “Enable DOF” in the Arnold section (not in the Depth of Field section, that’s for the Maya standard renderer) and increase the Aperture Size.

enabledof

With the default focus distance of 1 cm everything becomes blurred in the IPR.

defaultdof

To find out the right focus distance we need to measure it. Let’s temporarily hide unnecessary objects by hitting the “H” key. Switch to the default working camera in the Viewport > Panels > Perspective > persp. Activate “Snap to points” from the toolshelf and > Create > Measure Tools > Distance Tools.

distancetool

Click on the camera in the viewport and on the part of the object in your scene you want to have in focus.

distancemeasure

Apply the measured distance to the “Focus Distance” attribute in the Arnold section of our camera …

focusdistance

… and this part becomes sharper.

dofhighalllights

The DOF blur effect is still intense – great for making adjustments. If you don’t want to measure again when the focus distance has changed, first parent the camera locator by MMB dragging it onto the Camera in the Outliner.

camlocator

Rename the second locator to “Focus”. When you now move the camera or the “Focus” locator, the length value on the distance dimension tool should change. To connect the resulting length of the distanceDimension1 with the Arnold Focus Distance attribute in Camera1 just copy paste the following line into the “MEL” script field at the bottom left:

connectAttr -f distanceDimension1.distance Camera1Shape.aiFocusDistance;

Hit “Enter”. Important: To make the script work, your camera needs to be named exactly “Camera1” and the distance tool “distanceDimension1” in the Outliner. If you want to make it work with different names you need to adapt the strings in the script accordingly.

connectattr

If the script was successfully applied you can see in the Attribute Editor the Focus Distance of Camera1 became yellow and is now linked to the Distance Tool.

connectattrdone

For final rendering decrease the Aperture Size, I used here 2.

dofipr