Rasterization and Antialiasing

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
Advertisements

CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
From Vertices to Fragments
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
Scan Conversion A. Samal. Scan Conversion Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines – Polygons – Circles.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
+ 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.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Raster conversion algorithms for line and circle
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007.
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 50 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 45 Computer Graphics Implementation I.
University of Missouri at Columbia 2D Scan-line Conversion University of Missouri at Columbia.
College of Computer and Information Science, Northeastern UniversitySeptember 12, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
Dr. S.M. Malaek Assistant: M. Younesi
Graphics Primitives: line. Pixel Position
WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition.
Scan Conversion Line and Circle
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 7: From Vertices to Fragments Ed Angel Professor of Computer Science, Electrical.
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.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Objectives Introduce basic implementation strategies Clipping Scan conversion.
From Vertices to Fragments Chapter 7. Part I Objectives Introduce basic implementation strategies Introduce basic implementation strategies Clipping Clipping.
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.
Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Graphics Output Primitives
Line Drawing and Generalization. Outline  overview  line drawing  circle drawing  curve drawing.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Week 3 Lecture 1: Implementation Based on Interactive Computer Graphics (Angel) - Chapter.
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
In the name of God Computer Graphics. Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon.
Scan Conversion.
Lecture 13: Raster Graphics and Scan Conversion
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Rasterization CENG 477 Introduction to Computer Graphics Slides from Steve Marschner, CS4620, 2008 Cornell University.
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.
Primitive graphic objects
Scan Conversion or Rasterization
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
University of New Mexico
Implementation III.
Computer Graphics Implementation I.
Prof. Harriet Fell Spring 2007 Lecture 5 – January 17, 2006
Chapter Three Part I Output Primitives CS 380.
Introduction to Computer Graphics with WebGL
2D Scan-line Conversion
Course code: 10CS65 | Computer Graphics and Visualization
Rasterization and Antialiasing
Computer Graphics Implementation III
Edited from The Rasterization Problem: Idealized Primitives Map to Discrete Display Space Edited from.
Chapter 3 Graphics Output Primitives
From Vertices To Fragments
Implementation III Ed Angel Professor Emeritus of Computer Science
From Vertex to Fragment
From Vertex to Fragment
Presentation transcript:

Rasterization and Antialiasing Angel 7.8-7.9 & 7.12 Angel: Interactive Computer Graphics5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Objectives Survey Line Drawing Algorithms DDA Bresenham Antialiasing Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) Determine which pixels that are inside primitive specified by a set of vertices Produces a set of fragments Fragments have a location (pixel location) and other attributes such color and texture coordinates that are determined by interpolating values at vertices Pixel colors determined later using color, texture, and other vertex properties Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Scan Conversion of Line Segments Start with line segment in window coordinates with integer values for endpoints Assume implementation has a write_pixel function y = mx + h Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 DDA Algorithm Digital Differential Analyzer DDA was a mechanical device for numerical solution of differential equations Line y=mx+ h satisfies differential equation dy/dx = m = Dy/Dx = y2-y1/x2-x1 Along scan line Dx = 1 for(x=x1; x<=x2;x++) { y+=m; write_pixel(x, round(y), line_color) } Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Problem DDA = for each x plot pixel at closest y Problems for steep lines Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Using Symmetry Use for 1  m  0 For m > 1, swap role of x and y For each y, plot closest x Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Bresenham’s Algorithm DDA requires one floating point addition per step We can eliminate all fp through Bresenham’s algorithm Consider only 1  m  0 Other cases by symmetry Assume pixel centers are at half integers If we start at a pixel that has been written, there are only two candidates for the next pixel to be written into the frame buffer Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Candidate Pixels 1  m  0 candidates last pixel - Note that line could have passed through any part of this pixel Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Decision Variable d = Dx(b-a) d is an integer d > 0 use upper pixel d < 0 use lower pixel when Dx=1, d=b-a - Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Incremental Form More efficient if we look at dk, the value of the decision variable at x = k + ½ dk+1= dk +2Dy, if dk < 0 dk+1= dk +2(Dy-Dx), otherwise For each x, we need do only an integer addition and a test – a single instruction on graphics chips - - - - Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Aliasing Ideal rasterized line should be 1 pixel wide Choosing best y for each x (or visa versa) produces aliased raster lines Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Antialiasing by Area Averaging Color multiple pixels for each x depending on coverage by ideal line antialiased original magnified Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Polygon Aliasing Aliasing problems can be serious for polygons Jaggedness of edges Small polygons neglected Need compositing so color of one polygon does not totally determine color of pixel All three polygons should contribute to color Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009