Display Technologies: CRTs Raster Displays

Similar documents
Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk

From Ver(ces to Fragments: Rasteriza(on

Chapter 8: Implementation- Clipping and Rasterization

Scan Conversion. Drawing Lines Drawing Circles

Rasterization: Geometric Primitives

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

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

COMP371 COMPUTER GRAPHICS

Raster Scan Displays. Framebuffer (Black and White)

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

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

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

Line Drawing. Foundations of Computer Graphics Torsten Möller

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

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

CS Rasterization. Junqiao Zhao 赵君峤

Chapter - 2: Geometry and Line Generations

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

Overview of Computer Graphics

Rendering. A simple X program to illustrate rendering

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

EF432. Introduction to spagetti and meatballs

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

1 Introduction to Graphics

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

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

A New Line Drawing Algorithm Based on Sample Rate Conversion

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

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

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Topic #1: Rasterization (Scan Conversion)

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

Scan Converting Lines

Rendering. A simple X program to illustrate rendering

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Line Drawing Week 6, Lecture 9

Computer Graphics D Graphics Algorithms

UNIT -8 IMPLEMENTATION

Painter s HSR Algorithm

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CPSC / Scan Conversion

Computer Graphics: Line Drawing Algorithms

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CS 543: Computer Graphics. Rasterization

Computer Graphics. - Rasterization - Philipp Slusallek

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

Rasterization. COMP 575/770 Spring 2013

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

An Improved Algorithm for Scan-converting a Line

Graphics (Output) Primitives. Chapters 3 & 4

Visibility: Z Buffering

Computer Graphics and GPGPU Programming

KRISTU JYOTI COLLEGE OF MANAGEMENT & TECHNOLOGY QUESTION BANK BCA SEMESTER III Computer graphics Part A (2 marks questions)

Einführung in Visual Computing

UNIT 2 GRAPHIC PRIMITIVES

From 3D World to 2D Screen. Hendrik Speleers

Computer Graphics Lecture Notes

Raster Displays and Scan Conversion. Computer Graphics, CSCD18 Fall 2008 Instructor: Leonid Sigal

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Computer Graphics. Chapter 1 (Related to Introduction to Computer Graphics Using Java 2D and 3D)

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

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

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

CS 450: COMPUTER GRAPHICS RASTERIZING LINES SPRING 2016 DR. MICHAEL J. REALE

RASTERIZING POLYGONS IN IMAGE SPACE

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

(Refer Slide Time: 00:03:51)

(Refer Slide Time: 9:36)

Realtime 3D Computer Graphics Virtual Reality

Pipeline implementation II

OUTPUT PRIMITIVES. CEng 477 Introduction to Computer Graphics METU, 2007

CS6504 & Computer Graphics Unit I Page 1

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

Computer Graphics Lecture 5

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking

CS 130. Scan Conversion. Raster Graphics

Computer Graphics 7 - Rasterisation

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

E.Order of Operations

The Traditional Graphics Pipeline

CS 4300 Computer Graphics. Prof. Harriet Fell Fall 2012 Lecture 5 September 13, 2012

Graphics Hardware and Display Devices

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

Points and lines. x x 1 + y 1. y = mx + b

Implementation III. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Introduction to Bresenham s Line Algorithm Using. Instruction Series Graphics Note 5

Computer Graphics Solved MCQs -Part 2 MCQs Questions

Pipeline and Rasterization. COMP770 Fall 2011

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Transcription:

Rasterization

Display Technologies: CRTs Raster Displays Raster: A rectangular array of points or dots Pixel: One dot or picture element of the raster Scanline: A row of pixels Rasterize: find the set of pixels corresponding to a 2D shape (line, circle, polygon)

Display Technologies: CRTs Raster Displays Frame must be refreshed to draw new images As new pixels are struck by electron beam, others are decaying Electron beam must hit all pixels frequently to eliminate flicker Critical fusion frequency Typically 60 times/sec Varies with intensity, individuals, phosphor persistence, lighting...

Display Technologies: CRTs Raster CRT pros: Allows solids, not just wireframes Leverages low-cost CRT technology (i.e., TVs) Bright! Display emits light Cons: Requires screen-size memory array Discrete sampling (pixels) Practical limit on size (call it 40 inches) Bulky Finicky (convergence, warp, etc)

Framebuffers So far we ve talked about the physical display device How does the interface between the device and the computer s notion of an image look? Framebuffer: A memory array in which the computer stores an image On most computers, separate memory bank from main memory (why?) Many different variations, motivated by cost of memory

Rasterization Rasterization is the process by which a primitive is converted to a two-dimensional image Each point of this image contains such information as color and depth Rasterizing a primitive consists of two parts. 1. Determine which squares of an integer grid in window coordinates are occupied by the primitive 2. Assigning a color and a depth value to each such square Slide based on OpenGL documentation

Rasterization The results of this process are passed on to the next stage of the GL pipeline, which uses the information to update the appropriate locations in the framebuffer

Line-Drawing Algorithms Our first adventure into Rasterization aka scan conversion Due to the scanning nature of raster displays Algorithms are fundamental to both 2-D and 3-D computer graphics Transforming the continuous into this discrete (sampling) Most incremental line-drawing algorithms were first developed for pen-plotters

Line-Drawing Algorithms Most of the early scan-conversion algorithms developed for plotters can be attributed to one man, Jack Bresenham.

Quest for the Ideal Line The best we can do is a discrete approximation of an ideal line. Important line qualities Continuous appearance Uniform thickness and brightness Turn on the pixels nearest the ideal line How fast is the line generated

Simple Line Based on the simple slope-intercept algorithm from algebra ( y = m x + b ) public void linesimple(int x0, int y0, int x1, int y1, Color color) { int pix = color.getrgb(); int dx = x1 - x0; int dy = y1 - y0; } raster.setpixel(pix, x0, y0); if (dx!= 0) { float m = (float) dy / (float) dx; float b = y0 - m*x0; dx = (x1 > x0)? 1 : -1; while (x0!= x1) { x0 += dx; y0 = Math.round(m*x0 + b); raster.setpixel(pix, x0, y0); } }

linesimple() Demo The Demo http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide05.html Does it work?? Try various slopes? What happens for slopes greater than 1? This algorithm works well when the desired line's slope is less than 1, but the lines become more and more discontinuous as the slope increases beyond one Since this algorithm iterates over values of x between x 0 and x 1 there is a pixel drawn in each column Slope is greater than 1 = Often more than one pixel drawn in each column for the line to appear continuous

Lets Improve linesimple() Problem: linesimple() does not give satisfactory results for slopes > 1 Solution: Symmetry

lineimproved() Demo http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide07.html

Optimize Inner Loops Optimize those code fragments where the algorithm spends most of its time Often these fragments are inside loops Overall code organization

Optimizations Remove unnecessary method invocations Use incremental calculations

Modified Algorithm This line drawing algorithm is called a Digital Differential Analyzer or DDA for short

linedda() Demo http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide10.html You should not see any difference in the lines generated by this method and the lineimproved( ) method mentioned previously The main difference should only be speed When optimizing, it is important to verify at each step that the algorithm remains intact

Benchmarking http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide11.html Many modern optimizing compilers will automatically find the sorts of optimizations that we applied here (inlining function calls within loops and converting functions to incremental calculation). Raises the question: Is it better to retain readable code, and depend a compiler to do the optimization implicitly, or code the optimization explicitly with some loss in readability? The answer is not clear cut. In general, you should make your code as readable as possible.

Optimizing On the other hand, you should also seldom trade-off portability for elegance. Thus, if your application depends on a fast algorithm, you are better off coding directly rather than depending on a compiler to do your work Compiler versions and platforms change more frequently than your code!

Low-level optimizations Low-level optimizations are dubious, because they depend on specific machine details. However, a set of general rules that are more-or-less consistent across machines include: Addition and Subtraction are generally faster than Multiplication. Multiplication is generally faster than Division. Using tables to evaluate discrete functions is faster than computing them Integer calculations are faster than floating-point calculations. Avoid unnecessary computation by testing for various special cases. The intrinsic tests available to most machines are greater than, less than, greater than or equal, and less than or equal to zero (not an arbitrary value).

Applications of Low-level Optimizations Notice that the slope is always rational (a ratio of 2 integers) Note that the incremental part of the algorithm never generates a new y that is more than one unit away from the old one (slope is always less than one)

Applications of Low-level Optimizations If we maintained only the fraction part of y we could still draw a line by noting when this fraction exceeded one. If we initialize the fraction with 0.5, then we will also handle the rounding correctly as in our DDA routine

More Low-level Optimizations

More Low-level Optimizations

Bresenham s Algorithm

linebresenham() Demonstration http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide17.html Does it work? Was it worth all the trouble? Lets check Benchmarking Applet: http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide18.html

Question Infrastructure There is still a hidden multiply inside of our inner loop Our next optimization of Bresenham s algorithm eliminates even this multiply

Faster Bresenham Algorithm

Benchmarking How fast is Fast Bresenham Algorithm? http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide21.html

Life After Bresenham Most books would have you believe that the development of line drawing algorithms ended with Bresenham's famous algorithm. But there has been some significant work since then. The following 2-step algorithm, developed by Xiaolin Wu, is a good example. The interesting story of this algorithm's development is discussed in an article that appears in Graphics Gems I by Brian Wyvill.

The Two-Step algorithm The two-step algorithm takes the interesting approach of treating line drawing as a automaton, or finite state machine. If one looks at the possible configurations that the next two pixels of a line, it is easy to see that only a finite set of possibilities exist. The two-step algorithm also exploits the symmetry of line-drawing by simultaneously drawn from both ends towards the midpoint. Code snippet http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide22.html

Benchmarking Was the 2-step algorithm faster? http://graphics.csail.mit.edu/classes/6.837/f98/lecture5/slide23.html

Many more important issues Outstanding issues Non-integer endpoints (occurs frequently with 3D lines) Can we make the lines appear less jaggy? (Antialiasing coming soon) What if a line endpoint lies outside the viewing area? How do you handle thick lines? Optimizations for connected line segments

Circle Drawing Algorithm Come up with an algorithm to draw a circle? 2/2/2 Refer to the provided midpoint circle algorithm What about filling the circle with a particular color? Flood fill algorithm

Trivia Graphics Gems series of books This series focuses on short to medium length pieces of code which perform a wide variety of computer graphics related tasks. http://www.acm.org/pubs/tog/graphicsgems/