Class2

Class2 - CS580 (Computer Graphics Rendering) Rasterization...

Info iconThis preview shows pages 1–19. Sign up to view the full content.

View Full Document Right Arrow Icon
CS580 (Computer Graphics Rendering) Rasterization HW2 Flat-shaded z-buffer triangle teapot Ulrich Neumann
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Rendering HW in steps first rasterize a screen space triangle Input tris (pre-xformed) and output pixels to display built for HW1 (HW2) then add transforms (HW 3) then add shading (HW 4)
Background image of page 2
Rasterization Array of pixels 3 0 1 2 3 4 2 1 0
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Rasterizing Lines Given two endpoints, P= (x 0 , y 0 ), R = (x 1 , y 1 ) find the pixels that make up the line P R
Background image of page 4
Rasterizing Lines Requirements 1. No gaps 1. Minimize error (distance to true line)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Rasterizing Lines ) ( x f b mx y = + = Taylor Expansion: x x f y x x y + = + ) ( ' ) ( Equation of a Line: So if we have an x,y on the line, we can find the next point incrementally
Background image of page 6
Rasterizing Lines Line(int x0, int y0, int x1, int y1)   float dx = x1 – x0;   float dy = y1 – y0;   float m  = dy/dx;   float x = x0, y= y0;   for(x = x0; x <= x1; x++)      setPixel(x,round(y));      y = y+m; Assume –1 < m < 1, x0 < x1
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Rasterizing Lines Although correct and usable, there are problems with previous simple algorithm 1. rounding takes time – case checking 2. uses floating point arithmetic
Background image of page 8
Midpoint Algorithm NE E Start P=(x,y) M Q If Q <= M, choose East. If Q > M, choose NorthEast
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Implicit Form of a Line dx B c dx b dy a dx B y dx x dy B x dx dy y c by ax = - = = = + - + = = + + 0 0 Implicit form Explicit form Positive below the line Negative above the line Zero on the line
Background image of page 10
Decision Function c y b x a y x F d c y b x a y x F d + + + + = + + = + + = = ) ( ) 1 ( ) , 1 ( ) , ( 2 1 2 1 Choose NE if d > 0 Choose E if d <= 0
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Incrementing d c y b x a y x F d new + + + + = + + = ) ( ) 2 ( ) , 2 ( 2 1 2 1 If choosing E: But: c y b x a y x F d old + + + + = + + = ) ( ) 1 ( ) , 1 ( 2 1 2 1 So: E a d d d old new inc = = - =
Background image of page 12
Incrementing d c y b x a y x F d new + + + + = + + = ) ( ) 2 ( ) , 2 ( 2 3 2 3 If choosing NE: But: c y b x a y x F d old + + + + = + + = ) ( ) 1 ( ) , 1 ( 2 1 2 1 So: NE b a d d d old new inc = + = - =
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Initializing d 2 1 2 1 2 1 2 1 0 0 0 0 0 0 ) ( ) 1 ( ) , 1 ( b a b a c y b x a c y b x a y x F d + = + + + + = + + + + = + + = Multiply everything by 2 to remove fractions (doesn’t change the sign)
Background image of page 14
Midpoint Algorithm Line(int x0, int y0, int x1, int y1)   int dx = x1 – x0, dy = y1 – y0;   int d = 2*dy-dx;   int delE = 2*dy, delNE = 2*(dy-dx);   int x = x0, y = y0;   setPixel(x,y);   while(x < x1)      if(d<=0)         d += delE; x = x+1;      else         d += delNE; x = x+1; y = y+1;      setPixel(x,y); Assume 0 < m < 1, x0 < x1
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Anti-aliasing Lines Lines appear jaggy Sampling is inadequate
Background image of page 16
Anti-aliasing Lines Trade intensity resolution for spatial resolution
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Anti-aliasing Lines Line(int x0, int y0, int x1, int y1)   float dx = x1 – x0;   float dy = y1 – y0;   float m  = dy/dx;   float x = x0, y= y0;   for(x = x0; x <= x1; x++)
Background image of page 18
Image of page 19
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 37

Class2 - CS580 (Computer Graphics Rendering) Rasterization...

This preview shows document pages 1 - 19. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online