Graphics Reference
In-Depth Information
Figure 3.19. Calculating the distance from a point to a plane.
System Values
Besides these stage-based considerations, two new system values are available for the ver-
tex shader stage to write to: SV_ClipDistance[n] and SV_CullDistance[n]. Both are
available for writing in the stages before the rasterizer, where they are used to perform two
different types of operations: clipping and culling. Clipping and culling for the pipeline
are implemented in the rasterizer, and are discussed in more detail in the "Rasterizer" sec-
tion of this chapter. However, we will describe these operations briefly here to explain the
functionality provided in these two system values.
We begin with a brief mathematical introduction to point-to-plane distance calcula-
tions. In general, the shortest distance from a point to a plane can be found by taking the
dot product of the point's position and the normalized normal vector of the plane, minus
the shortest distance from the plane to the origin of its coordinate space. This result is
easily obtained when the familiar plane equation is available for a plane. Equation (3.1)
shows the equation that provides this property, where a, b, and c are the components of the
normal-length normal vector, and d is the shortest distance from the origin to the plane.
This equation produces a scalar result, which can take three different value ranges. It can
be a positive value if the point is on the side of the plane that the normal points into, a zero
value if the point is exactly on the plane, or a negative value if the point is on the side of
the plane pointing away from the normal vector. Figure 3.19 shows this calculation for a
plane and a point:
D = ax 1 + by 1 + cz 1 - d.
(3.1)
Search WWH ::




Custom Search