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

Set up the lesson:

Measure distances:

  1. Activate the Top viewport and press Alt+W to maximize it.
  2. Locate the Camera-Chair camera.
  3. On the Create panel, activate (Helpers). On the Object type rollout, click to activate 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:

Save your work:

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.