Polygon Rasterization: Jian Huang, CS594, Fall 2001
Polygon Rasterization: Jian Huang, CS594, Fall 2001
Scanline Rasterization
Polygon scan-conversion:
Intersect scanline with polygon edges and fill
between pairs of intersections
For y = ymin to ymax
1) intersect scanline y with each edge
2) sort interesections by increasing x
[p0,p1,p2,p3]
3) fill pairwise (p0 > p1, p2> p3, ....)
Rule
Rule:
If the intersection is the ymin of the edges
endpoint, count it. Otherwise, dont.
Performance Improvement
The goal is to compute the intersections more
efficiently. Brute force: intersect all the edges
with each scanline
find the ymin and ymax of each edge and intersect
the edge only when it crosses the scanline
only calculate the intersection of the edge with the
first scan line it intersects
calculate dx/dy
for each additional scanline, calculate the new
intersection as x = x + dx/dy
Data Structure
Edge table:
all edges sorted by their ymin coordinates.
keep a separate bucket for each scanline
within each bucket, edges are sorted by
increasing x of the ymin endpoint
Edge Table
y=8
Polygon Scan-conversion
Algorithm
Construct the Edge Table (ET);
Active Edge Table (AET) = null;
for y = Ymin to Ymax
Merge-sort ET[y] into AET by x value
Fill between pairs of x in AET
for each edge in AET
if edge.ymax = y
remove edge from AET
else
edge.x = edge.x + dx/dy
end scan_fill