Every time a 3D game renders a frame, millions of triangles compete to appear on screen. Most of them lie partially or entirely outside the visible window. Sending those stray fragments all the way to the pixel-painting stage wastes work — and can produce corrupted pixels at the viewport boundary. The solution is clipping: trim each polygon to the viewable region before rasterizing it.
The classic tool for this job is the Sutherland-Hodgman algorithm, published by Ivan Sutherland and Gary Hodgman in 1974. Its insight is elegantly simple: instead of trying to clip a polygon against the entire window at once, clip it against one edge at a time. After four passes (left, right, top, bottom), only the intersection of the polygon and the window remains.
What makes it beautiful is the reentrant structure: the output of each clipping pass feeds directly into the next. This pipeline style maps perfectly onto hardware and onto the GPU pipelines that descended from it.
Comments
Loading comments...