Rasterizing Polygons Lecture 29 Wed, Dec 7, 2005.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Polygon Scan Conversion – 11b
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Polygon Rasterization
College of Computer and Information Science, Northeastern UniversityApril 17, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9.
Convex Hull obstacle start end Convex Hull Convex Hull
Computer Graphics Viewing.
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
6/2/ :35 AMIncremental Convex Hull1 q w u e zt.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Graphics Programming: Polygon Filling
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)
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
Examining the top three rows first Row two requires a 5. It has to be located in the middle 3x3 box. Two possible locations for 5 in centre box The centre.
Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003.
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
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:
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
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.
Scan Conversion. Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines (done last class) – Polygons (fill polygons,
Implementation II.
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.
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.
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.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Rasterization, or “What is glBegin(GL_LINES) really doing?” Course web page: February 23, 2012  Lecture 4.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Computer Graphics Clipping.
Using One Point Perspective to Combine Shapes
Computer Graphics Filling.
Introduction to Polygons
Computer Graphics CC416 Week 13 Clipping.
(c) 2002 University of Wisconsin, CS559
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Fill Area Algorithms Jan
Polygon Filling Algorithms
Graphics Pipeline Clipping
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
Rasterizing Lines 2 Lecture 33 Wed, Nov 14, 2007.
Agenda Polygon Terminology Types of polygons Inside Test
Rasterizing Lines 1 Lecture 32 Mon, Nov 12, 2007.
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
Drawing Walls for a Room
(c) 2002 University of Wisconsin, CS559
Using One Point Perspective to Combine Shapes
Shading Polygons Lecture 36 Wed, Nov 28, 2007.
Rasterizing Polygons 2 Lecture 35 Mon, Nov 26, 2007.
Chapter 3 Graphics Output Primitives
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Where We Stand At this point we know how to: Next thing:
Clipping Polygons Lecture 31 Fri, Nov 9, 2007.
Presentation transcript:

Rasterizing Polygons Lecture 29 Wed, Dec 7, 2005

Rasterizing Polygons Given a the vertices of a polygon, in viewport coordinates, which pixels should be shaded? How do we determine them efficiently?

Rasterizing Polygons

Rasterizing Polygons Obviously, any pixel lying entirely within the polygon should be shaded. What about the pixels that are partially within the polygon? Rule: Shade them if their center is within the polygon. What about the pixels whose center is exactly on the edge?

Edge Pixels

Neighboring Polygons When two polygons share an edge, which one “owns” the pixels on the edge? Rule A polygon owns all pixels whose centers are within its interior. A polygon owns all pixels whose centers lie on one of its left edges.

Neighboring Polygons Fill in all pixels whose centers are within the polygon.

Neighboring Polygons Fill in all pixels whose centers are on a left edge of the polygon.

A Rasterization Algorithm To rasterize a polygon, first determine its bounding box.

A Rasterization Algorithm To rasterize a polygon, first determine its bounding rectangle.

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

A Rasterization Algorithm When an edge is encountered, If we were on the outside, we move to the inside. If we were on the inside, we move to the outside. Thus, we stop or resume shading accordingly.

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 0

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 1

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 2

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 3

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 4

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 5

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 6

A Rasterization Algorithm Then scan each row of pixels in the bounding rectangle, left to right, bottom to top. row 7

A Rasterization Algorithm The following algorithm is designed to allow rapid shading of the pixels. As the vertices are given, create a list of the vertices. (The order matters!) {(1, 0), (4, 3), (6, 1), (12, 1), (11, 8), (7, 8), (6, 5), (4, 8), (0, 7), (1, 0)}. From the list of vertices, form an edge table. {{(1, 0), (4, 3)}, {(4, 3), (6, 1)}, …, {(0, 7), (1, 0)}}.

A Rasterization Algorithm Organization of the edge table. Eliminate any horizontal edges. Sort the edges in the edge table by the y-coordinate of the lower endpoint. Begin scanning with the bottom scan line.

The Active Edge Table Create the active edge table (AET). For each edge in the edge table whose lower endpoint is on the scan line, Create an active-edge-table entry. Add it to the active edge table. Delete the edge from the edge table.

The Active Edge Table Organization of an active-edge-table entry: y-coordinate of upper endpoint. Reciprocal of the slope. x-intercept with the horizontal line ½ unit above the current scan line.

The Active Edge Table Active edges Scan line

The Active Edge Table (7, -1/7, 13/14) Scan line (3, 1, 1-1/2)

The Active Edge Table Sort the AET entries by their x-intercepts. The AET must contain an even number of entries. Why? Shade pixels from the 1st to the 2nd x-intercepts, 3rd to 4th x-intercepts, etc., in the AET.

The Active Edge Table (7, -1/7, 13/14) (no shading on Scan this scan line) Scan line (3, 1, 1-1/2)

The Active Edge Table Update the AET. Increment the scan line number. Delete from the AET any entries for which the upper endpoint is on the scan line. Update the x-intercepts of all AET entries. Add the reciprocal slope to the x-intercept. Create and add entries from the edge table for edges whose lower endpoint is on the scan line.

A Rasterization Algorithm (7, -1/7, 13/14) Scan line (3, 1, 1-1/2)

A Rasterization Algorithm (7, -1/7, 11/14) Scan line (8, -1/7, 11-13/14) (3, 1, 2-1/2) (3, -1, 5-1/2)

A Rasterization Algorithm (7, -1/7, 11/14) Scan line (8, -1/7, 11-13/14) (3, 1, 2-1/2) (3, -1, 5-1/2)

A Rasterization Algorithm (7, -1/7, 9/14) Scan line (8, -1/7, 11-11/14) (3, 1, 3-1/2) (3, -1, 4-1/2)

A Rasterization Algorithm (7, -1/7, 9/14) Scan line (8, -1/7, 11-11/14) (3, 1, 3-1/2) (3, -1, 4-1/2)

A Rasterization Algorithm (7, -1/7, 1/2) Scan line (8, -1/7, 11-9/14)

A Rasterization Algorithm (7, -1/7, 1/2) Scan line (8, -1/7, 11-9/14)

A Rasterization Algorithm (7, -1/7, 5/14) Scan line (8, -1/7, 11-1/2)

A Rasterization Algorithm (7, -1/7, 5/14) Scan line (8, -1/7, 11-1/2)

A Rasterization Algorithm (8, -2/3, 5-5/6) (8, 1/3, 6-1/6) (7, -1/7, 3/14) Scan line (8, -1/7, 11-5/14)

A Rasterization Algorithm (8, -2/3, 5-2/3) (8, 1/3, 6-1/6) (7, -1/7, 3/14) Scan line (8, -1/7, 11-5/14)

A Rasterization Algorithm (8, -2/3, 5) (8, 1/3, 6-1/2) (7, -1/7, 1/14) Scan line (8, -1/7, 11-3/14)

A Rasterization Algorithm (8, -2/3, 5) (8, 1/3, 6-1/2) (7, -1/7, 1/14) Scan line (8, -1/7, 11-3/14)

A Rasterization Algorithm (8, -2/3, 5) (8, 1/3, 6-1/2) (8, 4, 2) Scan line (8, -1/7, 11-3/14)

A Rasterization Algorithm (8, -2/3, 5) (8, 1/3, 6-1/2) (8, 4, 2) Scan line (8, -1/7, 11-3/14)

A Rasterization Algorithm

Rasterizing Polygons Read Run

Rasterizing Polygons in OpenGL Read Run

Freehand Polygons Read Run