Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn...
-
Upload
mavis-oliver -
Category
Documents
-
view
234 -
download
5
description
Transcript of Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn...
![Page 1: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/1.jpg)
Graphics PipelineRasterization
CMSC 435/634
![Page 2: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/2.jpg)
Drawing Terms
• Primitive– Basic shape, drawn directly– Compare to building from simpler shapes
• Rasterization or Scan Conversion– Find pixels for a primitive– Usually for algorithms that generate all pixels for
one primitive at a time– Compare to ray tracing: all primitives for one pixel
![Page 3: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/3.jpg)
Line Drawing
• Given endpoints of line, which pixels to draw?
![Page 4: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/4.jpg)
Line Drawing
• Given endpoints of line, which pixels to draw?
![Page 5: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/5.jpg)
• Given endpoints of line, which pixels to draw?
• Assume one pixel per column (x index), which row (y index)?
• Choose based on relation of line to midpoint between candidate pixels
??
Line Drawing
???? ??
![Page 6: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/6.jpg)
Line Drawing
• Choose with decision variable• Plug midpoint into implicit line equation
• Incremental update
![Page 7: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/7.jpg)
Line Drawing• Implicit line equation
• Midpoint algorithmy = y0
d = f(x0+1, y0+0.5)for x = x0 to x1
draw(x,y)if (d < 0) then
y = y+1d = d + (x1 - x0) + (y0 - y1)
elsed = d + (y0 - y1)
![Page 8: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/8.jpg)
Polygon Rasterization
• Problem– How to generate filled polygons (by determining which pixel positions
are inside the polygon)– Conversion from continuous to discrete domain
• Concepts– Spatial coherence– Span coherence– Edge coherence
![Page 9: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/9.jpg)
Scanning Rectangles
for ( y from y0 to y1 ) for ( x from x0 to x1 ) Write Pixel (x, y)
![Page 10: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/10.jpg)
Scanning Rectangles (2)
for ( y from y0 to y1 ) for ( x from x0 to x1 ) Write Pixel (x, y)
![Page 11: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/11.jpg)
Scanning Rectangles (3)
for ( y from y0 to y1 ) for ( x from x0 to x1 ) Write Pixel (x, y)
![Page 12: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/12.jpg)
Triangle Rasterization
• Barycentric coordinates are decision variables
![Page 13: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/13.jpg)
Barycentric Triangle Rasterization
For all x in xmin to xmax do For all y in ymin to ymax do
Compute (a, b, g) for (x,y)If (a ≥ 0 and b ≥ 0 and g ≥ 0) then
c = ac0 + bc1 + gc2
Draw pixel(x,y) with color c
![Page 14: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/14.jpg)
“Clipless” Homogeneous Rasterization
• Compute barycentrics using homogeneous coordinates
• Extra edge equations for clip edges– Compute t for clip plane at each vertex– Only visible (w>near) pixels will be drawn
• Adds computation– Divide by w per pixel instead of per vertex– But avoids branching and extra triangles– Good for hardware
![Page 15: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/15.jpg)
Homogeneous Barycentrics
• Each barycentric coordinate is a linear function of X and Y
• It is 1 at one vertex and 0 at the other two
![Page 16: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/16.jpg)
Homogeneous Barycentrics
• Write formula for barycentric coordinate in homogeneous form
• This defines a system of three equations
![Page 17: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/17.jpg)
Homogeneous Barycentrics
• Know• Simplifies the linear equation to
• Which we can solve:
![Page 18: Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.](https://reader033.fdocuments.in/reader033/viewer/2022052418/5a4d1af77f8b9ab059981eb4/html5/thumbnails/18.jpg)
Incremental Computation
• a, b, and g are linear in X and Y
• What about pixel-to-pixel updates?