i
i
i
i
i
i
i
i
24 2. The Graphics Rendering Pipeline
with the z-value and color from the primitive that is being drawn. If the
computed z-value is greater than the z-value in the Z-buffer, then the color
buffer and the Z-buffer are left untouched. The Z-buffer algorithm is very
simple, has O(n) convergence (where n is the number of primitives being
rendered), and works for any drawing primitive for which a z-value can be
computed for each (relevant) pixel. Also note that this algorithm allows
most primitives to be rendered in any order, which is another reason for its
popularity. However, partially transparent primitives cannot be rendered
in just any order. They must be rendered after all opaque primitives, and
in back-to-front order (Section 5.7). This is one of the major weaknesses
of the Z-buffer.
We have mentioned that the color buffer is used to store colors and
that the Z-buffer stores z-values for each pixel. However, there are other
channels and buffers that can be used to filter and capture fragment infor-
mation. The alpha channel is associated with the color buffer and stores
a related opacity value for each pixel (Section 5.7). An optional alpha test
can be performed on an incoming fragment before the depth test is per-
formed.
9
The alpha value of the fragment is compared by some specified
test (equals, greater than, etc.) to a reference value. If the fragment fails to
pass the test, it is removed from further processing. This test is typically
used to ensure that fully transparent fragments do not affect the Z-buffer
(see Section 6.6).
The stencil buffer is an offscreen buffer used to record the locations of
the rendered primitive. It typically contains eight bits per pixel. Primitives
can be rendered into the stencil buffer using various functions, and the
buffer’s contents can then be used to control rendering into the color buffer
and Z-buffer. As an example, assume that a filled circle has been drawn
into the stencil buffer. This can be combined with an operator that allows
rendering of subsequent primitives into the color buffer only where the
circle is present. The stencil buffer is a powerful tool for generating special
effects. All of these functions at the end of the pipeline are called raster
operations (ROP) or blend operations.
The frame buffer generally consists of all the buffers on a system, but
it is sometimes used to mean just the color buffer and Z-buffer as a set.
In 1990, Haeberli and Akeley [474] presented another complement to the
frame buffer, called the accumulation buffer. In this buffer, images can be
accumulated using a set of operators. For example, a set of images showing
an object in motion can be accumulated and averaged in order to generate
motion blur. Other effects that can be generated include depth of field,
antialiasing, soft shadows, etc.
9
In DirectX 10, the alpha test is no longer part of this stage, but rather a function
of the pixel shader.