Scan Conversion Week 6, Wed 8 Oct 2003

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

Computer Graphics- SCC 342
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Antialiasing Antialiasing.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CP411 polygon Lecture 6 1. Scan conversion algorithm for circle 2. Draw polygons 3. Antialiasing.
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CPCS 391 Computer Graphics 1 Lecture 5: Polygon Filling
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Sampling, Aliasing, & Mipmaps
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Graphics Programming: Polygon Filling
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Scan Conversion Week 6, Mon 6 Oct 2003 recap: Bresenham line algorithm scan.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Scan Conversion Week 6, Fri 10 Oct 2003 sampling.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Polygon Scan Conversion and Z-Buffering
Computer Graphics Panos Trahanias ΗΥ358 Spring 2009.
CS 551 / 645: Introductory Computer Graphics
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
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:
CS 445 / 645 Introduction to Computer Graphics Lecture 8 Triangle Rasterization Lecture 8 Triangle Rasterization.
Rasterization Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
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.
CAP4730: Computational Structures in Computer Graphics
Drawing Triangles CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Introduction to Computer Graphics CS 445 / 645 Lecture 9 Chapter 4: Rasterization L. McMillan MIT notes (Fall ’98)
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.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
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.
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Line Clipping & Line Rasterization.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Rasterization II Week.
Computer Graphics CC416 Week 14 Filling Algorithms.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
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.
Computer Graphics Filling.
Introduction to Polygons
CS G140 Graduate Computer Graphics
Polygons.
University of New Mexico
Implementation III.
Introduction to Computer Graphics with WebGL
Transformations 6 University of British Columbia
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Lecture 13 Clipping & Scan Conversion
Computer Graphics Implementation III
Introduction to Meshes
Rasterization Week 6, Mon Feb 12
Implementation III Ed Angel Professor Emeritus of Computer Science
Introduction to Meshes
Presentation transcript:

Scan Conversion Week 6, Wed 8 Oct 2003 recap: polygon scan conversion interpolation barycentric coords transforming normals sampling

News Homework 1 Project 1 problem 18 problem 4 new correct PDF posted x and y transposed in bottom layer problem 4 rotate 30 deg around x axis with fixed point of (3,5,12,1) new correct PDF posted reminder: no late work after Fri 17 Oct 9am handin box 18 CICSR basement Project 1 solution, hall of fame on Friday Week 6, Wed 8 Oct 03 © Tamara Munzner

News Office hours reminder: FSC 2618 Readings Mondays 10:30-11:30 or by appointment exceptions: Oct 20, Nov 10 Readings Chap 8.9-8.11, Fri 10/3 slide notes Week 6, Wed 8 Oct 03 © Tamara Munzner

Simple Polygon Scanconversion flood fill: simple, slow start with seed point recursively set all neighbors until boundary is hit Week 6, Wed 8 Oct 03 © Tamara Munzner

Scanline Algorithms given vertices, fill in the pixels triangles split into two regions fill in between edges arbitrary polygons (non-simple, non-convex) build edge table for each scanline obtain list of intersections, i.e., AEL use parity test to determine in/out and fill in the pixels Week 6, Wed 8 Oct 03 © Tamara Munzner

Edge Equations define triangle as intersection of three positive half-spaces: A1x + B1y + C1 < 0 A2x + B2y + C2 < 0 A3x + B3y + C3 < 0 A1x + B1y + C1 > 0 A3x + B3y + C3 > 0 A2x + B2y + C2 > 0 Week 6, Wed 8 Oct 03 © Tamara Munzner

Edge Equations So…simply turn on those pixels for which all edge equations evaluate to > 0: + - Week 6, Wed 8 Oct 03 © Tamara Munzner

Edge Equation Consistency how to get same +/- state for all equations? consistent counterclockwise vertex traversal good: [0,1], [1,2], [2,0] or [0,2], [2,1], [1,0] bad: [0,1], [2,1], [2,0] how to ensure interior is positive? explicit area test: if negative, flip all param signs if (area < 0) { A = -A; B = -B; C = -C; } 1 2 Week 6, Wed 8 Oct 03 © Tamara Munzner

Parity for General Case use parity for interior test draw pixel if edgecount odd horizontal lines: count vertical max: count vertical min: don’t count Week 6, Wed 8 Oct 03 © Tamara Munzner

Edge Tables edge table (ET) active edge table (AET) store edges sorted by y in linked list at ymin, store ymax, xmin, slope active edge table (AET) active: currently used for computation store active edges sorted by x update each scanline, store ET values + current_x for each scanline (from bottom to top) do EAT bookkeeping traverse EAT (from leftmost x to rightmost x) draw pixels if parity odd Week 6, Wed 8 Oct 03 © Tamara Munzner

Edge Table Bookkeeping setup: sorting in y bucket sort, one bucket per pixel add: simple check of ET[current_y] delete edges if edge.ymax > current_y main loop: sorting in x for polygons that do not self-intersect, order of edges does not change between two scanlines so insertion sort while adding new edges suffices Week 6, Wed 8 Oct 03 © Tamara Munzner

Interpolation

Scan Conversion done: next: how to determine pixels covered by a primitive next: how to assign pixel colors interpolation of colors across triangles interpolation of other properties Week 6, Wed 8 Oct 03 © Tamara Munzner

Interpolation During Scanconvert interpolate values between vertices z values r,g,b colour components u,v texture coordinates surface normals three equivalent methods (for triangles) bilinear interpolation plane equation barycentric coordinates Week 6, Wed 8 Oct 03 © Tamara Munzner

1. Bilinear Interpolation interpolate quantity along left-hand and right-hand edges, as a function of y then interpolate quantity as a function of x only triangles guarantee orientation-independent interpolation compute efficiently by using known values at previous scanline, previous pixel Week 6, Wed 8 Oct 03 © Tamara Munzner

2. Plane Equation implicit plane equation parametric plane equation z = f(x,y) parametric plane equation a(x-x0)+ b(y-y0)+c(z-z0) = 0 explicit plane equation Week 6, Wed 8 Oct 03 © Tamara Munzner

3. Barycentric Coordinates weighted combination of vertices “convex combination of points” (1,0,0) (0,0,1) (0,1,0) Week 6, Wed 8 Oct 03 © Tamara Munzner

Barycentric Coordinates how to compute ? use bilinear interpolation or plane equations once computed, use to interpolate any # of parameters from their vertex values interpolate just like we did for z etc. Week 6, Wed 8 Oct 03 © Tamara Munzner

Interpolatation: Gouraud Shading need linear function over triangle that yields original vertex colors at vertices use barycentric coordinates for this every pixel in interior gets colors resulting from mixing colors of vertices with weights corresponding to barycentric coordinates color at pixels is affine combination of colors at vertices Week 6, Wed 8 Oct 03 © Tamara Munzner

Interpolatation: Gouraud Shading we know affine combinatons are invariant under affine transformations thus does not matter whether colors are interpolated before or after affine transformations! colors do not shift around on the surface with affine transformations, but stay attached to every surface point Week 6, Wed 8 Oct 03 © Tamara Munzner

Computing Barycentric Coords how do we find barycentric coordinates for every pixel efficiently? look at a point x on a scanline: x3 x2 x4 x x5 a2 : a1 x1 Week 6, Wed 8 Oct 03 © Tamara Munzner

Computing Barycentric Coords similarly: x3 x2 x4 x5 b1 : b2 c1:c2 a2 : a1 x1 Week 6, Wed 8 Oct 03 © Tamara Munzner

Computing Barycentric Coords combining gives Week 6, Wed 8 Oct 03 © Tamara Munzner

Computing Barycentric Coords thus Week 6, Wed 8 Oct 03 © Tamara Munzner

Computing Barycentric Coords can prove correct by verifying barycentric properties  +  +  = 1 0  , ,   1 Week 6, Wed 8 Oct 03 © Tamara Munzner

Gouraud Shading with Bary Coords algorithm modify scanline algorithm for polygon scan-conversion as follows: linearly interpolate colors along edges of triangle to obtain colors for endpoints of span of pixels linearly interpolate colors from these endpoints within the scanline Week 6, Wed 8 Oct 03 © Tamara Munzner

Transforming Normals

Interpolation During Scanconvert interpolate values between vertices z values r,g,b colour components u,v texture coordinates surface normals Week 6, Wed 8 Oct 03 © Tamara Munzner

Computing Normals polygon: assume vertices ordered CCW when viewed from visible side of polygon normal for a vertex used for lighting supplied by model (i.e., sphere), or computed from neighboring polygons Week 6, Wed 8 Oct 03 © Tamara Munzner

Transforming Normals what is a normal? a direction earlier: vector as direction so if points transformed by modelview vector M, can we just transform vector by M too? Week 6, Wed 8 Oct 03 © Tamara Munzner

Transforming Normals translations OK: w=0 means unaffected rotations OK uniform scaling OK these all maintain direction Week 6, Wed 8 Oct 03 © Tamara Munzner

Transforming Normals nonuniform scaling does not work x-y=0 plane line x=y normal: [1,-1,0] ignore normalization for now Week 6, Wed 8 Oct 03 © Tamara Munzner

Transforming Normals apply nonuniform scale: stretch along x by 2 new plane x = 2y transformed normal x = -2y or x+2y=0 not perpendicular! should be 2x = -y Week 6, Wed 8 Oct 03 © Tamara Munzner

Planes and Normals plane is all points such that or (must transpose for matrix mult!) explicit form Week 6, Wed 8 Oct 03 © Tamara Munzner

Finding Correct Normal Transform transform a plane if we know M, what should Q be? stay perpendicular substitute from above thus the normal to any surface has to be transformed by the inverse transpose of the modelling transformation Week 6, Wed 8 Oct 03 © Tamara Munzner

Sampling and Antialiasing

Jaggy Lines rasterized lines were not smooth “stair-stepping”, “jaggies” Week 6, Wed 8 Oct 03 © Tamara Munzner

Smoother Lines solution set 2 points with intensity proportional to distance from line Week 6, Wed 8 Oct 03 © Tamara Munzner

Smoothing Bresenham can modify Bresenham alg to do this for every column of pixels, set the two pixels between which the line intersects the column means that decision variable has to be shifted down one pixel increments for E and NE can be determined as before (but results slightly different) d can directly be used to multiply pixel intensities fully integer implementation possible Week 6, Wed 8 Oct 03 © Tamara Munzner

General Problem “jaggies”: undesirable artifact name for general problem is “aliasing” solving the general problem “antialiasing” theoretical framework sampling, signal processing Week 6, Wed 8 Oct 03 © Tamara Munzner

Samples most things in the real world are continuous everything in a computer is discrete the process of mapping a continuous function to a discrete one is called sampling the process of mapping a discrete function to a continuous one is called reconstruction the process of mapping a continuous variable to a discrete one is called quantization rendering an image requires sampling and quantization displaying an image involves reconstruction Week 6, Wed 8 Oct 03 © Tamara Munzner

What is a pixel? a pixel is more than a point, it is a sample a pixel is not… a box a disk a teeny tiny little light a pixel is a point it has no dimension it occupies no area it cannot be seen it can have a coordinate a pixel is more than a point, it is a sample Week 6, Wed 8 Oct 03 © Tamara Munzner

Pixels point samples pixels have no extent! Week 6, Wed 8 Oct 03 © Tamara Munzner

Pixel Display reconstruction yields continuous function displays constructed to create reconstruction footprints can overlap! (e.g. Gaussians) Week 6, Wed 8 Oct 03 © Tamara Munzner

Pixels square pixel model Just ONE possible reconstruction function and a really bad one – leads to poor quality Week 6, Wed 8 Oct 03 © Tamara Munzner

Samples Week 6, Wed 8 Oct 03 © Tamara Munzner

Samples Week 6, Wed 8 Oct 03 © Tamara Munzner

Line Segments we tried to sample a line segment so it would map to a 2D raster display we quantized the pixel values to 0 or 1 we saw stair steps, or jaggies Week 6, Wed 8 Oct 03 © Tamara Munzner

Line Segments instead, quantize to many shades but what sampling algorithm is used? Week 6, Wed 8 Oct 03 © Tamara Munzner

Area Sampling shade pixels according to the area covered by thickened line this is unweighted area sampling a rough approximation formulated by dividing each pixel into a finer grid of pixels Week 6, Wed 8 Oct 03 © Tamara Munzner

Unweighted Area Sampling primitive cannot affect intensity of pixel if it does not intersect the pixel equal areas cause equal intensity, regardless of distance from pixel center to area Week 6, Wed 8 Oct 03 © Tamara Munzner

Weighted Area Sampling unweighted sampling colors two pixels identically when the primitive cuts the same area through the two pixels intuitively, pixel cut through the center should be more heavily weighted than one cut along corner Week 6, Wed 8 Oct 03 © Tamara Munzner

Weighted Area Sampling weighting function, W(x,y) specifies the contribution of primitive passing through the point (x, y) from pixel center x Intensity W(x,y) Week 6, Wed 8 Oct 03 © Tamara Munzner

Images an image is a 2D function I(x, y) that specifies intensity for each point (x, y) Week 6, Wed 8 Oct 03 © Tamara Munzner

Sampling and Image our goal is to convert the continuous image to a discrete set of samples the graphics system’s display hardware will attempt to reconvert the samples into a continuous image: reconstruction Week 6, Wed 8 Oct 03 © Tamara Munzner

Point Sampling an Image simplest sampling is on a grid sample depends solely on value at grid points Week 6, Wed 8 Oct 03 © Tamara Munzner

Point Sampling multiply sample grid by image intensity to obtain a discrete set of points, or samples. Sampling Geometry Week 6, Wed 8 Oct 03 © Tamara Munzner

Sampling Errors some objects missed entirely, others poorly sampled Week 6, Wed 8 Oct 03 © Tamara Munzner

Fixing Sampling Errors supersampling take more than one sample for each pixel and combine them how many samples is enough? how do we know no features are lost? 150x15 to 100x10 200x20 to 100x10 300x30 to 100x10 400x40 to 100x10 Week 6, Wed 8 Oct 03 © Tamara Munzner