- Blender Cycles:Lighting and Rendering Cookbook
- Bernardo Iraci
- 694字
- 2021-07-19 18:48:18
Using the Cycles camera's depth of field
Creating images using a 3D program is often all about imitating reality. When we take a picture, something that often occurs is that some of the objects are out of focus. Such an effect is called depth of field (DOF) and is what we are going to recreate in this recipe.
Getting ready
Our first scene in Cycles is almost ready. However, we can still do a couple of things to make it look even more realistic. We will now see how to add a nice DOF effect.
How to do it...
To recreate the DOF effect in Cycles, let's follow these steps:
- Let's jump in now to our scene in Blender and select the camera. First of all we need to set the point in the scene where we want to keep the focus. To do this we need to select the camera and go to the Object Data menu (the one with the little camera icon).
- From here we need to activate the Limits option in the Display panel. In the viewport we will see that the camera now has a line going towards where it is looking and a yellow cross at the beginning. This cross represents the focus point.
- To set the focus point where we want it, we need to change the Distance value in the Depth of Field panel. We want the keyholder to be the focus point of the scene, so let's set the Distance value to
16
. The yellow cross will now be placed over the key holder. - For the DOF intensity, let's use Radius with a value of
0.0500
. We do not want an effect that is too strong. For this particular scene we will simulate a round iris so that the default values are ok. Now we have a nice DOF effect in our scene that helps add realism to it. This is how the camera settings should look like if we did everything correctly in the following screenshot:
How it works...
With Blender Internal, the only way of adding this kind of effect is in compositing. Even if this method is still possible—also in Cycles—we now have another way of achieving the DOF effect.
Cycles has a DOF system built inside the camera. This means that now we dispose of a real ray-traced DOF effect which is much more accurate than the previous one. It is necessary to remind you that this new method also has some drawbacks. For instance, we will be dealing with render passes, and we will see that DOF generates a big amount of noise around edges, which can make it difficult sometimes to composite the scene. Another drawback is that once we render the image, we will not be able to change the DOF until we render the image again. This can be a problem especially for animations.
Anyway, apart from these two aspects the method of achieving DOF is fast and the final quality is really high.
There's more...
Another method of setting the focus point is to use an object. Right above the Distance value there is a field where you can put the name of the object on which you want to set the focus. The yellow cross will now automatically follow this object. It is important to remember that this doesn't mean that the camera will follow this object, just the distance of the focus.
On the left of where we set the distance value for the focus of the camera, there are the settings for the DOF. We can use two methods to set the intensity of the DOF: Radius and F/stop (focus stop). Bigger values for the radius will mean stronger DOF. On the contrary, with the focus stop method we need to lower the value to have a stronger DOF.
Right under the intensity value there are the iris settings, which will determine the shape and rotation of the bokeh effect. We can decide what shape and rotation the latter will have. If we want to have a circle iris it is enough to leave the Blade value to 0
.