[][src]Function ultraviolet::projection::lh_yup::perspective_reversed_infinite_z_dx_gl

pub fn perspective_reversed_infinite_z_dx_gl(
    vertical_fov: f32,
    aspect_ratio: f32,
    z_near: f32
) -> Mat4

Perspective projection matrix with reversed and infinite z-axis meant to be used with OpenGL or DirectX.

Reversed-Z provides significantly better precision and therefore reduced z-fighting for most depth situations, especially when a floating-point depth buffer is used. You'll want to use a reversed depth comparison function and depth clear value when using this projection.

Infinte-Z is useful for extremely large scenes where having a far clip plane is extraneous anyway, as allowing it to approach infinity it eliminates several approximate numerical computations and so can improve z-fighting behavior.

Combining them gives the best of both worlds for large scenes.

  • vertical_fov should be provided in radians.
  • aspect_ratio should be the quotient width / height.

This matrix is meant to be used when the source coordinate space is left-handed and y-up (the standard computer graphics coordinate space) and the destination coordinate space is left-handed and y-up with Z (depth) clip extending from 0.0 (close) to 1.0 (far).

Note that in order for this to work properly with OpenGL, you'll need to use the gl_arb_clip_control extension and set the z clip from 0.0 to 1.0 rather than the default -1.0 to 1.0