next up previous contents index
Next: 3.5.6 Polygon Rasterization State Up: 3.5 Polygons Previous: 3.5.4 Options Controlling Polygon

3.5.5 Depth Offset

 

The depth values of all fragments generated by the rasterization of a polygon may be offset by a single value that is computed for that polygon. The function that determines this value is specified by calling

void PolygonOffset ( float factor, float units ) ;

factor scales the maximum depth slope of the polygon, and units scales an implementation dependent constant that relates to the usable resolution of the depth buffer. The resulting values are summed to produce the polygon offset value. Both factor and units may be either positive or negative.

The maximum depth slope m of a triangle is

 

where is a point on the triangle. m may be approximated as

 

If the polygon has more than three vertices, one or more values of m may be used during rasterization. Each may take any value in the range [min,max], where min and max are the smallest and largest values obtained by evaluating Equation 3.5 or Equation 3.6 for the triangles formed by all three-vertex combinations.

The minimum resolvable difference r is an implementation constant. It is the smallest difference in window coordinate z values that is guaranteed to remain distinct throughout polygon rasterization and in the depth buffer. All pairs of fragments generated by the rasterization of two polygons with otherwise identical vertices, but values that differ by r, will have distinct depth values.

The offset value o for a polygon is

m is computed as described above, as a function of depth values in the range [0,1], and o is applied to depth values in the same range.

Boolean state values POLYGON_OFFSET_POINT, POLYGON_OFFSET_LINE, and POLYGON_OFFSET_FILL determine whether o is applied during the rasterization of polygons in POINT, LINE, and FILL modes. These boolean state values are enabled and disabled as argument values to the commands Enable  and Disable . If POLYGON_OFFSET_POINT is enabled, o is added to the depth value of each fragment produced by the rasterization of a polygon in POINT mode. Likewise, if POLYGON_OFFSET_LINE or POLYGON_OFFSET_FILL is enabled, o is added to the depth value of each fragment produced by the rasterization of a polygon in LINE or FILL modes, respectively.

Fragment depth values are always limited to the range [0,1], either by clamping after offset addition is performed (preferred), or by clamping the vertex values used in the rasterization of the polygon.



next up previous contents index
Next: 3.5.6 Polygon Rasterization State Up: 3.5 Polygons Previous: 3.5.4 Options Controlling Polygon



David Blythe
Sat Mar 29 02:23:21 PST 1997