Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
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.
+ CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Lecture 3.
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.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Polygon Rasterization
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Graphics Programming: Polygon Filling
Scan Conversion II Revision 1.4 2/13/07 Copyright 2006, Dr. Zachary Wartell, UNCC, All Rights Reserved.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
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)
TOPIC 4 PART III FILL AREA PRIMITIVES POLYGON FILL AREAS CGMB214: Introduction to Computer Graphics.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Polygon Scan Conversion and Z-Buffering
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
Graphics Primitives: line. Pixel Position
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.
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.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
Lecture 15: Raster Graphics and Scan Conversion
Scan Conversion.
Lecture 13: Raster Graphics and Scan Conversion
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
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 Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
Rasterization, or “What is glBegin(GL_LINES) really doing?” Course web page: February 23, 2012  Lecture 4.
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.
Computer Graphics Filling.
Introduction to Polygons
(c) 2002 University of Wisconsin, CS559
Basic Raster Graphics Algorithms for Drawing 2D Primitives
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
University of New Mexico
Implementation III.
Zhen Jiang West Chester University
Introduction to Computer Graphics with WebGL
© University of Wisconsin, CS559 Fall 2004
Agenda Polygon Terminology Types of polygons Inside Test
Rasterization and Antialiasing
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
Computer Graphics Implementation III
Rasterization and Antialiasing
Edited from The Rasterization Problem: Idealized Primitives Map to Discrete Display Space Edited from.
Rasterizing Polygons Lecture 29 Wed, Dec 7, 2005.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Where We Stand At this point we know how to: Next thing:
Implementation III Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Rasterization Overview Raster Display Device

Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in raster graphics to represent primitives in vector graphics).

Scan Converting Lines The Basic Incremental Algorithm A line scan-converting algorithm computes the coordinates of the pixels that lie on or near an ideal, infinitely thin straight line imposed on a 2D grid. (Selects pixels on the line to light up.) P a (x a,y a ) P b (x b,y b )

We need to compute x a, x a+1, x a+2, …, x b y a, y a+1, y a+2, …, y b dy=y b -y a ; dx=x b -x a ; m = dy /dx; for i = a, a+1, …, b. X i,

To increase efficiency, we consider y i = y a + m*(x i – x a ) and x i+1 = x i + 1 y i+1 = y a + m*(x i+1 - x a ) = y a + m*(x i +1- x a ) = y a + m*(x i – x a ) + m = y i + m …. Since pixels are at integer locations, we need round up if m is not an integer:

p i (x i, round(y i )), i=a, a+1, a+2, …,b. desired line (x i +1,Round(y i +m)) (x i +1, y i +m) (x i, y i ) (x i, Round(y i ))

DDA (digital differential analyzer): void Line(int x a, int y a, int x b, int y b, int color) { int x; float dy, dx, y, m; dy=y b -y a ; dx=x b -x a ; m=dy/dx; y=y a ; for(x=x a ; x<=x b ; x++) { // light the pixel near (x,y) with the color setPixelColor(x, (int)(y+0.5), color); y += m; }

This code is only good for |m|<=1. Swap x and y when calling the function with |m|>1, and a flag is needed for displaying the swapped case. Drawbacks: accumulating error, FP operation.

Fill Rectangles -> Area Fill  Choosing pixels inside the area  setPixelColor(x, y, color) We may need to compute color based on x, y if the filling is not a single color. A simple rectangle single color filling algorithm: int x, y for (y=y min ; y<=y max ; y++)/* for each scan line */ for (x=x min ; x<=x max ; x++) /* for each pixel */ setPixelColor(x, y, color);

Rules for shared edges =>A shared vertical edge belongs to the rightmost of the two sharing shapes =>A shared non-vertical edge belongs to the upper shape. =>Therefore only draw the pixels on the left and bottom edges. Revised code for rectangle single color filling: int x, y for (y=y min ; y<y max ; y++) for (x=x min ; x<x max ; x++) SetPixelColor(x, y, color);

Fill Polygons (Polygon Scan-Conversion) Parity: number of times a scan line has intersected the polygon. Initially it is 0 (even). Extrema: the intersection points of the scan line with the polygon. Span: a segment of a scan line between two consecutive extrema that is also within the polygon.

The Odd-Parity Rule =>For each intersection encountered, inverts the parity. =>Draw when the parity is odd. =>Don’t draw when it is even. The span-filling algorithm for filling a polygon on a scan-line: ->Find the intersections of the scan line with all edges of the polygon (extrema for the spans) ->Sort the intersections by increasing x coordinate ->Fill in all pixels between pairs of intersections that lie interior to the polygon (span), using the odd-parity rule to determine a point is inside the polygon or not. Polygon Filling Rule: draw only pixels that lie interior or on a left or bottom edge.

Four elaboration on handling intersection points: =>Fraction intersection x values: Round down x coordinate if the parity is even (when this intersection is counted); round up x coordinates if the parity is odd (when this intersection is counted). Count the pixel that are exactly inside. =>Integer intersection x values: Left (odd) in. Right (even) out. =>Shared vertices: Count y min, don’t count y max. =>Horizontal edges: Draw the bottom ones. Ignore horizontal edges when computing intersection points. Fraction extrema Odd upEven down Integer Extrema Left (odd) in Right (even) out Shared vertices y min iny max out Horizontal edges Bottom (y min ) in Top (y max ) out

PSC (Polygon Scan Conversion): determine the pixels and set them to the specified color. =>Algorithm:  Find the first and the last scan line that intersect with the polygon. first: y=y min : (min y value of the polygon) last: y=y max : (max y value of the polygon)  For each scan line between [y min, y max ], fill the spans (span-filling) : Three stages of span filling: -> Find (the extrema by intersecting the scan line with the polygon). -> Sort (the extrema by x) -> Fill (the pixels using the odd-parity rule).

Slivers: relax the filling rule, count nearby pixels Texture Filling

Pattern Filling setPixelColor(x,y,pattern[x%M,y%N]);

Clipping in a Raster World Clipping cuts the outside parts out before displaying Clipping a point. Point P(x, y) if ((x>=x min && x =y min && y<=y max )) setPixelColor(x, y, color);

Clipping filled polygons =>Clip while scan-convert. =>Clip extrema in pairs:. Keep the pair if both extrema are inside.. Remove the pair if both extrema are outside and on the same side.. Move the outside extreme point to the edge if one extreme point is out and the other is in.