Viewport Transformation

What’s after MVP?

  • Model transformation(placing objects)
  • View transformation(placing camera)
  • Projection transformation
    • Orthographic projection(cuboid to canonical cube $[-1,1]^{3}$)
    • Perspective projection (frustum to canonical cube)

Cannonical cube to screen

  • Define the screen space

Pixel’s indices are in the form of $(x,y)$, where both x and y are integers, $pixel(x,y)$ is centered at $(x + 0.5, y + 0.5)$ And the screen covers range $(0,0)$ to $(width,height)$.

  • ignore z
  • transform in xy plane: $[-1,1]^{2}$ to $[0,width]×[0,height]$

  • viewport transform matrix

It is not difficult to derive that the viewport transformation matrix is simply scaling plus translation.