Game Engine Architecture

(Ben Green) #1
453

10.2.5.7. Triangle Traversal


Each triangle is broken into fragments (i.e., rasterized) by the triangle travers-
al stage. Usually one fragment is generated for each pixel, although with mul-
tisample antialiasing (MSAA), multiple fragments are created per pixel (see
Section 10.1.4.7). The triangle traversal stage also interpolates vertex att ributes
in order to generate per-fragment att ributes for processing by the pixel shader.
Perspective-correct interpolation is used where appropriate. This stage’s func-
tionality is fi xed and not confi gurable.


10.2.5.8. Early Z Test


Many graphics cards are capable of checking the depth of the fragment at this
point in the pipeline, discarding it if it is being occluded by the pixel already
in the frame buff er. This allows the (potentially very expensive) pixel shader
stage to be skipped entirely for occluded fragments.
Surprisingly, not all graphics hardware supports depth testing at this
stage of the pipeline. In older GPU designs, the z test was done along with al-
pha testing, aft er the pixel shader had run. For this reason, this stage is called
the early z test or early depth test stage.


10.2.5.9. Pixel Shader


This stage is fully programmable. Its job is to shade (i.e., light and otherwise
process) each fragment. The pixel shader can also discard fragments, for ex-
ample because they are deemed to be entirely transparent. The pixel shader
can address one or more texture maps, run per-pixel lighting calculations, and
do whatever else is necessary to determine the fragment’s color.
The input to this stage is a collection of per-fragment att ributes (which
have been interpolated from the vertex att ributes by the triangle traversal
stage). The output is a single color vector describing the desired color of the
fragment.


10.2.5.10. Merging / Raster Operations Stage


The fi nal stage of the pipeline is known as the merging stage or blending stage,
also known as the raster operations stage or ROP in NVIDIA parlance. This
stage is not programmable, but it is highly confi gurable. It is responsible for
running various fragment tests including the depth test (see Section 10.1.4.8),
alpha test (in which the values of the fragment’s and pixel’s alpha channels can
be used to reject certain fragments), and stencil test (see Section 10.3.3.1).
If the fragment passes all of the tests, its color is blended (merged) with
the color that is already present in the frame buff er. The way in which blend-
ing occurs is controlled by the alpha blending function —a function whose basic


10.2. The Rendering Pipeline

Free download pdf