Graphics Reference
In-Depth Information
To conservatively cull a complete primitive from further processing, all of the vertex
positions must be completely outside of at least one of the six planes defining clip space."
Each of the distances between the vertex positions and each of the planes can be calculated
as described above. If all of the vertices of a primitive result in negative distance values
for any of the six planes, the primitive can be discarded since it would not be visible. The
SV_CullDistance[n] system value semantics behave in much the same way as the form
of conservative culling mentioned above. Each attribute declared with this system value
represents the distance to a culling plane. When these system values are interpreted by the
rasterizer stage, it will eliminate any primitive whose vertices all have a negative value in
the same register. An example of this type of system value usage is shown in Listing 3.12.
If the same component of the "clips" attribute were negative for all of the vertices of a
primitive, it would be culled without being rasterized at all. This arrangement allows for
the results of up to four different culling equation results to be stored for this attribute.
struct VS_OUT
{
float4 position : SVPosition;
float4 clips
: SV_CullDistance;
};
Listing 3.12. A sample output vertex structure that uses a four-component SVCullDistance system value
semantic.
The SV_ClipDistance system value semantic operates in a similar fashion, and de-
fines the distance to a clipping plane. If one or more vertices of a primitive have negative
values in this attribute, its value will be used to determine which portion of the current
primitive should be clipped. The actual clipping can be performed before or after rasteriza-
tion—this is an implementation-specific detail that the developer can't know in advance.
Regardless of how the primitive is clipped, the result is that none of the fragments gener-
ated after rasterization will contain a negative value in the interpolated SV_ClipDistance
system value semantic. This differs from the SV_CullDistance system variable, which
performs the culling test on the entire primitive instead of trying to "clip" the primitive to
only have a positive SV_ClipDistance attribute.
The maximum number of these clip and cull system values is a total of two attri-
butes, with up to four components, each of which can be declared in any combination of
SV_ClipDistance and SV_CullDistance. This means that a total of eight planes can be
either clipped against (if two float4s are used as SV_ClipDistance) or culled against (if
two float4s are used as SV_CullDistance) or some combination of the two.
1 1 1 We discuss clip space and its properties in more detail in the rasterizer and pixel shader sections of this
chapter.
Search WWH ::




Custom Search