gfx.math.proj

NDC agnostic projection matrices. Each projection can be parameterized with a NDC configuration. NDC defines how the clip space will translate to screen coordinates. Note that after transformation by a projection matrix, X, Y and Z vertex coordinates must be divided by W to obtain coordinates in final NDC space. NDC has two components (XYClip and ZClip) that will affect how the coordinates are transformed in the final normalized clipping space. XYClip affects only X and Y (X always to the right, Y either upwards or downwards for leftHanded and rightHanded respectively), and ZClip affects Z depth range.

Members

Aliases

defFrustum
alias defFrustum = frustumCT!(defNdc)

Build an frustum perspective projection matrix with default NDC and DepthClip

defOrtho
alias defOrtho = orthoCT!(defNdc)

Build an orthographic projection matrix with default NDC

defPerspective
alias defPerspective = perspectiveCT!(defNdc)

Build a perspective projection matrix with default NDC and DepthClip

Enums

NDC
enum NDC

NDC aggregates both XYClip and ZClip

XYClip
enum XYClip

Determines whether the default projection matrices will project to a clip space where Y points upwards (left hand NDC) or downwards (right hand NDC). Default is right hand NDC, but can be changed by setting version(GfxMathLeftHandNDC) X-Y clip space spans from [-1 .. 1] in both cases.

ZClip
enum ZClip

Determines whether the default projection matrices will project to a clip space whose depth range is [0 .. 1] or [-1 .. 1]. Default is [0 .. 1] but can be changed by setting version(GfxMathDepthMinusOneToOne) Z points into the screen in both cases.

Functions

frustum
Mat4!T frustum(NDC ndc, T l, T r, T b, T t, T n, T f)

Build an frustum perspective projection matrix with NDC and DepthClip selected at runtime

frustum_LH_01
Mat4!T frustum_LH_01(T l, T r, T b, T t, T n, T f)

Build a perspective projection matrix with left-hand NDC and [0 .. 1] depth clipping

frustum_LH_M11
Mat4!T frustum_LH_M11(T l, T r, T b, T t, T n, T f)

Build a perspective projection matrix with left-hand NDC and [-1 .. 1] depth clipping

frustum_RH_01
Mat4!T frustum_RH_01(T l, T r, T b, T t, T n, T f)

Build a perspective projection matrix with right-hand NDC and [0 .. 1] depth clipping

frustum_RH_M11
Mat4!T frustum_RH_M11(T l, T r, T b, T t, T n, T f)

Build a perspective projection matrix with right-hand NDC and [0 .. 1] depth clipping

ndc
NDC ndc(XYClip xy, ZClip z)

Build NDC from XYClip and ZClip

ortho
Mat4!T ortho(NDC ndc, T l, T r, T b, T t, T n, T f)

Build an orthographic projection matrix with NDC determined at runtime

ortho_LH_01
Mat4!T ortho_LH_01(T l, T r, T b, T t, T n, T f)

Build an orthographic projection matrix with left-hand NDC and [0 .. 1] depth clipping

ortho_LH_M11
Mat4!T ortho_LH_M11(T l, T r, T b, T t, T n, T f)

Build an orthographic projection matrix with left-hand NDC and [-1 .. 1] depth clipping

ortho_RH_01
Mat4!T ortho_RH_01(T l, T r, T b, T t, T n, T f)

Build an orthographic projection matrix with right-hand NDC and [0 .. 1] depth clipping

ortho_RH_M11
Mat4!T ortho_RH_M11(T l, T r, T b, T t, T n, T f)

Build an orthographic projection matrix with right-hand NDC and [-1 .. 1] depth clipping

perspective
Mat4!T perspective(NDC ndc, T fovx, T aspect, T near, T far)

Build a perspective projection matrix with NDC selected at run-time.

perspective_LH_01
Mat4!T perspective_LH_01(T fovx, T aspect, T near, T far)

Build a perspective projection matrix with left-hand NDC and [0 .. 1] depth clipping

perspective_LH_M11
Mat4!T perspective_LH_M11(T fovx, T aspect, T near, T far)

Build a perspective projection matrix with left-hand NDC and [-1 .. 1] depth clipping

perspective_RH_01
Mat4!T perspective_RH_01(T fovx, T aspect, T near, T far)

Build a perspective projection matrix with right-hand NDC and [0 .. 1] depth clipping

perspective_RH_M11
Mat4!T perspective_RH_M11(T fovx, T aspect, T near, T far)

Build a perspective projection matrix with right-hand NDC and [-1 .. 1] depth clipping

Properties

xyClip
XYClip xyClip [@property getter]

Get XYClip from NDC

zClip
ZClip zClip [@property getter]

Get ZClip from NDC

Templates

frustumCT
template frustumCT(NDC ndc)

Build an frustum perspective projection matrix with NDC set at compile-time.

orthoCT
template orthoCT(NDC ndc)

Build an orthographic projection matrix with NDC set at compile-time.

perspectiveCT
template perspectiveCT(NDC ndc)

Build an perspective projection matrix with NDC set at compile-time.

Meta