Function perspective

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

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

Parameters

NameDescription
ndc the target NDC
fovx horizontal field of view in degrees
aspect aspect ratio (width / height)
near position of the near plane
far position of the far plane

Returns

a matrix that maps from eye space to clip space. To obtain NDC, the vector must be divided by w.