How to enable and control Depth of Field (DOF) in Corona for C4D?

This article explains how to enable the Depth of Field (DOF) effect in Corona and how to control its appearance. 

on-givsaa4-hc10-denoise.png

 

Table of Contents:

 

Enabling Depth of Field

When using a Corona Camera Tag:

Simply enable the Depth of Feild checkbox in the Corona Camera Tag you are rendering from (DOF > Override > Enable DOF):

 

dof.jpg

Once both checkboxes are enabled, Depth of Field options become active and are considered when calculating the Depth of Field effect (bokeh shape, center bias, vignetting, etc) at rendering time. 

 

When using the Camera/Postprocessing render settings:

Go to Render Settings > Corona > Camera/Postprocessing > Depth of field and enable its checkbox. You can then use the available settings to control the Depth of Field effect (bokeh shape, sensor width, F-stop): 

dof1.jpg

 

Notes: 

  • It is not possible to use the Depth of Field effect when using non-perspective camera projection.
  • The Depth of Field settings from the Render Settings window are overridden when setting up DOF from a Corona Camera Tag. The Corona Camera Tag has a higher priority. 

 

DOF Settings, Quality, Performance

Focal point distance

To determine the focal point distance, you can use the pointer tool found in the settings of the C4D camera and select what object the camera will be focused on. 

02_HowToControlDOF_Camera_FocalDistance_A.jpg

 

The focal distance can also be set by dragging your object into the object slot or using the pointer tool again to choose the focus target.

03_HowToControlDOF_Camera_FocalDistance_B.jpg

 

 

Photographic Exposure Controls

Depth of field is affected by photographic exposure controls. For example, the wider the aperture is open ie: F1.8, the more light that is let into the camera and hitting the sensor. More light entering a camera will result in a more pronounced (shallow) DoF effect and a brighter image overall. Stopping the lens down to F22 will decrease the amount of light that passes through the lens resulting in a sharper yet darker image, and the DoF effect will be less noticeable. 

04_HowToControlDOF_F-Stops.png

 

DOF Highlights Solver

When enabled, the DOF Highlights Solver greatly improves the quality of the blurring of any highlights in the rendered image (both reflections and directly-viewed lights):

 

dof-solver-on.png

[Click here to see interactive comparison]

 

You can find it in Render Settings > Corona >  Performance Settings and enable it with a single checkbox:

DOF

 

Important notes: 

  • The DOF Highlights Solver improves the quality of highlights at the cost of other rendering effects. This means that when rendering an image within a specific time limit (e.g. 10 minutes) with the DOF Highlights Solver enabled, the quality of some image effects, such as GI or anti-aliasing, may become slightly worse than in the case of rendering the same image for the same time with the DOF Highlights Solver disabled. 
  • Regular (non-highlights) DOF blurring is unaffected by the DOF Highlights Solver. This means that if you are rendering a scene with DOF, but there are no visible highlights in the image, enabling this option may not be beneficial. 
  • The Budget and Reprojection count settings are set to optimal values by default. Usually, there is no need to change them. 
  • At the moment, the DOF Highlights Solver is listed as Experimental, as there may be some cases where it does not work as expected. 
  • The DOF Highlights Solver works optimally with the High Quality image filter. It can be used with other filter types, such as Tent, but it may produce more noise and generally perform worse. 
  • The DOF Highlights Solver can only be used with non-VR perspective cameras without any distortion.
  • For further information on DOF Highlights Solver limitations, see: DOF Highlights Solver Error Messages

 

DOF Quality

The DOF Highlights Solver can greatly improve the quality of highlight blurring, but the overall quality of the depth of field effect (dark areas, object edges, etc.) is mainly dependent on anti-aliasing.

Even when using the DOF Highlights Solver to focus computing power more on anti-aliasing than on the GI sampling, thus increasing the rendering speed of DOF at the cost of other effects, you can decrease the "GI vs. AA balance" value to about 4-8. Values lower than 4 should be avoided because they usually increase render times without much anti-aliasing quality improvement. 

See: Where are supersampling / antialiasing controls in Corona?

 

DOF Quality - Examples with different render settings:

DOF Highlights Solver:

Render time: 10 minutes

GI vs AA set to 16 (default value)

DOF Highlights Solver on and off

on-default.png

[Click here to open the interactive comparison]

Conclusion: The DOF Highlights Solver improves the quality of out-of-focus highlights; still, enabling it can result in a slightly lowered quality of other effects, such as the GI. 

 

Lowering the GI vs AA value: 

Render time: 10 minutes

DOF Highlights Solver on

GI vs AA set to 16 and 4

on-givsaa4.png

[Click here to open the interactive comparison]

The differences are subtle (they are mainly visible at the central points of the DOF highlights), but the render stamp shows 69 passes rendered with GI vs AA set to 16 and 146 passes rendered with GI vs AA set to 4. With GI vs AA set to 4, roughly twice as many passes were rendered, which can be translated to "two times better anti-aliasing quality". 

You can switch to the Indirect Illumination Multi-Pass to confirm that increasing the quality of the DOF highlights comes at the slight expense of GI quality. More noise is visible, mainly close to the light source in the lower-right corner of the image. Click here to see the Indirect Illumination render element. 

Conclusion: lowering the GI vs AA value results in increased quality of the DOF highlights. This is again at some expense of GI quality. 

 

Increasing the GI vs AA value: 

Render time: 10 minutes

DOF Highlights Solver on

GI vs AA set to 16 and 64

on-givsaa4.png

[Click here to open the interactive comparison]

This example demonstrates how increasing the GI vs AA value makes the DOF quality worse. This is clearly visible on the DOF highlight edges and centers and is confirmed by the number of rendered passes - 69 with GI vs AA set to 16, but only 23 with GI vs AA set to 64. 

Conclusion: the higher the GI vs AA value, the lower the quality of DOF highlights. 

 

Highlight Clamping: 

To make the blurred highlights even "easier" to render for the DOF Highlights Solver, thus increasing the rendering speed at the cost of some realism and dynamic range in your image, you can enable highlight clamping

Render time: 10 minutes

DOF Highlights Solver on

GI vs AA set to 4

Highlight Clamping off (value set to 0) and on (value set to 10)

on-givsaa4-hc10.png

[Click here to open the interactive comparison]

Enabling Highlight Clamping slightly increases the quality of DOF effects, mainly by removing "fireflies" (single bright pixels). In this example, after changing the Highlight Clamping value from the default 0 (disabled) to 10, the number of passes increases from 143 to 146. Note that because of highlight clamping, the brightest parts of the image became darker.

Note: if you wish to save your output to a high dynamic range format, such as 32-EXR or HDR, by enabling Highlight Clamping, you lose some of the dynamic range. 

Conclusion: Highlight Clamping can be used to increase the quality of DOF highlights further, but the price is lowered brightness of the highlights and lack of high-dynamic range in the rendered image. 

 

Denoising:

Finally, you can enable denoising to reduce noise in the DOF highlights and all other areas of the image. 

Render time: 10 minutes

DOF Highlights Solver on

GI vs AA set to 4

Highlight Clamping on (set to 10)

Denoising on (Intel AI Denoiser) and off 

on-givsaa4-hc10-denoise.png

[Click here to open the interactive comparison]

Denoising smartly blurs noise in the rendered image. Remember that using high denoising values may blur too much of the image detail. In this example, the Intel AI Denoiser was used. 

 

The Corona Camera Tag is recommended

For the easiest control of Depth of Field, it is recommended to use a Corona Camera Tag on your camera. For example, F-stop settings from the native Cinema 4D camera will not affect DoF.

 

Fisheye Camera and DOF

Starting from Corona 9, it is possible to Enable the Depth of Field in a Fisheye Camera. Simply create a Corona Camera, go to the Attributes panel, open the Camera Projection, and set the Projection type to "Fisheye":

 

fisheye1.jpg

 

Scene Setup:

Corona_Camera_Fisheye_Scene_Setup.jpg

 

Render:

Corona_Camera_Fisheye_DOF_Example_01_Render.jpg

 

Troubleshooting

DoF effect is too weak; everything is sharp even if I set very low f/stop values such as 0.1

This may be caused by using a wrong scene scale. Incorrect units may be used. The dimensions of objects in the scene should correspond to the size of the camera's sensor width. If you are, for example, using millimeters instead of meters (or vice versa), you need to either rescale the scene or set the camera's sensor size to corresponding units (for example meters instead of millimeters).

 

Examples

DOF Highlights Solver

Render time: 10 minutes. DOF Highlights Solver disabled: 

off-default.png

[Click here to open the interactive comparison]

 

Render time: 10 minutes. DOF Highlights Solver enabled: 

on-default.png

[Click here to open the interactive comparison]

 

Render time: 5 minutes. DOF Highlights Solver disabled: 

dof-solver-off.png

[Click to see interactive comparison]

 

Render time: 5 minutes. DOF Highlights Solver enabled: 

dof-solver-on.png

[Click to see interactive comparison]

 

F-stop

As in photography, increasing the F-stop value will make the "Dof" effect more subtle. Decreasing the F-stop value will make it more pronounced.

 

F-stop = 2 - pronounced DoF effect
05_HowToControlDOF_Example_F-Stop_A.jpg

 

F-stop = 4
06_HowToControlDOF_Example_F-Stop_B.jpg

 

F-stop = 16 - subtle DoF effect

07_HowToControlDOF_Example_F-Stop_C.jpg

 

Target distance

Camera target placed on the rear end 20 marker:

08_HowToControlDOF_Example_TargetDistance_A.jpg

 

Camera target placed in the center (on the Corona logo):

09_HowToControlDOF_Example_TargetDistance_B.jpg

 

Camera target placed close to the camera on the front 20 marker:

10_HowToControlDOF_Example_TargetDistance_C.jpg

 

Sensor size

Sensor size also affects the appearance of the DoF effect. Increasing it makes the DoF effect more pronounced. Note: in Cinema 4D, changing the Sensor Size keeps the Focal Length static and automatically changes the Field of View; be sure to reset your Field of View after changing Sensor Size if you want to retain the same composition in your image.

F-stop=4, Sensor width=35mm

11_HowToControlDOF_Example_SensorSize_A.jpg

 

F-stop=4, Sensor width=100mm

12_HowToControlDOF_Example_SensorSize_B.jpg

 

Bokeh type

Circular:

13_HowToControlDOF_Example_Bokeh_A.jpg

 

Bladed:

14_HowToControlDOF_Example_Bokeh_B.jpg

 

Custom 1:

15_HowToControlDOF_Example_Bokeh_C.jpg

 

Custom 2:

16_HowToControlDOF_Example_Bokeh_D.jpg

 

Custom 3: "fake chromatic aberrations"

17_HowToControlDOF_Example_Bokeh_E.jpg

 

Advanced Bokeh Effects: Bokeh center bias = 1

18_HowToControlDOF_Example_Bokeh_F.jpg

 

Center bias = 1, Vignetting = 2

19_HowToControlDOF_Example_Bokeh_G.jpg

 

Vignetting = -2

20_HowToControlDOF_Example_Bokeh_H.jpg

 

Bokeh Anisotropy = 0.5

21_HowToControlDOF_Example_Bokeh_I.jpg

 

Bokeh Anisotropy = -0.5

22_HowToControlDOF_Example_Bokeh_J.jpg

 

Was this article helpful?
0 out of 0 found this helpful