Scan Conversion of Polygons. Dr. Scott Schaefer

Similar documents
Filled Area Primitives. CEng 477 Introduction to Computer Graphics METU, 2007

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

CS 4731/543: Computer Graphics Lecture 7 (Part I): Raster Graphics: Polygons & Antialiasing. Emmanuel Agu

2D Drawing Primitives

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Computer Graphics 7 - Rasterisation

Agenda. Polygon Terminology Types of polygons Inside Test Polygon Filling Algorithms. Scan-Line Polygon Fill Algorithm Flood-Fill Algorithm

Text in OpenGL and Windows. Computer Graphics Attributes. Computer Graphics. Binghamton University. EngiNet. Thomas J. Watson

Rasterizing triangles

CSC Computer Graphics

Shading/Texturing. Dr. Scott Schaefer

Computer Graphics CS 543 Lecture 11 (Part 1) Polygon Filling & Antialiasing

CS488 2D Graphics. Luc RENAMBOT

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Chapter 8: Implementation- Clipping and Rasterization

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

1 Introduction to Graphics

Graphics (Output) Primitives. Chapters 3 & 4

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

CS130 : Computer Graphics. Tamar Shinar Computer Science & Engineering UC Riverside

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Computer graphic -- Programming with OpenGL I

CSC 8470 Computer Graphics. What is Computer Graphics?

SE Mock Online Test 1-CG

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Computer Graphics II

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

CS 248 Assignment 2 Polygon Scan Converter. CS248 Presented by Abe Davis Stanford University October 17, 2008

? Which intermediate. Recall: Line drawing algorithm. Programmer specifies (x,y) of end pixels Need algorithm to determine pixels on line path

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Chapter 3. Sukhwinder Singh

Computer Graphics. - Rasterization - Philipp Slusallek

Triangle Fast Scan-Conversion Algorithm Report

COMP371 COMPUTER GRAPHICS

Computer Graphics Geometry and Transform

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

CS 325 Computer Graphics

Hidden surface removal. Computer Graphics

Hidden-Surface Removal.

The Traditional Graphics Pipeline

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

4.5 VISIBLE SURFACE DETECTION METHODES

Scan Converting Text. Attributes of Output Primitives. CS 460/560 Computer Graphics. Binghamton University. EngiNet. Thomas J.

OpenGL Primitives. Examples: Lines. Points. Polylines. void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend(); }

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives

Clipping Lines. Dr. Scott Schaefer

Scan Conversion- Polygons

8. Hidden Surface Elimination

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Topics. From vertices to fragments

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

Beyond Programmable Shading. Scheduling the Graphics Pipeline

Rendering. Part 1 An introduction to OpenGL

Werner Purgathofer

Visible Surface Detection. (Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

Scanline Rendering 2 1/42

CS 248 Assignment 2 Polygon Scan Conversion. CS248 Presented by Michael Green Stanford University October 20, 2004

Incremental Form. Idea. More efficient if we look at d k, the value of the decision variable at x = k

CS 543: Computer Graphics. Rasterization

(Refer Slide Time: 00:02:00)

The Traditional Graphics Pipeline

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Spring 2009 Prof. Hyesoon Kim

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

The Traditional Graphics Pipeline

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Einführung in Visual Computing

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Rasterization, or What is glbegin(gl_lines) really doing?

Power Efficiency for Software Algorithms running on Graphics Processors. Björn Johnsson Per Ganestam Michael Doggett Tomas Akenine-Möller

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

2D Viewing. Viewing Pipeline: Window-Viewport Transf.

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

UNIT 2 GRAPHIC PRIMITIVES

Geometry Unit 6 Properties of Quadrilaterals Classifying Polygons Review

Outline. Scanline conversion Incremental updates Edge table and active edge table. Gouraud shading Phong interpolation

Hardware-driven visibility culling

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

Fondamenti di Grafica 3D The Rasterization Pipeline.

Attributes of Graphics Primitives

Ray Casting of Trimmed NURBS Surfaces on the GPU

Graphics Pipeline & APIs

Visible Surface Detection Methods

Spring 2011 Prof. Hyesoon Kim

Triangle Rasterization

Polygon Triangulation. (slides partially by Daniel Vlasic )

Transcription:

Scan Conversion of Polygons Dr. Scott Schaefer

Drawing Rectangles Which pixels should be filled? /8

Drawing Rectangles Is this correct? /8

Drawing Rectangles What if two rectangles overlap? 4/8

Drawing Rectangles Is this correct? /8

Drawing Rectangles Is this correct? Overlap!!! /8

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

Drawing Rectangles Artifacts are possible 8/8

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 9/8

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

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

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

General Polygons Data Structures Edge: Edge maxy currentx xincr ( xi, yi ) ( xi, yi ) maxy: currentx: xincr: max( y i, y i ) xi, yi min( y xi, otherwise x y i i x y i i i, y i ) /8

General Polygons Data Structures Edge: Edge maxy currentx xincr ( xi, yi ) ( xi, yi ) maxy: currentx: xincr: max( y i, y i ) xi, yi min( y xi, otherwise x y i i x y i i i, y i ) Horizontal edges will not be used!!! 4/8

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

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

General Polygons Algorithm line = 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 /8

General Polygons Example Active Edge Table 4 Active Edge List 4 C B D G F E A 4 8/8

General Polygons Example Active Edge Table 4 Active Edge List 4 C B D G F E A 4 9/8

General Polygons Example Active Edge Table 4 BC Active Edge List 4 C B D G F E A 4 /8

General Polygons Example Active Edge Table 4 BC CD Active Edge List 4 C B D G F E A 4 /8

General Polygons Example Active Edge Table 4 BC CD ED Active Edge List 4 C B D G F E A 4 /8

General Polygons Example Active Edge Table 4 BC CD ED Active Edge List 4 C B D G F E A 4 /8

General Polygons Example Active Edge Table 4 BC CD FG ED Active Edge List 4 C B D G F E A 4 4/8

General Polygons Example Active Edge Table 4 BC CD FG ED AG Active Edge List 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List AG 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List AG FG ED 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List AG FG ED 4 C B D G F E A 4 8/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List AG 4 FG ED 4 C B D G F E A 4 9/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List AG 4 FG ED 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List AG FG ED 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List ED 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List ED 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List ED 4 C B D G F E A 4 4/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List ED 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List ED CD 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List ED CD 4 C B D G F E A 4 /8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List CD 4 C B D G F E A 4 8/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List CD 4 C B D G F E A 4 9/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List BC CD 4 C B D G F E A 4 4/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List BC CD 4 C B D G F E A 4 4/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List BC CD 4 C B D G F E A 4 4/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List BC CD 4 C B D G F E A 4 4/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List BC CD 4 C B D G F E A 4 44/8

General Polygons Example maxy currentx xincr Active Edge Table 4 BC CD FG ED AG Active Edge List BC CD 4 C B D G F E A 4 4/8

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) 4/8

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 4/8

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

Boundary Fill Example 49/8

Boundary Fill Example /8

Boundary Fill Example /8

Boundary Fill Example /8

Boundary Fill Example /8

Boundary Fill Example 4/8

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 /8

Flood Fill Example /8

Flood Fill Example /8

Flood Fill Example 8/8

Flood Fill Example 9/8

Flood Fill Example /8

Flood Fill Example /8

Flood Fill Example /8

Flood Fill Example /8

Flood Fill Example 4/8

Flood Fill Example /8

Flood Fill Example /8

Flood Fill Example /8

Flood Fill Example 8/8

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_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP GL_POLYGON 9/8

Performance Nvidia Nvidia 88 GT GTX ATI Radeon HD 48 ATI Radeon HD 48 New Drivers Immediate Mode.... Display Lists 8.. 4. 49. Vertex Arrays.... Vertex Buffer Objects.. 4.. Frames per second displaying a 4, triangle model. CPU was an Intel Core or Core i 94. /8

Tile-Based Rasterization Screen /8

Tile-Based Rasterization /8

Tile-Based Rasterization /8

Tile-Based Rasterization 4/8

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

Even More Parallelization /8

Even More Parallelization /8

Even More Parallelization 8/8

Point in Triangle ( x i, yi ) ( x, y) ( x i, yi ) x y i i x y x y i i x y 9/8

Even More Parallelization 8/8

Even More Parallelization Only need to check until first polygon hit 8/8