Depth of Field

DepthOfField_Banner.png

Depth of Field (DOF) applies a blur to the scene based on distance in front of or behind a focal point, similarly to what happens in real-world cameras. The effect can be used to draw the viewer’s attention on specific subject of shot based on depth and adding an aesthetic to make the rendering appear more like a photograph or like a movie.

Depth of Field Types

There are several methods of performing depth of field effects in Unreal Engine 4 that you can use. These have been broken into two categories:
  • Cinematic: These methods provide a cinematic and filmic look to depth of field effects. The adjustments for these methods also align more with common camera options available in photography and cinematography. These methods are also considered too expensive for use with Mobile platforms but work well for Desktop and Console platforms. 
  • Mobile: This method provides optimized and lower-cost depth of field options considered acceptable for Mobile platforms. 

Select from the methods below to learn more about their features:

Implementation

Depth of Field is broken up into three layers; Near, Far, and the Focal Region. Each of these is processed separately and then later composited together to achieve the final effect. Objects in the Near and Far layers (objects not in the Focal Region) are always fully blurred. These layers are blended with the non-blurred scene.

  • Objects within the Focal Region (Black) use the non-blurred scene layer.
  • Objects in the Near (Green) or Far (Blue) layers but outside any transition regions are fully blended to the blurred layer.
  • Objects within the transition area are blended linearly between the non-blurred scene layer and their blurred layer based on their position within the transition region.

Visualizing Depth of Field

These layers, including transition regions, can be visualized using the Depth of Field Layers showflag in the Level Viewport under Show > Visualize.

Scene

Layer Visualization

Visualizing the Depth of Field Layers also includes useful information relevant to the DOF method being used, such as values that are currently set or when moving the mouse around the scene, the distance from the camera to the Actor is displayed next to the mouse cursor.

DepthOfFieldVisualization_Stats.png

Using DOF in the Editor

Using Depth of Field in Unreal Editor can be done in a few different ways; by placing a Post Process Volume, using a Camera Actor, or a Cine Camera Actor. Each of these has access to DOF properties via the Post Process Volume and Camera. For Cine Camera, there are some additional industry standard settings for cameras and lenses.

The majority of settings used can be accessed under the Lens tab in the Camera and Depth of Field sections. When selecting a DOF method, the properties that affect that method will be editable with others being grayed out (even if they are enabled with a checkbox next to them).

Click image for full size.

When using a Cine Camera Actor, replacing properties that affect depth of field can be found under the Current Camera Settings in the Lens Settings section.

Click image for full size.

If you’re using a Camera or Cine Camera Actor, you can inhabit them using Actor Piloting in the Level Viewport by selecting the Perspective and choosing from one of the placed Cameras in the scene.

Click image for full size.

The Level Viewport will snap to the camera’s view and indicate that you are piloting and viewing what that camera sees.

DoF_PilotCamera_Status.png

Any properties that are changed in the Camera or Post Process Volume (if the Camera is within it) will immediately take effect in the viewport. 

To achieve similar results as the shot above, the key is to use a low Aperture (F-stop) to get a large Bokeh shape, move the camera or viewport position closer to an object and change the Field of View (FOV) to be lower. Then, adjust the Focus Distance to get some scene content to be out of focus in front and behind the focus plane.

Using Cinematic Camera's Debug Focus Plane

While using the Cine Camera Actor, enable Draw Debug Focus Plane to see where focus is placed in your level.

Click image for full size.

When enabled, the focus plane will be drawn at the currently set Manual Focus Distance from the camera. In this case, the character is the focal point where everything is sharp and in focus. Anything in front or behind the focus plane will be out of focus.

Draw Debug Focus Plane: Disabled

Draw Debug Focus Plane: Enabled

Use Debug Focus Plane Color to customize the RGBA color values for the focus plane being drawn. This is helpful in scenes where it may be hard to see the focus plane being drawn.