[][src]Struct web_glitz::pipeline::graphics::PolygonOffset

pub struct PolygonOffset {
    pub factor: f32,
    pub units: f32,
}

Specifies an offset modifier for for depth values from polygonal fragments.

When a DepthTest specifies a polygon offset, then an offset is applied to depth values for fragments from polygonal primitives (triangles) before they are tested and before the depth value is written to the depth buffer. This offset is computed as factor * DZ + r * units, where factor is the [factor] specified by the PolygonOffset instance, DZ is a measurement of the fragment's rate of change in depth relative to the screen area of the polygon, units is the [units] value specified by the PolygonOffset instance, and r is the smallest value that is guaranteed to produce a resolvable offset for a given implementation.

A polygon offset is useful when rendering coplanar primitives, such as when rendering hidden-line images, when applying decals to surfaces, and when rendering solids with highlighted edges. Can be used to prevent what is called "stitching", "bleeding" or "Z-fighting", where fragments with very similar z-values do not always produce predictable results.

Only applies to fragments from polygonal primitives (triangles); ignored for fragments from other primitives (points, lines). If you are rendering e.g. a coplanar triangle and line, specify a polygon offset to "push back" the triangle, rather than attempting to "push forward" the line.

May be instantiated with default values through Default:

use web_glitz::pipeline::graphics::PolygonOffset;

assert_eq!(PolygonOffset::default(), PolygonOffset {
    factor: 0.0,
    units: 0.0,
});

Fields

factor: f32

Specifies a scale factor that is used to create a variable depth offset for each polygon.

See the type documentation for PolygonOffset for details.

Defaults to 0.0.

units: f32

Is multiplied by an implementation-specific value to create a constant depth offset.

See the type documentation for PolygonOffset for details.

Defaults to 0.0.

Trait Implementations

impl Default for PolygonOffset[src]

impl Clone for PolygonOffset[src]

impl PartialEq<PolygonOffset> for PolygonOffset[src]

impl Debug for PolygonOffset[src]

Auto Trait Implementations

Blanket Implementations

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]