Graphics Programming: Polygon Filling

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
Computer Graphics- SCC 342
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
3D Graphics Rendering and Terrain Modeling
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
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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)
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
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.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Polygon Scan Conversion and Z-Buffering
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
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:
Graphics Graphics Korea University cgvr.korea.ac.kr Raster Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
College of Computer and Information Science, Northeastern UniversityMay 27, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 9 – September.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
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.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Lecture 15: Raster Graphics and Scan Conversion
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
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 Through OpenGL: From Theory to Experiments, Second Edition Chapter 14.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Introduction to Polygons
Polygons.
(c) 2002 University of Wisconsin, CS559
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
University of New Mexico
Implementation III.
Fill Area Algorithms Jan
3D Graphics Rendering PPT By Ricardo Veguilla.
Introduction to Computer Graphics with WebGL
© University of Wisconsin, CS559 Fall 2004
Agenda Polygon Terminology Types of polygons Inside Test
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
Lecture 13 Clipping & Scan Conversion
Prof. Harriet Fell Fall 2011 Lecture 9 – September 26, 2011
Computer Graphics Implementation III
Introduction to Meshes
(c) 2002 University of Wisconsin, CS559
© University of Wisconsin, CS559 Fall 2004
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Where We Stand At this point we know how to: Next thing:
Implementation III Ed Angel Professor Emeritus of Computer Science
Polygons.
Introduction to Meshes
Presentation transcript:

Graphics Programming: Polygon Filling

Agenda Terminology Generalities Scan-Line Polygon Fill Algorithm Boundary-Fill Algorithm Flood-Fill Algorithm

A Polygon Vertex = point in space (2D or 3D) + extra information in most cases Polygon = ordered list of vertices Each vertex connected with the next in the list Last is connected with the first Maybe more than one – polygons with holes May contain self-intersections Simple polygon – no holes or self-intersections These are of most interest in CG

Polygons in graphics The main geometric object used for interactive graphics Efficient rendering algorithms exist Polygon scanline rendering Algorithms for making them look good exist Lighting, shading, texture mapping Lowest common denominator for all geometry Can get close to any reasonable shape if enough of them

Drawing modes for polygons Draw lines along polygon edges Use algorithms e.g Bresenham This is called wireframe mode Draw filled polygons – new algorithms Shaded polygons (shading modes) Flat shaded – constant color for whole polygon Gouraud shaded – interpolate vertex colors across the polygon

Polygon interior Want to fill in (color) only pixels inside a polygon What is “inside” of a polygon ? Imagine a ray from the point to infinity Count number of intersections with polygon edges If N is odd, point is inside If N is even, point is outside

Filling Polygons: Terminology Red arrow denotes a particular scan line. Blue disks denote span perimeter or ‘extrema’. Green disks denote other interior pixels in the span.

Filling Polygons: Generalities Avoid drawing pixels more than once. 1. wastes computation 2. may cause unwanted color change if xor graphics context is used. 3. ugly artifacts can occur if two polygons share the same edge (e.g., dependence on drawing order). Exploit coherence: pixels that are nearby each other tend to share common attributes (color, illumination, normal vectors, texture, etc.). Span coherence: Pixels in the same scan line tend to be similar. Scan-line coherence: Pixels in adjacent scan line tend to be similar. Edge coherence: The corresponding span extrema in adjacent span lines tend to be near one another.

Interior Pixel Convention Pixels that lie in the interior of a polygon belong to that polygon, and can be filled. Pixels that lie on a left boundary or a lower boundary of a polygon belong to that polygon, and can be filled. Pixels that have centers that fall outside the polygon, are said to be exterior and should not be drawn. Pixels that lie on a right or an upper boundary do not belong to that polygon, and should not drawn.

Example 1 The boundary of a polygon: (In practice, a polygon is defined as a list of vertices.)

Example 2 Pixels closest to the polygon boundary – derived from Bresenham’s

Example 3 The scan extrema (blue) and interior (green) pixels that would be obtained if the span extrema were defined by the pixels closest to the boundary. Our convention excludes some of these.

Example 4 The scan extrema (blue) and interior (green) pixels that are obtained using our interior pixel convention for the given polygon (purple).

Basic Scan-Fill Algorithm Do the following for every scan line: 1. Compute the intersection of the current scan line with every polygon edge. 2. Sort the intersections in increasing order of the x coordinate. 3. Draw every pixel that lies between each pair of intersections, using a parity bit to designate the interior from the exterior. (Toggle the bit at each intersection.)

Polygon Fill B C Parity 0 = even 1 = odd Parity 1 D A E F

Polygon Fill 2 B C Parity 0 = even 1 = odd F D Parity 1 1 A E

See: Rowe G. Computer Graphics with Java Chapter 1 pages 24 -34 Subtleties 1. The x-coordinates of the intersections are rounded towards the interior of the polygon. 2. If an intersection occurs precisely at an integer, following our convention, it is drawn if a piece of the polygon lies immediately above or to the right. 3. If a scanline intersects the polygon at a vertex, then only one of the intersections is counted in the parity test. To conform with our convention, the vertex is assumed to belong only to the edge that lies above it. (Edges, like spans, are regarded as intervals that are open at their maximum values and closed at their minimum values.) N.B., horizontal edges, and their vertices, are ignored completely. See: Rowe G. Computer Graphics with Java Chapter 1 pages 24 -34