Rendering Tutorials >
Using the Depth-of-Field Camera Effect

This tutorial shows how to use the mental ray Depth-of-Field render effect to increase the realism of your renderings.

Depth of field is a technique used to focus on a fixed point in a scene, called a focal plane. The area of the focal plane remains in focus, while objects closer than the focal plane, and farther from it, are blurred. This is how real-world cameras work, and using Depth of Field can make it appear as if the rendering were a photograph.

Skill level: Intermediate

Time to complete: 45 minutes

Preparation for This Tutorial

- If you have not already downloaded the tutorial files (MAX scenes and other assets), download them now and unzip them into a project folder called \Autodesk 3ds Max Design 2012 tutorials. See Where to Find Tutorial Files.
- On the Quick Access toolbar, click (Project Folder) and set your current project to Autodesk 3ds Max Design 2012 Tutorials.

Set up the lesson:

- On the Quick Access toolbar, click (Open File), navigate to the \scenes\rendering\rendering_effects folder, and open med_villa_rendering_dof.max.
  NoteIf a dialog asks whether you want to use the scene’s Gamma And LUT settings, accept the scene Gamma settings, and click OK. If a dialog asks whether to use the scene’s units, accept the scene units, and click OK.

Measure distances:

1. Activate the Top viewport and press Alt + W.
2. Locate the Camera-Chair camera.
3. On the Create panel, click (Helpers). On the Object type rollout, click Tape.

   You will use the Tape helper to determine the distance between the camera and three objects in the scene: a chair, a flower pot, and a corner of the building. The location of each object will become a focal plane, or region where the scene is in the sharpest focus.

4. Click on the center of the camera object and drag to the closest chair, as shown in the next illustration.

   On the Parameters rollout, the Length field displays the distance between the two objects as roughly 2.3 meters.

5. Press Delete to delete the Tape helper.
6. Click on the camera again, then drag to the flower pot across the pool.

   The Length field displays a length of about 20 meters.

7. Press Delete to delete the Tape helper.
8. Click on the camera, then drag to the lower-left corner of the villa.

   The Length field displays a length of about 28 meters.

9. Press Delete to delete the Tape helper, and then right-click to exit Helper creation mode.

Now that you know the distances, you will use the chair in the foreground as the focal plane for the first rendering.

Adjust the f-stop and focus plane:

1. Press Alt + W to return to a four-viewport layout, then activate the Camera-Chair viewport.
2. On the main menu, click (Rendered Frame Window) to display the rendered frame window.
3. On the Rendered Frame Window, click (Render Setup).
4. In the Render Setup dialog Renderer tab Camera Effects rollout Depth of Field group, turn on Enable.

   The depth-of-field render effect works only in Perspective viewports, so now you need to change the viewport view.

5. Press P to switch the Camera-Chair viewport to a Perspective view.
6. In the Render Setup dialog Camera Effects rollout Depth of Field group, leave the drop-down list set to F-Stop (the aperture setting). This lets you specify the degree of blurriness of objects that are not in focus.
7. In the Focus Plane spinner, set the distance you measured from the camera to the chair, 2.3m, and in the f-Stop spinner, set the aperture to 2.8.

   The lower the aperture, or f-stop setting, the larger the aperture and the more blurred the out-of-focus regions become.

   Leave the Render Setup dialog open for now (move it if it obscures the Rendered Frame Window).

8. On the Rendered Frame window, click the Render button to render the scene.

   The focal plane, which is set to the chair in the foreground, is in the sharpest focus, while the background becomes progressively more blurred.

Use the other two focal planes to create renderings:

1. On the Render Setup dialog, change the Focus Plane to 20.0m, then render the Perspective viewport again.

   The area in sharpest focus is now the flower pot and the plant in it. All objects in the foreground and, to a lesser extent, the background are blurred.

2. Change the Focus Plane to 28.0m, then render the Perspective viewport again.

   All objects in the foreground are blurred, while the house is mainly in focus.

   One last adjustment remains. You will now adjust the f-Stop to make the foreground less out of focus.

Use the f-stop setting to control the depth-of-field effect:

- Set the f-Stop to 5.6, then render the Perspective viewport again.

  The foreground is much more defined than in the previous rendering.

  Above: f2.8 creates a narrow focal range

  Below: f5.6 creates a deeper focal range

  NoteYou can also sharpen the foreground image by dragging the Image Precision (Antialiasing) slider in the Rendered Frame Window to the right, but this option greatly increases render time.

Save your work:

- Save the scene as my_villa_focal_planes.max.

Summary

The Depth-of-Field camera effect is an easy way to make it appear as if your rendering was taken by a real-world camera.