Graphics / Reference / Triangle rasterisation
Triangle rasterisation
Triangle rasterisation finds the pixels covered by a triangle. A scanline implementation sorts the vertices by y, processes upper and lower parts separately, and fills between the two active edges on each row.
A filled triangle is rasterised by finding the pixels covered by its area rather than only drawing its three boundary edges. Triangle meshes use many such primitives to represent complex surfaces: increasing mesh density provides a finer geometric approximation, while wireframe and shaded views expose the same underlying triangular structure in different ways. Triangle rasterisation is a fundamental operation in conventional raster graphics pipelines.
The scanline structure mirrors rectangle filling. Determine the triangle's vertical extent, then for each row obtain the two current boundary intersections and fill the horizontal span between them.
Using the y-down convention of this experience, sort the vertices by increasing y and name them A, B and C, so A is top, B is middle and C is bottom.
The active boundary changes at B. In the upper range the active edges are AB and AC. In the lower range they are BC and AC. Use non-overlapping row ranges so the scanline through B is processed once: the upper range stops before B and the lower range begins at B. The long edge AC continues through both parts.
The associated figures show triangle meshes, covered triangle pixels, changing scanline spans and the upper/lower split through B.
Builds on
Read
- Read the chapter: Triangle rasterisation