Unit content
Clipping and viewport mapping
Projection can produce geometry outside the region that should appear in the final image. Clipping removes or shortens primitives against the visible region before rasterization.
In a homogeneous graphics pipeline, clipping is performed in clip space before the perspective divide. This avoids pathological behavior for geometry crossing the camera plane and preserves the projective interpolation needed by later stages.
After clipping and the perspective divide, visible coordinates lie in a normalized range chosen by the graphics convention. A viewport transform then maps those normalized coordinates to pixel coordinates in a rectangular region of the framebuffer.
For example, a normalized horizontal coordinate $x_n\in[-1,1]$ can be mapped to viewport position
$$x_p=x_0+\frac{x_n+1}{2}W,$$
where $x_0$ is the viewport origin and $W$ its width.
Clipping answers what portion is visible; viewport mapping answers where that visible portion lands on the output image.