Perspective draws a point by dividing by w, which carries depth. A larger w makes a smaller image, and parallel edges that recede meet at a vanishing point.
Parallel edges that run away from you meet at one vanishing point. The vanishing point sits on the horizon, level with the eye. The matrix stays the same when the eye moves. This corner's depth changes, and that changes w.
Before—
w—
After—
The matrix writes depth into w. Then x, y, and z are divided by w. A far corner has a larger w, so it shrinks more. In lesson 04, w marks a point or a direction. Here, w carries depth.
4×4 perspective matrix. It multiplies the corner measured from the eye. Read each row from left to right. The bottom row builds w.
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
Where this is used
A 3D camera in a game or an animated film uses this divide. A graphics programmer builds that camera. A layout artist or a camera artist places it.
Artists and illustrators draw lines to a vanishing point on a horizon. This is linear perspective. Painters have used it since the Renaissance.
On a phone, augmented reality uses the same divide, so a virtual object lines up with the camera.
In computer vision, a related idea is the pinhole camera. A photogrammetrist uses it to measure a real object from photographs. A real lens can add distortion, which this page leaves out.
Common mistakes
The matrix output is not the final picture. x, y, and z still have to be divided by w.
Moving the eye does not change the matrix. The matrix stays the same, and this corner's depth changes w.
Perspective is not an orthographic projection. A projection drops a direction. Perspective divides by depth.
A real lens can distort. This page is the pinhole picture, and it leaves that distortion out.