Labs ICT
โญ Pro Login

Viewing Pipeline

From world coordinates to screen pixels

The Viewing Pipeline

The viewing pipeline is the sequence of transformations that converts 3D world coordinates into 2D screen pixels. Understanding this pipeline is fundamental to mastering computer graphics.

Pipeline Stages

Complete Pipeline:

  Object Space
      |
      v  [Model Transform]
  World Space
      |
      v  [View Transform]
  Camera/View Space
      |
      v  [Projection Transform]
  Clip Space (Homogeneous)
      |
      v  [Perspective Division]
  NDC (Normalized Device Coordinates)
      |
      v  [Viewport Transform]
  Screen Space
      |
      v  [Rasterization]
  Fragments/Pixels

Total transform:
  M = Viewport * Projection * View * Model

Model Transform

Places objects in the world by applying translation, rotation, and scaling.

Model = T * R * S

Each object has its own model matrix.
Multiple objects: each has a unique M_model.

View Transform

Positions the camera in the world. Transforms from world space to camera space.

View Matrix:

  Define camera by:
    - eye (position)
    - center (look-at point)
    - up (up vector)

  View = R * T

  Where:
    T = translate eye to origin
    R = rotate camera axes to align with world axes

  lookAt(eye, center, up):
    z = normalize(center - eye)  // forward
    x = normalize(up ร— z)       // right
    y = z ร— x                   // up

    View = [ x.x  x.y  x.z  -dot(x,eye) ]
           [ y.x  y.y  y.z  -dot(y,eye) ]
           [-z.x -z.y -z.z   dot(z,eye) ]
           [  0    0    0       1        ]

Viewport Transform

Maps NDC coordinates to screen pixel coordinates.

Viewport Transform:

  x_screen = (x_ndc + 1) * width/2  + x_offset
  y_screen = (y_ndc + 1) * height/2 + y_offset
  z_screen = (z_ndc + 1) * max_depth / 2

  Where x_offset, y_offset are viewport position.

Clipping

Before rasterization, primitives outside the view volume are clipped (removed). Only visible portions are sent to the rasterizer.

Clipping against frustum:
  - Lines partially outside โ†’ trimmed to boundary
  - Triangles partially outside โ†’ split into smaller triangles
  - Completely outside โ†’ discarded

๐Ÿงช Quick Quiz

The viewing transformation converts coordinates from: