Game Development Reference
In-Depth Information
Figure 1.2. Extreme near- and far-field defocus with smooth transitions rendered by
our algorithm.
Note the blurry silhouettes on near-field objects and detail inpainted
behind them.
aperture that we model, but we depend on the signed radius for another reason.
Signed radius decreases monotonically with depth, so if r A <r B ,thenpoint A is
closer to the camera than point B . Thus the single signed radius value at each
pixel avoids the need for separate values to encode the field, radius, and depth of
apoint.
Our demo supports two methods to compute the signed radius. The first is
the physically correct model derived from Figure 1.4. Let a be the radius of the
lens, z F < 0 be the depth of the focus plane, and R be the world-space (versus
screen-space) radius. By similar triangles, the screen-space radius r for a point
at depth z is
R
a
a |
z F โ
z
|
=
,
r
โ
.
|
z F โ
z
|
|
z F |
z F ยท
z
The proportionality constant depends on screen resolution and field of view. Our
art team felt that this physical model gave poor control over the specific kinds
of shots that they were trying to direct. They preferred the second model, in
which the artists manually place four planes (near-blurry, near-sharp, far-sharp,
far-blurry). For the near- and far-blurry planes, the artists specify the CoC radius
explicitly. At the near-sharp and far-sharp planes, the radius is 1 / 2 pixel. The
CoC at depths between the planes is then linearly interpolated. Depths closer
than the near-blurry and farther than the far-blurry have radii clamped to the
values at those planes.