DepthOffsetAttrib¶
-
class
DepthOffsetAttrib
¶ Bases:
RenderAttrib
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.
Inheritance diagram
-
static int
get_class_slot
(void)¶
-
static TypeHandle
get_class_type
(void)¶
-
PN_stdfloat
get_max_value
(void) const¶ Returns the value for the maximum (farthest) depth value to be stored in the buffer, in the range 0 .. 1.
-
PN_stdfloat
get_min_value
(void) const¶ Returns the value for the minimum (closest) depth value to be stored in the buffer, in the range 0 .. 1.
-
int
get_offset
(void) const¶ Returns the depth offset represented by this attrib.
-
static ConstPointerTo<RenderAttrib>
make
(int offset = 1)¶
-
static ConstPointerTo<RenderAttrib>
make
(int offset, PN_stdfloat min_value, PN_stdfloat max_value)¶ Constructs a new
DepthOffsetAttrib
object that indicates the relative amount of bias to write to the depth buffer for subsequent geometry.Constructs a new
DepthOffsetAttrib
object 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 ConstPointerTo<RenderAttrib>
make_default
(void)¶ Returns a
RenderAttrib
that corresponds to whatever the standard default properties for render attributes of this type ought to be.
-
static int