Game Development Reference
Figure 1.1. Three frames from a cinematic “rack focus” transition designed to move the
player's attention from the background to the extreme foreground.
In each shot, the
yellow dot shows the location of camera focus.
True DoF arises because each point on the camera lens has a slightly different
viewpoint and the final image is a composite of images from all of them. Research
papers have simulated this brute-force rendering of multiple viewpoints to an
accumulation buffer, sampling viewpoints with distribution ray tracing [Cook et
al. 84], and sampling with stochastic rasterization [McGuire et al. 10]. These
methods are all too expensive to be practical today and are overkill for achieving
a convincing effect. Since the goal is to blur parts of the image, we need not render
a perfect result. It should be enough to selectively apply some post-processing
blur filters to a typical frame. Like many other game engines, ours follows this
approach. There's a good argument for this approximation over physically correct
solutions: it is what Photoshop's Lens Blur and many film editing packages do.
The DoF seen in advertisements and feature films is certainly of sucient quality
for game graphics.
We distinguish three depth ranges of interest: the far field in which objects
are blurry because they are too far away, the focus field where objects are in
focus, and the near field in which objects are blurry because they are too close
to the camera.
A post-processing DoF shader is essentially a blur filter with a spatially vary-
ing kernel. The way that the kernel varies poses three challenges. First, unlike a
typical Gaussian or box blur, DoF blur must respect depth edges. For example,
the effect should not let a blurry distant object bleed over a nearer sharp object.
We observe that it is most critical that the far-focus-near ordering of occlusion
be preserved. However, incorrect blurring of images of neighboring objects within
a field is often undetectable.
Second, when preventing bleeding, the effect must also not create sharp sil-
houettes on blurry objects in the near field.
These sharp silhouettes are the
primary visual artifact in previous methods.