Scan Conversion of Polygons

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Mark Nelson Rendering algorithms Fall 2013
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CPCS 391 Computer Graphics 1 Lecture 5: Polygon Filling
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Graphics Programming: Polygon Filling
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Scan Conversion Week 6, Mon 6 Oct 2003 recap: Bresenham line algorithm scan.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
CS 454 Computer graphics Polygon Filling
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Rasterization Foley, Ch: 3. Pixels are represented as disjoint circles centered on uniform grid Each (x,y) of the grid has a pixel Y X (1,1) (1,2) (0,0)
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
TOPIC 4 PART III FILL AREA PRIMITIVES POLYGON FILL AREAS CGMB214: Introduction to Computer Graphics.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
1/24/20061 Fill-Area Algorithms and Functions. 1/24/20062 Learning Objectives OpenGL state variables Color and gray scale Color functions Point attributes.
Polygon Scan Conversion and Z-Buffering
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
1 CS 430/536 Computer Graphics I Polygon Clipping and Filling Week 3, Lecture 5 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Hidden Surface Removal
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
Computer Graphics Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Graphics Output Primitives
Lecture 15: Raster Graphics and Scan Conversion
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 4: Color and Attributes Isaac Gang University.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
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 Through OpenGL: From Theory to Experiments, Second Edition Chapter 14.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
CS552: Computer Graphics Lecture 16: Polygon Filling.
CSCE 441 Lecture 2: Scan Conversion of Lines
Visible Surface Detection
Computer Graphics Implementation II
Computer Graphics Filling.
Introduction to Polygons
(c) 2002 University of Wisconsin, CS559
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Visible-Surface Detection Methods
Fill Area Algorithms Jan
Hidden Surfaces Dr. Scott Schaefer.
Polygon Filling Algorithms
Query Processing in Databases Dr. M. Gavrilova
CSCE 441 Lecture 2: Scan Conversion of Lines
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Agenda Polygon Terminology Types of polygons Inside Test
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
(c) 2002 University of Wisconsin, CS559
Rasterization Week 6, Mon Feb 12
Programming with OpenGL Part 4: Color and Attributes
Rasterizing Polygons Lecture 29 Wed, Dec 7, 2005.
Where We Stand At this point we know how to: Next thing:
Polygons.
Presentation transcript:

Scan Conversion of Polygons Dr. Scott Schaefer

Which pixels should be filled? Drawing Rectangles Which pixels should be filled?

Drawing Rectangles Is this correct?

What if two rectangles overlap? Drawing Rectangles What if two rectangles overlap?

Drawing Rectangles Is this correct?

Drawing Rectangles Overlap!!! Is this correct?

Solution: Exclude pixels on top and right Drawing Rectangles Solution: Exclude pixels on top and right

Artifacts are possible Drawing Rectangles Artifacts are possible

General Polygons – Basic Idea Intersect scan lines with edges Find ranges along x Fill interior of those ranges Don’t fill top/right Edges may NOT match with line drawing algo

General Polygons – Basic Idea Use coherence to speed up Intersect scan lines with edges Find ranges along x Fill interior of those ranges Don’t fill top/right Edges may NOT match with line drawing algo

General Polygons – Basic Idea Use coherence to speed up Intersect scan lines with edges Find ranges along x Fill interior of those ranges Edges intersection one scan line are mostly same as those intersecting previous scan line

General Polygons – Basic Idea Use coherence to speed up Intersect scan lines with edges Find ranges along x Fill interior of those ranges The x-value of an intersection with one scan line is close to the intersection with the previous one

General Polygons – Data Structures Edge: maxY: currentX: xIncr: Edge maxY currentX xIncr

General Polygons – Data Structures Edge: maxY: currentX: xIncr: Edge maxY currentX xIncr Horizontal edges will not be used!!!

General Polygons – Data Structures Active Edge Table: Store a linked-list per scan-line. Insert edges into table at scan-line associated with lowest end-point. Scan Lines Edges

General Polygons – Data Structures Active Edge List: List of all edges intersecting current scan-line sorted by their x-values Edges

General Polygons – Algorithm line = 0 While (line < height ) Add edges to Active Edge List from Active Edge Table starting at line Remove edges that end at line Fill pixels Increment x-values on edges in Active Edge List Increment line

General Polygons – Example C Active Edge Table B D G Active Edge List F E A

General Polygons – Example C Active Edge Table B D G AB Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D G AB Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D CD G AB Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D CD G ED AB Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D CD G ED AB Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E A

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB BC CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB BC CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

General Polygons – Problems Sliver polygons may not be drawn correctly No simple solution Long, thin triangles cause problems Want triangles with good aspect ratio (close to equilateral)

Boundary Fill Start with drawn outline of a polygon and an interior point Recursively recolor outward from that point If neighbor different, then recolor and recur Everything within the boundary is changed to that color

Boundary Fill How to define a neighbor? 8-connected 4-connected

Boundary Fill – Example

Boundary Fill – Example

Boundary Fill – Example

Boundary Fill – Example

Boundary Fill – Example

Boundary Fill – Example

Flood Fill Start with a point Define color under that point as the interior color Recursively recolor outward from that point If neighbor is interior color, then recolor and recur Contiguous regions of the same color are recolored

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

Flood Fill – Example

OpenGL: Drawing Polygons Lots of different primitives supported GPU only draws triangles OpenGL triangulates all polygons Problems with concave polygons! How data is passed to GPU makes a significant difference in speed GL_QUADS GL_POLYGON GL_TRIANGLES GL_TRIANGLE_FAN GL_TRIANGLE_STRIP GL_QUAD_STRIP

Performance Nvidia 7300 GT1 Nvidia 8800 GTX1 ATI Radeon HD 48502 New Drivers Immediate Mode 15.5 21.0 33.0 Display Lists 28.3 22.0 463.5 497.5 Vertex Arrays 33.5 35.5 75.0 335.0 Vertex Buffer Objects 50.0 200.0 476.3 506.0 Frames per second displaying a 413,236 triangle model. CPU was an Intel Core 2 67001 or Core i7 9402.

Tile-Based Rasterization Screen

Tile-Based Rasterization

Tile-Based Rasterization

Tile-Based Rasterization

Tile-Based Rasterization Each thread draws polygon into local frame buffer Copies local frame buffer into global frame buffer when complete

Even More Parallelization

Even More Parallelization

Even More Parallelization

Point in Triangle

Even More Parallelization

Even More Parallelization Only need to check until first polygon hit