gfx.math.proj

Projection matrices Assumption is made that the model-view coordinates are right-handed, with X to the right, Y up, and Z out of the screen. A second assumption is that in the final normalized clipping space, Z points into the screen. The projection transforms have two options (DepthClip and NDC) that will affect how the coordinates are transformed in the final normalized clipping space. NDC affects only X and Y (X always to the right, Y either upwards or downwards for leftHanded and rightHanded respectively), and DepthClip affects Z depth range.

Members

Aliases

frustum
alias frustum = frustumCT!(defNdc, defDepthClip)

Build an frustum perspective projection matrix with default NDC and DepthClip

ortho
alias ortho = orthoCT!(defNdc, defDepthClip)

Build an orthographic projection matrix with default NDC and DepthClip

perspective
alias perspective = perspectiveCT!(defNdc, defDepthClip)

Build a perspective projection matrix with default NDC and DepthClip

Enums

DepthClip
enum DepthClip

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)

NDC
enum NDC

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)

Functions

frustumRT
Mat4!T frustumRT(NDC ndc, DepthClip dc, 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

orthoRT
Mat4!T orthoRT(NDC ndc, DepthClip dc, T l, T r, T b, T t, T n, T f)

Build an orthographic projection matrix with NDC and DepthClip selected 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

perspectiveRT
Mat4!T perspectiveRT(NDC ndc, DepthClip dc, T fovx, T aspect, T near, T far)

Build a perspective projection matrix with NDC and DepthClip 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

Templates

frustumCT
template frustumCT(NDC ndc, DepthClip dc)

Build an frustum perspective projection matrix with NDC and DepthClip set with compile-time params.

orthoCT
template orthoCT(NDC ndc, DepthClip dc)

Build an orthographic projection matrix with NDC and DepthClip set with compile-time params.

perspectiveCT
template perspectiveCT(NDC ndc, DepthClip dc)

Build an perspectivegraphic projection matrix with NDC and DepthClip set with compile-time params.

Meta