camera-project
Projects a 3D world point into 2D window space.
var mat4 = var project = //projection * view matrixvar combinedProjView = mat4 //viewport boundsvar viewport = x y width height //3D world pointvar point = 0 -1 25 //vec4 outputvar output =
The output z
component contains the window space depth, and w
is the value of (1 / clip.w)
. Assumes depth range is 0 to 1.
Usage
vec4 = project(out, point, viewport, combined)
Projects the 3D point
into window space using the viewport
bounds (screen x, y, width, height) and combined
matrix (result of multiplying projection * view
matrices).
The result is stored in out
and returned.
See Also
License
MIT, see LICENSE.md for details.