Class SoPolygonOffset

  • All Implemented Interfaces:
    SafeDisposable

    public class SoPolygonOffset
    extends SoNode
    Property node that sets the polygon offset. This class encapsulates the OpenGL 1.1 glPolygonOffset() function. This node can be used to offset polygons that are at the exact same depth to avoid depth buffer artifacts, commonly called z-buffer stitching.

    NOTE: SoPolygonOffset, as its name implies, only works with polygonal geometry.

    SoPolygonOffset affects filled primitives such as SoFaceSet and SoTriangleStripSet. It also affects lines and points in the limited sense that it affects polygonal primitives when the draw style is set to LINES or POINTS. However, because polygon offset does not affect non-polygonal geometry, primitives such as SoLineSet and SoPointSet cannot be offset with SoPolygonOffset(). To avoid depth buffer artifacts with mixed polygonal and non-polygonal geometry, you should "push" the polygonal geometry away from the camera.

    Note: There is only one offset value (combination of factor and units) in the traversal state at any given time.

    The value of the offset is factor * z + r * units, where

    • z is a measurement of the change in depth relative to the screen area of the polygon (commonly called the depth slope), and
    • r is the smallest value that is guaranteed to produce a resolvable offset for a given OpenGL implementation.

    So units produces a constant depth offset and factor produces a variable depth offset which is zero when a polygon is perpendicular to the view vector (parallel to the view plane) and increases as the depth slope increases.

    Both factor and units may be either positive or negative. A positive offset value pushes primitives away from the camera and a negative value pulls them closer. Generally a small value, like 1.0, is sufficient for both parameters.

    File format/default:

    PolygonOffset {

      factor 1
      units 100
      styles FILLED
      on true
    }

    Action behavior:

    SoGLRenderAction
    Calls glPolygonOffset and enables or disables the polygon offset feature as specified. Sets: SoPolyonOffsetElement.

    See Also:
    SoDepthOffset, SoDepthBuffer, SoOverlayGroup
    • Field Detail

      • factor

        public final SoSFFloat factor
        Specifies a scale factor that is used to create a variable depth offset for each polygon. Positive values push polygons away from the camera (opposite of SoDepthOffset). Default = 1.0.
      • units

        public final SoSFFloat units
        Is multiplied by an OpenGL implementation-specific value to create a constant depth offset. Positive values push polygons away from the camera (oppsite of SoDepthOffset). Default = 100.0.
      • styles

        public final SoSFBitMask<SoPolygonOffset.StyleType> styles
        A bit-wise combination of FILLED, LINES, and POINTS that determines which polygon modes should be offset. Default = FILLED.
      • on

        public final SoSFBool on
        Enables/disables polygon offset. Default = true.
    • Constructor Detail

      • SoPolygonOffset

        public SoPolygonOffset()
        Constructor.