Class2

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

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

CS580 (Computer Graphics Rendering) Rasterization HW2 Flat-shaded z-buffer triangle teapot Ulrich Neumann

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

View Full Document
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)
Rasterization Array of pixels 3 0 1 2 3 4 2 1 0

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

View Full Document
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
Rasterizing Lines Requirements 1. No gaps 1. Minimize error (distance to true line)

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

View Full Document
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
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

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

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

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

View Full Document
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
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

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

View Full Document
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 = = - =
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 = + = - =

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

View Full Document
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)
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

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

View Full Document
Anti-aliasing Lines Lines appear jaggy Sampling is inadequate
Anti-aliasing Lines Trade intensity resolution for spatial resolution

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

View Full Document
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++)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online