Depth of Field 3.4
Manual     Reference     Scripting   
Reference Manual > Components > Image Effect Scripts > Depth of Field 3.4

Depth of Field 3.4

The Depth of Field 3.4 image effect is a common post effect simulating camera lens systems. It has been updated with new features and faster execution for Unity 3.4, hence the name. An example for the new Depth of Field effect can be seen in the following images, displaying the results of a defocused foreground and a defocused background. Notice how the foreground blur overlaps with the rest while the background doesn't. You might also consider the Tilt Shift effect for a simpler to use but less powerful depth of field effect.


Only the nearby pipes are in the focal area

Foreground vs. Background blurring with Depth of Field

As with the other image effects, this effect is only available in Unity Pro. Make sure to have the Pro Standard Assets installed.

Properties

General Settings
ResolutionDetermines the internal render target sizes. The lower the resolution the faster the effect and the lower the memory requirements will be.
QualityThe quality level. Chose between the faster OnlyBackground or the slower BackgroundAndForeground options which calculates the Depth of Field defocus for both areas seperately.
Simple tweakSwitches to a simpler focal model.
Visualize focusVisualizes the focal areas in the game view.
Enable bokehThis will generate more realistic lens blurs where very bright parts are scaled and overlap.
Focal Settings
Focal distanceThe distance to the focal point from the camera position in world space.
Object FocusInstead of setting the distance manually you can always autofocus on this Transform.
SmoothnessThe smoothness when transitioning from out-of-focus to in-focus areas.
Focal sizeThe size of the in-focus area.
Blur
BlurrinessHow many iterations are taken for defocusing the various buffers.
Blur spreadThe blur distance (resolution independent, you might have to re-tweak if the resolution changes drastically).
Bokeh Settings
DestinationEnabling foreground and background blur will be a lot slower but gives more realistic results.
IntensityBlend intensity when all bokeh shapes are being accumulated. This is a critical value that always needs to be carefully adjusted.
Min luminanceThe luminance threshhold for all pixels that should be considered.
Min contrastThe contrast threshhold for all pixels that should be considered (this is important as usually, you only need bokeh shapes in areas of high frequency. They would be close to invisible otherwise. It also helps performance as it can save a lot of fillrate.).
DownsampleThe size of the internal render target used for accumulating bokeh shapes.
SizeThe maximum bokeh size. Will be modulated by the amount of defocus (Circle of Confusion).
Bokeh TextureThe texture defining the bokeh shapes.

Note about the Bokeh effect: as it is based on drawing triangles per pixel it can drastically affect your framerate, especially if it's not properly tweaked. Adjust the Size, Min luminance, Min contrast, Downsample and Resolution for highest performance. Also, as it pre-darkens the screen before applying the bokeh shapes, one should take care of using an apropriately high Blurriness level to remove possible artefacts.

Hardware support

This effect requires a graphics card with pixel shaders (3.0) or OpenGL ES 2.0. Additionally, depth texture support is required. PC: NVIDIA cards since 2004 (GeForce 6), AMD cards since 2005 (Radeon X1300), Intel cards since 2006 (GMA X3000); Mobile: OpenGL ES 2.0 with depth texture support; Consoles: Xbox 360, PS3.

All image effects automatically disable themselves when they can not run on end-users graphics card.

Page last updated: 2011-06-12