DepthOffsetAttrib

from panda3d.core import DepthOffsetAttrib
class DepthOffsetAttrib

Bases:

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

Inheritance diagram of DepthOffsetAttrib

property class_slot int
static getClassSlot() int
static getClassType() TypeHandle
getMaxValue() float

Returns the value for the maximum (farthest) depth value to be stored in the buffer, in the range 0 .. 1.

getMinValue() float

Returns the value for the minimum (closest) depth value to be stored in the buffer, in the range 0 .. 1.

getOffset() int

Returns the depth offset represented by this attrib.

static make(offset: int) RenderAttrib

Constructs a new DepthOffsetAttrib object that indicates the relative amount of bias to write to the depth buffer for subsequent geometry.

static make(offset: int, min_value: float, max_value: float) RenderAttrib

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 makeDefault() RenderAttrib

Returns a RenderAttrib that corresponds to whatever the standard default properties for render attributes of this type ought to be.

property max_value float

Returns the value for the maximum (farthest) depth value to be stored in the buffer, in the range 0 .. 1.

property min_value float

Returns the value for the minimum (closest) depth value to be stored in the buffer, in the range 0 .. 1.

property offset int

Returns the depth offset represented by this attrib.