CS-378: Game Technology Lecture #1: Scan Conversion Prof. Okan Arikan

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
Advertisements

COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
+ CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Lecture 3.
Lecture 5 Rendering lines 1.Steps of line rendering 2.Scan-conversion for line segments 3.A1 tutorial CP411 Computer Graphics Fall 2007 Wilfrid Laurier.
CS-378: Game Technology Lecture #1: Scan Conversion Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic,
Line Drawing Algorithms. Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
CHAPTER 3 2D GRAPHICS ALGORITHMS
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
College of Computer and Information Science, Northeastern UniversityApril 17, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9.
CS-378: Game Technology Lecture #5: Curves and Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic,
Raster conversion algorithms for line and circle
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Scan Conversion. Also known as rasterization In our programs objects are represented symbolically –3D coordinates representing an object’s position –Attributes.
Graphics Primitives: line. Pixel Position
Chapter 1, Section 6. Finding the Coordinates of a Midpoint  Midpoint Formula: M( (x1+x2)/2, (y1+y2)/2 )  Endpoints (-3,-2) and (3,4)
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
CS-378: Game Technology Lecture #2.1: Projection Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
CS-378: Game Technology Lecture #2.2: Clipping and Hidden Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
CS-378: Game Technology Lecture #13: Animation Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
CS-321 Dr. Mark L. Hornick 1 Line Drawing Algorithms.
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
CS-378: Game Technology Lecture #15.5: Physically Based Simulation Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Lecture 13: Raster Graphics and Scan Conversion
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics CC416 Week 14 Filling Algorithms.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics : output primitives.. 2 of 32 T1 – pp. 103–123, 137–145, 147–150, 164–171 Points and LinesPoints Line Drawing AlgorithmsLine Mid–Point.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
Line Drawing Algorithms 1. A line in Computer graphics is a portion of straight line that extends indefinitely in opposite direction. 2. It is defined.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Computer Graphics CC416 Week 13 Clipping.
CS-378: Game Technology Lecture #15: Physically Based Simulation
(c) 2002 University of Wisconsin, CS559
Basic Raster Graphics Algorithms for Drawing 2D Primitives
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
University of New Mexico
Implementation III.
Introduction to Computer Graphics with WebGL
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
© University of Wisconsin, CS559 Fall 2004
Agenda Polygon Terminology Types of polygons Inside Test
Agenda Polygon Terminology Types of polygons Inside Test
Prof. Harriet Fell Fall 2011 Lecture 9 – September 26, 2011
Computer Graphics Implementation III
CS-378: Game Technology Lecture #2: Transformations Prof. Okan Arikan
CS-378: Game Technology Lecture #4: Texture and Other Maps
Chapter 3 Graphics Output Primitives
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Implementation III Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CS-378: Game Technology Lecture #1: Scan Conversion Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica Hodgins for lecture notes V2005-02-1.3

Today 2D Scan Conversion Drawing Lines Drawing Curves Filled Polygons Filling Algorithms

Drawing a Line Basically, its easy... but for the details Lines are a basic primitive that needs to be done well...

by Grabli, Durand, Turquin, Sillion Drawing a Line Basically, its easy... but for the details Lines are a basic primitive that needs to be done well... From “A Procedural Approach to Style for NPR Line Drawing from 3D models,” by Grabli, Durand, Turquin, Sillion

Drawing a Line

Drawing a Line

Drawing a Line Some things to consider How thick are lines? How should they join up? Which pixels are the right ones? For example:

Drawing a Line Inclusive Endpoints

Drawing a Line

Drawing a Line x=x1 y=y1 while(x<=x2) plot(x,y) x++ y+=Dy

Drawing a Line After rounding

Drawing a Line Accumulation of roundoff errors How slow is float- to-int conversion?

Drawing a Line

Drawing a Line Not exact math Accumulates errors void drawLine-Error1(int x1,x2, int y1,y2) float m = float(y2-y1)/(x2-x1) int x = x1 float y = y1 while (x <= x2) setPixel(x,round(y),PIXEL_ON) x += 1 y += m Not exact math Accumulates errors

Drawing a Line No more rounding void drawLine-Error2(int x1,x2, int y1,y2) float m = float(y2-y1)/(x2-x1) int x = x1 int y = y1 float e = 0.0 while (x <= x2) setPixel(x,y,PIXEL_ON) x += 1 e += m if (e >= 0.5) y+=1 e-=1.0 No more rounding

Drawing a Line void drawLine-Error3(int x1,x2, int y1,y2) int x = x1 float e = -0.5 while (x <= x2) setPixel(x,y,PIXEL_ON) x += 1 e += float(y2-y1)/(x2-x1) if (e >= 0.0) y+=1 e-=1.0

Drawing a Line void drawLine-Error4(int x1,x2, int y1,y2) int x = x1 float e = -0.5*(x2-x1) // was -0.5 while (x <= x2) setPixel(x,y,PIXEL_ON) x += 1 e += y2-y1 // was /(x2-x1) if (e >= 0.0) // no change y+=1 e-=(x2-x1) // was 0.0

Drawing a Line void drawLine-Error5(int x1,x2, int y1,y2) int x = x1 int e = -(x2-x1) // removed *0.5 while (x <= x2) setPixel(x,y,PIXEL_ON) x += 1 e += 2*(y2-y1) // added 2* if (e >= 0.0) // no change y+=1 e-=2*(x2-x1) // added 2*

Drawing a Line Faster Not wrong void drawLine-Bresenham(int x1,x2, int y1,y2) int x = x1 int y = y1 int e = -(x2-x1) while (x <= x2) setPixel(x,y,PIXEL_ON) x += 1 e += 2*(y2-y1) if (e >= 0.0) y+=1 e-=2*(x2-x1) Faster Not wrong

Drawing a Line How thick? Ends?

Drawing a Line Joining? Ugly Bevel Round Miter

Only one value of y for each value of x... Drawing Curves Only one value of y for each value of x...

Drawing Curves Parametric curves Both x and y are a function of some third parameter

Drawing Curves

Drawing Curves Draw curves by drawing line segments Must take care in computing end points for lines How long should each line segment be?

Drawing Curves Draw curves by drawing line segments Must take care in computing end points for lines How long should each line segment be? Variable spaced points

Drawing Curves Midpoint-test subdivision

Drawing Curves Midpoint-test subdivision

Drawing Curves Midpoint-test subdivision

Drawing Curves Midpoint-test subdivision Not perfect We need more information for a guarantee...

Filled Polygons

Filled Polygons

Filled Polygons

Filled Polygons

Filled Polygons

Filled Polygons

Filled Polygons

Filled Polygons Treat (scan y = vertex y) as (scan y > vertex y)

Filled Polygons Horizontal edges

Filled Polygons Horizontal edges

Filled Polygons “Equality Removal” applies to all vertices Both x and y coordinates

Filled Polygons Final result:

Filled Polygons Who does this pixel belong to?

Flood Fill

Suggested Reading Fundamentals of Computer Graphics by Pete Shirley Chapters 2.5-2.11, 3