Another scene from "Vetri".

Quick Tip: Depth-of-Field in Blender

Danan how to, Quick Tips, tutorials Leave a Comment

In this quick tip post, I’ll show you how you can add depth-of-field effects to make you renders look awesome!

Difficulty level: Too easy!

Depth-of-field is a very common effect used in films, photography and 3D art and apart from being used as a stylistic effect, it also helps to drive the viewer’s attention to the object in focus. According to wikipedia, “Depth of Field (DOF) is the distance between the nearest and farthest objects in a scene that appear acceptably sharp in an image”.

We can use DOF right from within Blender to make our renders look more realistic and help guide the viewer’s attention.

Here are some examples of DOF being used in photography:

By Haseeb Ansar "Sarson Flower"

By Haseeb Ansar “Sarson Flower”

By Jynto "The Daisy Parade"

By Jynto “The Daisy Parade”

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Here, the flowers are in focus while the background/foreground are blurred out. Not only does this draw our attention to the flowers, but it makes the scene look beautiful! And this can be done straight from within Blender! Here are 2 ways to achieve DOF in Blender.

Using a Camera
Select the camera in your scene by right-clicking. Go to the camera settings by clicking the ‘Object Data’ window. In ‘Display’, tick the ‘limits’ box. This tells the camera the limit of visibility, but we will need it to see the yellow cross symbol which indicates the focal point. Next, in the ‘Depth of Field’ panel, select the distance where you want to focus the camera or select an object in which will automatically focus to.  Also select your aperture type (radius or f-stop). I usually choose f-stop as it mimics reality more closely. The value you enter here will determine the amount of blurring you get for out of focus objects.

Using the compositor
Alternatively, you can also use the compositor to achieve DOF effects. This tends to be used if camera DOF produces too much noise. The compositor can give a smoother result but not always a realistic result. To get the DOF working in the Node Editor, you still need to set up the aperture and distance in the ‘Depth of Field’ settings of the camera. Then in the Node Editor, Add –> Filter –> Defocus. Connect the image to the image socket of the Defocus node and similarly the Z pass to the Z socket of the Defocus node.Turn off ‘Preview’ and turn on ‘Use Z-Buffer’. This uses the distance value that you set in the camera settings. Change to your preferred Bokeh type (I use Pentagonal as it tends to give more professional results). Change your fstop value (lower value means more blurring for out-of-focus objects). The Max Blur options specifies the limit to how much blurring should occur. If you don’t wan’t too much blurring for out-of-focus objects, you can clamp it with this setting.

Just a tip, don’t go overboard with the blurring. Too much blurring, i.e, very low f-stop, will make your scene look very miniature. In other words, a large-scale landscape will look like a miniature toy model. Finding the right amount of f-stop can help make your renders more believable.

Here are some examples where I’ve used DOF in Blender:

Scene from "Vetri"

Scene from “Vetri”

Here I tried to create a comedic effect where the policeman is completely oblivious to the beating that’s going on in the background. DOF helps here since if I only focused on the thugs in the background and blurred out the policeman, it may not make sense to the viewer the message I’m trying to convey.

Another scene from "Vetri".

Another scene from “Vetri”.

I used it again here to draw attention to Vetri’s face and try and create a sense of emotion. I wanted the audience to feel Vetri’s pain of being told he failed his exams. Without DOF, it may not have been as emotional.