![]() |
|Download Files|
![]() ![]() ![]() ![]() ![]() Next: 3.5.2 Stippling Up: 3.5 Polygons Previous: 3.5 Polygons
3.5.1 Basic Polygon RasterizationThe first step of polygon rasterization is to determine if the polygon is back facing or front facing. This determination is made by examining the sign of the area computed by equation 2.6 of section 2.13.1 (including the possible reversal of this sign as indicated by the last call to FrontFace ). If this sign is positive, the polygon is frontfacing; otherwise, it is back facing. This determination is used in conjunction with the CullFace enable bit and mode value to decide whether or not a particular polygon is rasterized. The CullFace mode is set by calling mode is a symbolic constant: one of FRONT, BACK or FRONT_AND_BACK. Culling is enabled or disabled with Enable or Disable using the symbolic constant CULL_FACE. Front facing polygons are rasterized if either culling is disabled or the CullFace mode is BACK while back facing polygons are rasterized only if either culling is disabled or the CullFace mode is FRONT. The initial setting of the CullFace mode is BACK. Initially, culling is disabled. The rule for determining which fragments are produced by polygon rasterization is called point sampling. The two-dimensional projection obtained by taking the x and y window coordinates of the polygon's vertices is formed. Fragment centers that lie inside of this polygon are produced by rasterization. Special treatment is given to a fragment whose center lies on a polygon boundary edge. In such a case we require that if two polygons lie on either side of a common edge (with identical endpoints) on which a fragment center lies, then exactly one of the polygons results in the production of the fragment during rasterization.
As for the data associated with each fragment produced
by rasterizing a polygon,
we begin by specifying how these
values are produced for fragments in a triangle.
Define barycentric coordinates for a triangle.
Barycentric coordinates are a set of three numbers,
a, b, and c, each in the range
where
where
Denote a datum at
where Just as with line segment rasterization, equation 3.4 may be approximated by this may yield acceptable results for color values (it must be used for depth values), but will normally lead to unacceptable distortion effects if used for texture coordinates. For a polygon with more than three edges, we require only that a convex combination of the values of the datum at the polygon's vertices can be used to obtain the value assigned to each fragment produced by the rasterization algorithm. That is, it must be the case that at every fragment
where n is the number of vertices in the polygon,
One algorithm that achieves the required behavior is to triangulate a polygon (without adding any vertices) and then treat each triangle individually as already discussed. A scan-line rasterizer that linearly interpolates data along each edge and then linearly interpolates data across each horizontal span from edge to edge also satisfies the restrictions (in this case, the numerator and denominator of equation 3.4 should be iterated independently and a division performed for each fragment).
![]() ![]() ![]() ![]() ![]() Next: 3.5.2 Stippling Up: 3.5 Polygons Previous: 3.5 Polygons David Blythe Sat Mar 29 02:23:21 PST 1997
|