Pipeline implementation II

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

Topics. From vertices to fragments

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Rasterization, Depth Sorting and Culling

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

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

Realtime 3D Computer Graphics Virtual Reality

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

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

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

COMP371 COMPUTER GRAPHICS

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

Rasterization: Geometric Primitives

From Ver(ces to Fragments: Rasteriza(on

CS Rasterization. Junqiao Zhao 赵君峤

Scan Conversion. Drawing Lines Drawing Circles

Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Einführung in Visual Computing

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

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

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

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

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

CS 543: Computer Graphics. Rasterization

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

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

Clipping and Scan Conversion

Graphics (Output) Primitives. Chapters 3 & 4

Topic #1: Rasterization (Scan Conversion)

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

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

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

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

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

Agenda. Polygon Terminology Types of polygons Inside Test Polygon Filling Algorithms. Scan-Line Polygon Fill Algorithm Flood-Fill Algorithm

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

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

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

Rasterization. CS4620 Lecture 13

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

UNIT -8 IMPLEMENTATION

Line Drawing. Foundations of Computer Graphics Torsten Möller

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

Pipeline and Rasterization. COMP770 Fall 2011

The Traditional Graphics Pipeline

1 Introduction to Graphics

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

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

The Traditional Graphics Pipeline

Computer Graphics. - Rasterization - Philipp Slusallek

The Traditional Graphics Pipeline

CS4620/5620: Lecture 14 Pipeline

Rasterization. COMP 575/770 Spring 2013

Line Drawing Week 6, Lecture 9

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

Chapter - 2: Geometry and Line Generations

Institutionen för systemteknik

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

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

UNIT 2 GRAPHIC PRIMITIVES

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

Scan Converting Lines

CHAPTER 1 Graphics Systems and Models 3

Overview of Computer Graphics

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

CS 325 Computer Graphics

Rendering the Teapot 1

CSE Real Time Rendering Week 10

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

Computer Graphics Lecture Notes

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Rasteriza2on and Clipping

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

Computer Graphics D Graphics Algorithms

RASTERIZING POLYGONS IN IMAGE SPACE

Chapter 8: Implementation- Clipping and Rasterization

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

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

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

Rasterizing triangles

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

Lecture 2 October 31, 2005

Painter s HSR Algorithm

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

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

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Computer Graphics D Graphics Algorithms

Lecture 2 March 24, 2004

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

Computer Graphics and GPGPU Programming

Graphics Output Primitives

Scan Conversion- Polygons

EF432. Introduction to spagetti and meatballs

Spring 2009 Prof. Hyesoon Kim

SE Mock Online Test 1-CG

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

Unit 2 Output Primitives and their Attributes

Shading Techniques Denbigh Starkey

Transcription:

Pipeline implementation II

Overview Line Drawing Algorithms DDA Bresenham Filling polygons Antialiasing

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

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 m = Δ x y = mx + h

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 = Δy/Δx = y 2 -y 1 /x 2 -x 1 Along scan line Δx = 1 For(x=x1; x<=x2,ix++) { y+=m; write_pixel(x, round(y), line_color) }

Problem DDA = for each x plot pixel at closest y Problems for steep lines

Using Symmetry Use for 1 m 0 For m > 1, swap role of x and y For each y, plot closest x

Problem Floating point operations are expensive Compared to integer operations Floating point accuracy Error can accumulate

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

Candidate Pixels 1 m 0 candidates last pixel Note that line could have passed through any part of this pixel

Decision Variable d = Δx(a-b) d is an integer d < 0 use upper pixel d > 0 use lower pixel -

Incremental Form More efficient if we look at d k, the value of the decision variable at x = k d k+1 = d k 2Δy, if d k > 0 d k+1 = d k 2(Δy- Δx), otherwise For each x, we need do only an integer addition and a test Single instruction on graphics chips

Polygon Scan Conversion Scan Conversion = Fill How to tell inside from outside Convex easy Nonsimple difficult Odd even test Count edge crossings Winding number odd-even fill

Winding Number Count clockwise encirclements of point winding number = 1 winding number = 2 Alternate definition of inside: inside if winding number 0

Filling in the Frame Buffer Fill at end of pipeline Convex Polygons only Nonconvex polygons assumed to have been tessellated Shades (colors) have been computed for vertices (Gouraud shading) Combine with z-buffer algorithm March across scan lines interpolating shades Incremental work small

Using Interpolation C 1 C 2 C 3 specified by glcolor or by vertex shading C 4 determined by interpolating between C 1 and C 2 C 5 determined by interpolating between C 2 and C 3 interpolate between C 4 and C 5 along span C 1 scan line C 4 C 2 C 5 span C 3

Flood Fill Fill can be done recursively if we know a seed point located inside (WHITE) Scan convert edges into buffer in edge/inside color (BLACK) flood_fill(int x, int y) { if(read_pixel(x,y)= = WHITE) { write_pixel(x,y,black); flood_fill(x-1, y); flood_fill(x+1, y); flood_fill(x, y+1); flood_fill(x, y-1); } }

Scan Line Fill Can also fill by maintaining a data structure of all intersections of polygons with scan lines Sort by scan line Fill each span vertex order generated by vertex list desired order

Data Structure

Aliasing Ideal rasterized line should be 1 pixel wide Choosing best y for each x (or visa versa) produces aliased raster lines

Antialiasing by Area Averaging Color multiple pixels for each x depending on coverage by ideal line original antialiased magnified

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

Next time Example exam questions and answers See the old exams online on the course page Does not completely reflect the exam this year