Perspective projection

On this page 7

Perspective projection is the mathematical mapping that turns points of a three-dimensional scene into a two-dimensional image by drawing rays toward a single center of projection, so that objects farther from the viewer appear smaller. Among the 3D fundamentals of 3D graphics & animation, it is the default view of a virtual camera and the reason rendered images show convincing depth.

Every rasterizer, game engine and offline renderer applies perspective projection after the scene has been placed in camera space. The mapping is described by a projection matrix and a perspective divide, and its behavior is controlled by a small set of parameters: field of view, aspect ratio and the near and far clipping planes.

How perspective projection maps points to the image

Perspective projection divides each point’s horizontal and vertical position by its distance along the viewing axis. A point at coordinates (x, y, z) in camera space lands on the image plane at roughly (x/z, y/z), scaled by the focal length. This division by depth is what makes parallel lines converge and distant objects shrink.

In real-time graphics the operation is split into two steps. First, a 4×4 projection matrix transforms camera-space coordinates into clip space and copies the depth into the fourth component, w. Second, the GPU performs the perspective divide, dividing x, y and z by w to produce normalized device coordinates (NDC). Only then are triangles clipped, rasterized and mapped to pixels by the viewport transform.

The following table traces a single vertex through the stages of the pipeline that involve projection.

StageWhat happensTypical range
Camera spaceScene expressed relative to the cameraUnbounded, camera looks along -z or +z
Clip spaceProjection matrix applied, w holds depthVisible points satisfy -w to w
NDCx, y and z divided by w-1 to 1 (z 0 to 1 in Direct3D and Vulkan)
Screen spaceViewport transform to pixels0 to image width and height
Coordinate stages around the projection step

Because the divide happens per vertex, attributes such as texture coordinates must be interpolated in a perspective-correct way. Modern GPUs do this automatically by interpolating attribute/w and 1/w and then dividing, which prevents the warped textures seen in early software renderers that used simple screen-space interpolation.

Parameters of the viewing frustum

The visible region of a perspective camera is a truncated pyramid called the viewing frustum. Its apex sits at the camera, its sides are defined by the field of view and aspect ratio, and it is cut by the near and far clipping planes. Anything outside the frustum is clipped or culled and never reaches the image.

ParameterTypical valuesEffect on the image
Vertical field of view40 to 90 degreesWider angles exaggerate depth and edge stretching
Focal length18 mm to 200 mm (35 mm equivalent)Longer lenses flatten depth and compress distance
Aspect ratio16:9, 4:3, 2.39:1Sets horizontal extent relative to vertical
Near clipping plane0.01 to 1 scene unitToo small a value wastes depth precision
Far clipping plane100 to 100,000 unitsToo large a ratio to near causes z-fighting
Main frustum parameters and their effects

Field of view and focal length describe the same property. Digital content creation tools usually expose focal length and a sensor width to match real cameras, while game engines expose the vertical or horizontal field of view directly. Converting between them uses the relation FOV = 2 x atan(sensor size / (2 x focal length)).

Perspective compared with orthographic projection

Perspective projection differs from orthographic projection in one essential way: orthographic projection uses parallel projection rays and no division by depth, so object size on screen does not depend on distance. Both are standard camera modes in a 3D viewport, and each suits different tasks.

PropertyPerspective projectionOrthographic projection
Projection raysConverge at the cameraParallel to the view direction
Size with distanceShrinks with depthConstant
Parallel linesMeet at vanishing pointsStay parallel
Depth buffer distributionNonlinear, dense near the cameraLinear
Typical useFinal renders, games, VRModeling views, technical drawings, isometric games
Perspective and orthographic projection side by side

Artists usually model in orthographic front, side and top views to measure proportions, then switch to perspective to judge the form as an audience will see it. A related variant, weak perspective, scales a whole object by one average depth and is used in computer vision when depth variation within the object is small.

Setting up a perspective camera in practice

Good camera setup starts with the intended viewing distance and mood. A narrow field of view suits portraits and product shots because it avoids enlarged noses and bulging edges, while a wide field of view creates speed and scale in action scenes and first-person games.

SituationRecommended settingReason
Character close-up50 to 85 mm focal lengthNatural facial proportions
Architectural interiorWide lens with vertical lines kept verticalShows space without converging walls
First-person gameHorizontal FOV of 90 to 110 degreesPeripheral awareness on flat screens
Large open worldReversed depth with a floating-point bufferReduces z-fighting at long range
VR headsetFOV taken from the headset’s own opticsPrevents discomfort and scale errors
Choosing perspective settings by situation

Depth precision deserves particular attention. With a standard depth mapping, most precision is concentrated close to the near plane, so pushing the near plane outward helps far more than pulling the far plane inward. Many engines now use reversed-Z, which maps the near plane to 1 and the far plane to 0, pairing well with floating-point depth buffers.

Limitations and common mistakes

Perspective projection is a planar projection, so it cannot represent a field of view approaching 180 degrees without extreme stretching at the image edges. Fisheye, panoramic and equirectangular cameras use different, nonlinear mappings that a single projection matrix cannot express.

  • Extreme wide angles distort spheres into ovals near the frame edges; this is correct geometry, not a rendering bug.
  • A near plane set too close causes flickering surfaces where geometry overlaps, known as z-fighting.
  • Mismatched aspect ratio between camera and output stretches every object horizontally or vertically.
  • Matching a background photo fails when focal length and sensor width do not match the real camera.

The simple explanation

Perspective projection is how a computer draws a 3D world the way your eyes see it. Things far away look smaller. Train tracks seem to meet at the horizon. The computer copies this effect with simple math.

Imagine looking through a window at a street. Each point you see travels in a straight line to your eye. If you traced every point on the glass, you would get a perspective picture. The computer does the same tracing for every corner of every object, millions of times per second.

How it is used in practice

A visualization artist is placing a computer-generated building into a drone photograph of an empty lot. The drone camera recorded a 24 mm lens on a sensor about 13.2 mm wide. The artist sets the virtual camera to the same focal length and sensor width, then aligns its position and rotation until the rendered ground grid follows the real road edges.

The first test render looks wrong because the default 36 mm sensor width produced a narrower field of view. After correcting the sensor value, the building’s roof lines converge at the same vanishing points as the neighboring houses. The final composite reads as one photograph, and the client approves it without asking for further perspective corrections.