Chapter 9: The Viewing Pipeline and Projections
Rendering a 3D scene involves converting 3D coordinates into a 2D image. This transition is handled by the viewing pipeline and projection matrices.
The 3D Viewing Pipeline
The viewing pipeline is a sequence of transformations that takes an object from its local model space to the final screen space.
- Model Transformation: Objects from local space (around their own origin) are placed into world space.
- Viewing (Camera) Transformation: The entire world is moved so the camera sits at the origin looking down the axis (standard in many systems).
- Projection Transformation: The 3D view space is projected onto a 2D plane (clip space).
- Perspective Division: Each coordinate is divided by to account for perspective.
- Viewport Transformation: The coordinates are mapped to the actual pixel dimensions of the window on the screen.
Projection Types
Projection is the process of mapping a higher-dimensional space (3D) to a lower-dimensional space (2D).
Orthographic (Parallel) Projection
In an orthographic projection, parallel lines in 3D remain parallel in the 2D image. Size does not depend on distance.
- View Volume: A rectangular box (frustum).
- Applications: Engineering drawings, blueprinting, and technical illustrations.
Where represent Left, Right, Bottom, Top, Near, and Far planes.
Perspective Projection
Perspective projection mimics how the human eye and cameras perceive the world. Parallel lines appear to converge at a "vanishing point." Objects appear smaller as their distance from the camera increases.
- View Volume: A truncated pyramid called a frustum.
- Applications: Most realistic 3D games, movies, and simulations.
The key feature of perspective projection is the perspective divide. The component of the homogeneous coordinate becomes the distance from the camera. Dividing and by creates the perspective effect.
Clipping
Before we display anything, we must "clip" the scene against the view frustum.
- Clipping Volumes: Any part of an object that falls outside the Left, Right, Top, Bottom, Near, or Far planes is discarded.
- Near Plane Clipping: Essential for preventing objects from being too close and distorting or passing behind the camera.
Summary
The projection pipeline is the final bridge between our abstract 3D mathematical models and the 2D grid of pixels on our screens. Choosing between orthographic and perspective projections can fundamentally change the aesthetic and functional characteristics of a digital experience. Understanding how to construct these matrices is the key to creating a sense of depth and realism in computer graphics.