Download presentation
Presentation is loading. Please wait.
Published byPamela Reeves Modified over 8 years ago
1
Rasterization CENG 477 Introduction to Computer Graphics Slides from Steve Marschner, CS4620, 2008 Cornell University
4
Primitives Graphic SW and HW provide subroutines to describe a scene in terms of basic geometric structures called output primitives. Output primitives are combined to form complex structures Simplest primitives Point (pixel) Line segment
6
Rasterization Converting output primitives into frame buffer updates. Choose which pixels contain which intensity value. Constraints Straight lines should appear as a straight line primitives should start and end accurately Primitives should have a consistent brightness along their length They should be drawn rapidly
8
OpenGL Point Functions glBegin (GL_POINTS); glVertex2i(50, 100); glVertex2i(75, 150); glVertex2i(100, 200); glEnd();
9
OpenGL Line Functions glBegin (GL_LINES); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2
10
OpenGL Line Functions glBegin (GL_LINE_STRIP); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2
11
OpenGL Line Functions glBegin (GL_LINE_LOOP); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2
12
Line Drawing Algorithms Simple approach: sample a line at discrete positions at one coordinate from start point to end point, calculate the other coordinate value from line equation (slope-intercept line equation). If m>1, increment y uniformly and find x If m ≤1, increment x uniformly and find y Is this correct?
14
Digital Differential Analyzer Simple approach: too many floating point operations and repeated calculations Calculate from for a value
17
DDA Algorithm
18
DDA Is faster than directly implementing y=mx+b. No floating point multiplications. We have floating point additions only at each step. But what about round-off errors? Can we get rid of floating point operations completely?
19
Bresenham's Line Algorithm DDA: Still floating point operations x k+1 xkxk ykyk yk+1yk+1 y=mx+b d upper d lower x k+2 x k+3
20
at step k+1: 0 if p k was negative1 if p k was positive to calculate p 0 at the starting pixel position (x 0,y 0 )
21
Bresenham’s Line-Drawing Algorithm
22
Midpoint algorithm from the book Implicit line equation: Incremental computation: Evaluation of line equation at midpoint: What does this mean?
23
Midpoint algorithm from the book
24
Example Using Bresenham’s algorithm digitize the line with endpoints (20,10) and (30,18)
25
Example continued... 2021302225 10 18
26
Plotted pixels 2021302225 10 18
41
Computing the Barycentric Coordinates
42
Triangle rasterization algorithm Combine this with incremental linear interpolation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.