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

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

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

COMP371 COMPUTER GRAPHICS

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

Clipping and Scan Conversion

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

Pipeline implementation II

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

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

Scan Conversion. Drawing Lines Drawing Circles

Topics. From vertices to fragments

CS452/552; EE465/505. Clipping & Scan Conversion

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

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

Einführung in Visual Computing

CS 543: Computer Graphics. Rasterization

The Traditional Graphics Pipeline

From Ver(ces to Fragments: Rasteriza(on

Computer Graphics. - Rasterization - Philipp Slusallek

Realtime 3D Computer Graphics Virtual Reality

Line Drawing. Foundations of Computer Graphics Torsten Möller

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

Computer Graphics Geometry and Transform

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

Topic #1: Rasterization (Scan Conversion)

Rasterization: Geometric Primitives

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

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

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

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

CS Rasterization. Junqiao Zhao 赵君峤

CS 4731/543: Computer Graphics Lecture 7 (Part I): Raster Graphics: Polygons & Antialiasing. Emmanuel Agu

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

EF432. Introduction to spagetti and meatballs

Display Technologies: CRTs Raster Displays

Graphics (Output) Primitives. Chapters 3 & 4

CHAPTER 1 Graphics Systems and Models 3

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

Incremental Form. Idea. More efficient if we look at d k, the value of the decision variable at x = k

Computer Graphics 7 - Rasterisation

Computer Graphics, Lecture 2 October 31, Department of Information Technology. - Scientific Computing. Department of Information Technology

? Which intermediate. Recall: Line drawing algorithm. Programmer specifies (x,y) of end pixels Need algorithm to determine pixels on line path

Lecture 2 October 31, 2005

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

Computer Graphics Geometry and Transform

CS488 2D Graphics. Luc RENAMBOT

EF432. Introduction to spagetti and meatballs

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

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

COMP3421. Particle Systems, Rasterisation

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

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

RASTERIZING POLYGONS IN IMAGE SPACE

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

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics?

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

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

1 Introduction to Graphics

Input Nodes. Surface Input. Surface Input Nodal Motion Nodal Displacement Instance Generator Light Flocking

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

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Scan Converting Lines

Computer Graphics CS 543 Lecture 11 (Part 1) Polygon Filling & Antialiasing

Rasterization, Depth Sorting and Culling

Chapter 8: Implementation- Clipping and Rasterization

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

Real-Time Graphics Architecture

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

Chapter - 2: Geometry and Line Generations

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

Direct Rendering of Trimmed NURBS Surfaces

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

UNIT -8 IMPLEMENTATION

Lecture 2 March 24, 2004

Attributes of Graphics Primitives

Computer Graphics. Rasterization. Teacher: A.prof. Chengying Gao( 高成英 ) School of Data and Computer Science

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Pipeline Operations. CS 4620 Lecture 10

Rendering. A simple X program to illustrate rendering

28 SAMPLING. ALIASING AND ANTI-ALIASING

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

Computer Graphics. Lecture 8 Antialiasing, Texture Mapping

Painter s HSR Algorithm

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

CS 428: Fall Introduction to. Polygon rendering: additional topics. Andrew Nealen, Rutgers, /14/2009 1

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

From Vertices To Fragments-1

Rendering. A simple X program to illustrate rendering

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

CS 130 Final. Fall 2015

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

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Institutionen för systemteknik

Overview of Computer Graphics

Real-Time Reyes Programmable Pipelines and Research Challenges

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

Transcription:

Fall 2015 CSCI 420: Computer Graphics 7.1 Rasterization Hao Li http://cs420.hao-li.com 1

Rendering Pipeline 2

Outline Scan Conversion for Lines Scan Conversion for Polygons Antialiasing 3

Rasterization (scan conversion) Final step in pipeline: rasterization From screen coordinates (float) to pixels (int) Writing pixels into frame buffer Separate buffers: - depth (z-buffer), - display (frame buffer), - shadows (stencil buffer), - blending (accumulation buffer) 4

Rasterizing a line 5

Digital Differential Analyzer (DDA) Represent line as Then, if pixel, we have y = m x = m x =1 6

Digital Differential Analyzer Assume write_pixel(int x, int y, int value) for (i = x1; i <= x2; i++) { y += m; write_pixel(i, round(y), color); } Problems: - Requires floating point addition - Missing pixels with steep slopes: slope restriction needed 7

Digital Differential Analyzer (DDA) Assume 0 m 1 Exploit symmetry But still requires floating point additions! Distinguish special cases 8

Bresenham s Algorithm I Eliminate floating point addition from DDA Assume again 0 m 1 Assume pixel centers halfway between integers 9

Bresenham s Algorithm II Decision variable a b - If a b>0 choose lower pixel - If a b apple 0 choose higher pixel Goal: avoid explicit computation of a b Step 1: re-scale d =(x 2 x 1 )(a b) = x(a b) d is always integer 10

Bresenham s Algorithm III Compute d at step from d at step k +1 k! Case: j did not change - decreases by, increases by - decreases by - decreases by (d k > 0) a m b m y (a b) 2m = 2( x ) x(a b) 2 y 11

Bresenham s Algorithm IV Case: j did change (d k apple 0) - decreases by, increases by y - (a b) decreases by 2m 2 = 2( x a m 1 b m 1 - decreases by x(a b) 2( y x) 1) 12

Bresenham s Algorithm V So d k+1 = d k 2 y d k > 0 if And d k+1 = d k 2( y x) d k apple 0 if Final (efficient) implementation: void draw_line(int x1, int y1, int x2, int y2) { int x, y = y1; int dx = 2*(x2-x1), dy = 2*(y2-y1); int dydx = dy-dx, D = (dy-dx)/2; } for (x = x1 ; x <= x2 ; x++) { write_pixel(x, y, color); if (D > 0) D -= dy; else {y++; D -= dydx;} } 13

Bresenham s Algorithm VI Need different cases to handle m > 1 Highly efficient Easy to implement in hardware and software Widely used 14

Outline Scan Conversion for Lines Scan Conversion for Polygons Antialiasing 15

Scan Conversion of Polygons Multiple tasks: - Filling polygon (inside/outside) - Pixel shading (color interpolation) - Blending (accumulation, not just writing) - Depth values (z-buffer hidden-surface removal) - Texture coordinate interpolation (texture mapping) Hardware efficiency is critical Many algorithms for filling (inside/outside) Much fewer that handle all tasks well 16

Filling Convex Polygons Find top and bottom vertices List edges along left and right sides For each scan line from bottom to top - Find left and right endpoints of span, xl and xr - Fill pixels between xl and xr - Can use Bresenham s algorithm to update xl and xr xl xr 17

Concave Polygons: Odd-Even Test Approach 1: odd-even test For each scan line - Find all scan line/polygon intersections - Sort them left to right - Fill the interior spans between intersections Parity rule: inside after an odd number of crossings 18

Edge vs Scan Line Intersections Brute force: calculate intersections explicitly Incremental method (Bresenham s algorithm) Caching intersection information - Edge table with edges sorted by ymin - Active edges, sorted by x-intersection, left to right Process image from smallest ymin up 19

Concave Polygons: Tessellation Approach 2: divide non-convex, non-flat, or non-simple polygons into triangles OpenGL specification - Need accept only simple, flat, convex polygons - Tessellate explicitly with tessellator objects - Implicitly if you are lucky Most modern GPUs scan-convert only triangles 20

Flood Fill Draw outline of polygon Pick color seed Color surrounding pixels and recurse Must be able to test boundary and duplication More appropriate for drawing than rendering 21

Outline Scan Conversion for Lines Scan Conversion for Polygons Antialiasing 22

Aliasing 23

Aliasing 24

Aliasing Artifacts created during scan conversion Inevitable (going from continuous to discrete) Aliasing (name from digital signal processing): we sample a continues image at grid points Effect - Jagged edges - Moire patterns Moire pattern from sandlotscience.com 25

More Aliasing 26

Antialiasing for Line Segments Use area averaging at boundary (c) is aliased, magnified (d) is antialiased, magnified 27

Antialiasing by Supersampling Mostly for off-line rendering (e.g., ray tracing) Render, say, 3x3 grid of mini-pixels Average results using a filter Can be done adaptively - Stop if colors are similar - Subdivide at discontinuities one pixel 28

Supersampling Example Other improvements - Stochastic sampling: avoid sample position repetitions - Stratified sampling (jittering) : perturb a regular grid of samples 29

Temporal Aliasing Sampling rate is frame rate (30 Hz for video) Example: spokes of wagon wheel in movies Solution: supersample in time and average - Fast-moving objects are blurred - Happens automatically with real hardware (photo and video cameras) Exposure time is important (shutter speed) - Effect is called motion blur Motion blur 30

Wagon Wheel Effect 31

Motion Blur Example Achieve by stochastic sampling in time T. Porter, Pixar, 1984 16 samples / pixel / timestep 32

Summary Scan Conversion for Polygons - Basic scan line algorithm - Convex vs concave - Odd-even rules, tessellation Antialiasing (spatial and temporal) - Area averaging - Supersampling - Stochastic sampling 33

http://cs420.hao-li.com Thanks! 34