Math Playground
Back to Graphics

Graphics › Coordinate spaces

View space (the camera)

Here's the secret: there is no camera. The view matrix moves the entire world so that 'the camera' ends up sitting at the origin, looking straight down −Z.

Coordinate spaces — follow a cube from mesh to pixels
xyz

Model space: the cube as the mesh file stores it — built around its own origin, no idea where it'll end up.

the cube's far-top-right corner here: (0.5, 0.5, 0.5)

The camera that isn't there

GPUs only know how to draw things relative to a fixed eye at the origin. So instead of moving a camera around the world, graphics moves the world around a stationary eye. If your camera is at position C with orientation R, the view matrix is the inverse of that pose: V = (translate C · rotate R)⁻¹. Apply it to everything and the camera is now at (0,0,0), the “forward” direction is −Z, and +Y is up.

lookAt(eye, target, up)

The everyday way to build V: give an eyeposition, a target to look at, and a rough up vector. From those, forward = normalize(target − eye), right = normalize(cross(forward, up)), trueUp = cross(right, forward) — those three become the rows of the rotation part, and −(R · eye) the translation.

How to tell you're in view space

  • The camera is at the origin.
  • Everything in front of the camera has negative z (in OpenGL's right-handed convention).
  • Distances to the camera are now just −z — handy for fog, depth sorting and the next step, projection.

What it's good for

View space is the natural home for anything “relative to where you're looking”: screen-space effects, billboards that always face the camera, depth-of-field, and the frustum-culling test that throws away whatever isn't in front of you.