Download presentation
Presentation is loading. Please wait.
Published byRosaline Bailey Modified over 9 years ago
1
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008
2
Today Finish Projection Rasterization Antialising Hidden Surface Removal Reading: – Shirley ch 7,4,8
3
3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing Rotation Translation Projective, Scale Translation
4
Clipping and the viewing frustum The center of projection and the portion of the projection plane that map to the final image form an infinite pyramid. The sides of the pyramid are clipping planes. Frequently, additional clipping planes are inserted to restrict the range of depths. These clipping planes are called the near and far or the hither and yon clipping planes. All of the clipping planes bound the viewing frustum.
5
View Volume Transformation We want a matrix that will take points in our perspective view volume and transform them into the orthographic view volume – This matrix will go in our pipeline before an orthographic projection matrix (l,b,n) (r,t,n)(l,b,n) (r,t,n) (r,t,f)
6
Mapping Lines We want to map all the lines through the center of projection to parallel lines – This converts the perspective case to the orthographic case, we can use all our existing methods The relative intersection points of lines with the near clip plane should not change The matrix that does this looks like the matrix for our simple perspective case n f -z y
7
How to get this mapping? n f -z y
8
Properties of this mapping If z = n, M(x,y,z,1) = [x,y,z,1] near plane is unchanged If x/z = c1, y/z = c2, then x’=n*c1, y’=n*c2 bending converging rays to parallel rays If z1 < z2, z1’ < z2’ z ordering is preserved n f -z y In pyramid In cube
9
General Perspective
10
To Canonical view volume Perspective projection transforms a pyramid volume to an orthographic view volume (l,b,n) (r,t,n)(l,b,n) (r,t,n) (r,t,f) (1,-1,1) (-1,1,-1) Canonical view volume [-1,1]^3 Scale, translate
11
Orthographic View to Canonical Matrix
12
Complete Perspective Projection After applying the perspective matrix, we map the orthographic view volume to the canonical view volume:
13
3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing : Projective, Scale, Translation Canonical View Space Screen Space (2D) Rotation Translation Image Space (pixels) Raster Space
14
3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing Canonical View Space Screen Space (2D) Rotation Translation Image Space (pixels) Raster Space
15
3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing Canonical View Space Screen Space (2D) Rotation Translation Image Space (pixels) Raster Space Order matters!!!
16
Canonical Window Transform (-1,-1) (1,1) n y -1 (x min,y min )=(-0.5,-0.5) n x -1 (x max, y max )=(n x -0.5,n y -0.5)
17
3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing Canonical View Space Screen Space (2D) Rotation Translation Image Space (pixels) Raster Space
18
Polygons are basic shape primitives Any 3D shape can be approximated by a polygon using a locally linear (planar) approximation. To improve the quality of fit, we need only increase the number of edges
19
Line Drawing (x 1, y 1 ) (x 0, y 0 )
20
Line Drawing (x 1, y 1 ) (x 0, y 0 ) for x = x0 to x1 do y=y0+(∆y/∆x)(x-x0) draw(x,round(y)) for x = x0 to x1 do y=y0+(∆y/∆x)(x-x0) draw(x,round(y))
21
Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1
22
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 f(x+1,y+0.5)<0
23
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 f(x+1,y+0.5)<0 Incremental Evaluation
24
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else d<0 d=f(x+1,y+0.5) D=d-∆y+∆x D=d-∆y Incremental Evaluation
25
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else d<0 d=2f(x+1,y+0.5) D=d-2∆y+2∆x D=d-2∆y Incremental Evaluation Integer operation
26
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else d<0 d=2f(x+1,y+0.5) D=d-2∆y+2∆x D=d-2∆y
27
Implicit Line Drawing y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else d<0 d=2f(x+1,y+0.5) D=d-2∆y+2∆x D=d-2∆y
28
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1
29
Implicit Line Drawing y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1
30
Implicit Line Drawing (x 1, y 1 ) (x 0, y 0 ) y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else y = y0 for x = x0 to x1 do draw(x,y) if (some condition) then y=y+1 else d<0 d=2f(x+1,y+0.5) D=d-2∆y+2∆x D=d-2∆y If ∆y>∆x, switch x and y
31
Drawing Triangle
32
for all y do for all x do if (in triangle) then draw(x,y) with color c for all y do for all x do if (in triangle) then draw(x,y) with color c A3A3 A1A1 A2A2 P
33
Drawing Triangle for all y do for all x do compute t 1,t 2,t 3 if t 1,t 2,t 3 in [0,1] then draw(x,y) with color t 1 c 1 +t 2 c 2 +t 3 c 3 for all y do for all x do compute t 1,t 2,t 3 if t 1,t 2,t 3 in [0,1] then draw(x,y) with color t 1 c 1 +t 2 c 2 +t 3 c 3 A3A3 A1A1 A2A2 P
34
Common Edge for all y do for all x do compute t 1,t 2,t 3 if t 1,t 2,t 3 in [0,1] then draw(x,y) with color t 1 c 1 +t 2 c 2 +t 3 c 3 for all y do for all x do compute t 1,t 2,t 3 if t 1,t 2,t 3 in [0,1] then draw(x,y) with color t 1 c 1 +t 2 c 2 +t 3 c 3
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.