Graphics Reference
In-Depth Information
Figure 3.55. A depiction of the primitive culling test where all three vertices of a triangle must be outside
of the same plane to be culled.
check is performed for each of the sides of the unit cube. This culling process is depicted
in Figure 3.55.
In addition to this standard form of culling, the developer can also use custom culling
algorithms. We have seen the system value attribute SV_CullDistance in the vertex shader
section. This system value semantic will cull a primitive if all of its vertices arrive at the
rasterizer stage with negative values in the same attribute component marked with the SV_
CullDistance semantic. The value can be generated with a user-defined plane equation,
performing a distance test and then storing the scalar result in the SV_CullDistance attri-
bute. In practice, there is no limitation imposed on the type of calculation used to generate
the culling value. If there is a more appropriate test to be applied, it can be implemented as
needed and the result stored in the same way. For example, when generating a paraboloid
environment map, geometry could be culled that exists in the opposite hemisphere from
the one being generated at the moment (paraboloid maps are discussed in more detail in
Chapter 13).
Primitive Clipping
The next operation performed by the rasterizer stage is primitive clipping. This takes
each primitive that has survived the culling operations and tests if it is located fully inside
of the unit cube, or if it is only partially inside. If the primitive resides completely outside
of the unit cube, it can be discarded outright without any further processing. If it is partially
inside, then the primitive is split into new primitives that reside entirely within the unit
cube, and the exterior primitives are discarded. This procedure is depicted in Figure 3.56.
Since the unit cube corresponds to the view frustum of the current projection matrix, this
operation is also referred to as frustum clipping.
Search WWH ::




Custom Search