4
$\begingroup$

I'm new to computer graphics and just wanted a solid understanding of why?

Why is it so important that polygons you push through the pipeline be "simple" and "convex"?

$\endgroup$

1 Answer 1

5
$\begingroup$

Polygon rasterization (the conversion of the analog polygon data into a raster image) is a key operation in rasterization-based rendering. As such, performing this operation fast, and with predictable performance, is key to the performance of graphics rendering.

It is possible to rasterize any arbitrary polygon. But rasterizing triangles is extremely simple to code and offers numerous efficiency improvements over general polygon rasterization.

Triangle rasterization is done by something called "scan conversion": you break the triangle up into a series of horizontal scan-lines (one pixel tall) of a length determined by the sides of the triangle. Building these scan-lines and getting their lengths is something you can do through basic integer math involving only additions and multiplications. Furthermore, each scan-line can be constructed independently of the others, so highly threaded hardware can be employed to perform this process efficiently.

None of this is true for arbitrary polygons. Concave polygons in particular require much more complex math. A concave polygon can have multiple lines in the same horizontal row.

Furthermore, interpolation of values across the surface of a triangle can be done by relatively simple math. For each scanline, you can compute a gradient that represents how much each value changes from one end of the line to the other. So given a starting value at one line, you can easily compute the interpolated position at any point on the scanline simply by multiplication and addition. If you're computing them in sequence, you don't even need the multiplication; successive addition is adequate.

Interpolation of values across an arbitrary polygonal surface is much more complicated.

Given all of these advantages, and the fact that you can use a series of triangles to build any arbitrary polygon, there's really no reason to rasterize any more complex shape.

$\endgroup$
1
  • 2
    $\begingroup$ BTW, GPU hardware does not really use scan-conversion; it uses tile-based rasterization instead. But the main point that the math is simple still holds: sample coverage is determined by checking the three edge inequalities, and attribute interpolation is evaluating a plane equation. $\endgroup$ Dec 5, 2018 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.