Download presentation
Presentation is loading. Please wait.
Published byDerrick Garrison Modified over 9 years ago
1
Graphics Pipeline Rasterization CMSC 435/634
2
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
3
Line Drawing Given endpoints of line, which pixels to draw?
4
Line Drawing Given endpoints of line, which pixels to draw?
5
Assume one pixel per column (x index), which row (y index)? Choose based on relation of line to midpoint between candidate pixels ? ? Line Drawing ? ? ? ? ? ?
6
Choose with decision variable Plug midpoint into implicit line equation Incremental update
7
Line Drawing Implicit line equation Midpoint algorithm y = y 0 d = f(x 0 +1, y 0 +0.5) for x = x 0 to x 1 draw(x,y) if (d < 0) then y = y+1 d = d + (x 1 - x 0 ) + (y 0 - y 1 ) else d = d + (y 0 - y 1 )
8
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
9
Scanning Rectangles for ( y from y 0 to y 1 ) for ( x from x 0 to x 1 ) Write Pixel (x, y)
10
Scanning Rectangles (2) for ( y from y 0 to y 1 ) for ( x from x 0 to x 1 ) Write Pixel (x, y)
11
Scanning Rectangles (3) for ( y from y 0 to y 1 ) for ( x from x 0 to x 1 ) Write Pixel (x, y)
12
Barycentric Coordinates Use non-orthogonal coordinates to describe position relative to vertices – Scaled edge equations 0 on edge, 1 at opposite vertex
13
Barycentric Example
14
Barycentric Coordinates Computing coordinates – Equations for , and in book – Solutions to linear equations of x,y Ratio of areas / ratio of cross products – Area = 0.5*b*h – Length of cross product = 2*area of triangle Matrix form
15
Area Computation
16
Barycentric Matrix Computation Edge equation for each coordinate Plug in known values at the vertices
17
Barycentric Matrix Computation Write linear system in matrix form Solve
18
Barycentric Matrix Computation Solutions = rows of inverse matrix
19
Barycentric Rasterization For all x do For all y do Compute ( , , ) for (x,y) If ( [0,1] and [0,1] and [0,1] then c = c 0 + c 1 + c 2 Draw pixel (x,y) with color c
20
Barycentric Rasterization x min = floor(min(x 0,x 1,x 2 )) x max = ceiling(max(x 0,x 1,x 2 )) y min = floor(min(y 0,y 1,y 2 )) y max = ceiling(max(y 0,y 1,y 2 )) for y = y min to y max do for x = x min to x max do = (x,y) = (x,y) = (x,y) If ( [0,1] and [0,1] and [0,1] then c = c 0 + c 1 + c 2 Draw pixel (x,y) with color c
21
Incremental Computation , , and are linear in x and y What about (x+1,y)?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.