This is a special kind of attribute that instructs the graphics driver to apply an offset or bias to the generated depth values for rendered polygons, before they are written to the depth buffer.
This can be used to shift polygons forward slightly, to resolve depth conflicts. The cull traverser may optionally use this, for instance, to implement decals. However, driver support for this feature seems to be spotty, so use with caution.
The bias is always an integer number, and each integer increment represents the smallest possible increment in Z that is sufficient to completely resolve two coplanar polygons. Positive numbers are closer towards the camera.
Nested DepthOffsetAttrib values accumulate; that is, a DepthOffsetAttrib with a value of 1 beneath another DepthOffsetAttrib with a value of 2 presents a net offset of 3. (A DepthOffsetAttrib will not, however, combine with any other DepthOffsetAttribs with a lower override parameter.) The net value should probably not exceed 16 or drop below 0 for maximum portability.
Also, and only tangentially related, the DepthOffsetAttrib can be used to constrain the Z output value to a subset of the usual [0, 1] range (or reversing its direction) by specifying a new min_value and max_value.
Returns the value for the maximum (farthest) depth value to be stored in the buffer, in the range 0 .. 1.
Returns the value for the minimum (closest) depth value to be stored in the buffer, in the range 0 .. 1.
Returns the depth offset represented by this attrib.
make(int offset, PN_stdfloat min_value, PN_stdfloat max_value)¶
Constructs a new
DepthOffsetAttribobject that indicates the relative amount of bias to write to the depth buffer for subsequent geometry.
Constructs a new
DepthOffsetAttribobject that indicates the bias, and also specifies a minimum and maximum (or, more precisely, nearest and farthest) values to write to the depth buffer, in the range 0 .. 1. This range is 0, 1 by default; setting it to some other range can be used to create additional depth buffer effects.
- static int