Graphics Reference
In-Depth Information
Depth Peeling
Another approach to handling the layers is to use depth peeling (Everitt, 2001). With depth
peeling, all geometry is rendered for each layer. When rendering, the depth from the previ-
ous layer is sampled and compared with the depth of the surface being rendered. A given
pixel is written only if its depth is greater than the same pixel in the previous layer. The
result is that the overlapping geometry is "automatically" sorted, based on depth at a per-
pixel level. Then, in the lighting pass, the layers are once again lit in order and blended
together. The main advantage of this technique is that it is not dependent on the order of
submission for geometry, which means that no CPU-side sorting is required. It also prop-
erly handles cases where transparent triangles overlap, since depth is sorted per-pixel. The
obvious downside is that all scene geometry has to be rendered N times, where N is the
number of depth layers in the scene. The added pixel shader cost can be mitigated some-
what if a depth-only prepass is performed first, which allows depth testing to be used to
ensure that only one pixel per layer is shaded when writing out the g-buffer (Persson, Deep
deferred shading, 2007).
11.6.3 Inferred Lighting
Inferred lighting (Kircher & Lawrance, 2009) is a technique that was initially developed to
allow lighting to be run at a resolution lower than the final output resolution. It is a varia-
tion of light pre-pass deferred rendering, where the results of the lighting passes are bilater-
ally upsampled while rendering the scene geometry a second time. The bilateral upsample
is performed by taking four samples from the g-buffer and comparing depth, normal, and
object ID values. Samples that aren't within a threshold are rejected, which ensures that
lighting performed for a different surface isn't applied to the geometry being rendered.
While the aim of the technique was primarily to enable lower-resolution shading as a
performance optimization, it also enabled a novel method for handling transparent geom-
etry. Since the bilateral filter automatically rejects pixels from the light buffer that aren't
from the same mesh, it is possible to interleave transparent geometry into the g-buffer,
using a stipple pattern. If the g-buffer is divided into a grid of 2x2 quads, a pattern can
be used, where one texel is reserved for opaques while the other three provide three lay-
ers of transparent geometry. Thus, the opaque geometry would be rendered to the top-left
texel, the first transparent layer would be in the top-right area, and so on. The diagram in
Figure 11.11 illustrates this concept.
To assign transparent geometry to a particular layer, a coarse sorting pass can be used,
as described in the "Multiple G-Buffer Layers" section. In this case, it is desirable to keep
the sorting on the CPU, so that the shader has advance knowledge of which stipple pattern
must be used. During the lighting pass, the lights can sample the g-buffer normally, without
knowing or caring whether a texel belongs to opaque or transparent geometry. Finally, all
Search WWH ::




Custom Search