CAP4730: Computational Structures in Computer Graphics

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

Computer Graphics Lecture 3 Modeling and Structures.
Computer Graphics- SCC 342
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.
David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Course Website: Computer Graphics 4: Viewing In 2D.
Computer Graphics Viewing.
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
Polygons – Sum of the Angles The sum of the interior angles of a convex polygon depends on the number of sides of the polygon. The formula is developed.
Classes of Polygons Planar polygons Non-planar polygons Simple
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Scan Conversion Week 6, Mon 6 Oct 2003 recap: Bresenham line algorithm scan.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Adv. Computer Graphics CS6500, Spring 2003.
Rasterization May 14, Triangles Only We will discuss the rasterization of triangles only. Why? –Polygon can be decomposed into triangles. –A triangle.
Status – Week 280 Victor Moya. Rasterization Setup triangles. Setup triangles. Fill triangle: Interpolate parameters. Fill triangle: Interpolate parameters.
Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
The Art Gallery Problem
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Polygon Scan Conversion and Z-Buffering
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
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.
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.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
Drawing Triangles CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Computer Graphics I, Fall 2010 Implementation II.
Lecture 15: Raster Graphics and Scan Conversion
Introduction to Meshes Lecture 22 Mon, Oct 20, 2003.
2 3D Viewing Process  3D viewing process MC Model Space Model Transformation Model Transformation WC World Space Viewing Transformation Viewing Transformation.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Polygon Triangulation
Computer Graphics I, Fall 2010 Scan conversion algorithms.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Computer Graphics Clipping.
Computer Graphics Filling.
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
University of New Mexico
Implementation III.
Polygon Filling Algorithms
Query Processing in Databases Dr. M. Gavrilova
Introduction to Computer Graphics with WebGL
Craig Schroeder October 26, 2004
Lecture 13 Clipping & Scan Conversion
Computer Graphics Implementation III
Introduction to Meshes
Shading Polygons Lecture 36 Wed, Nov 28, 2007.
Implementation III Ed Angel Professor Emeritus of Computer Science
Introduction to Meshes
Lecture 22 Complexity and Reductions
Presentation transcript:

CAP4730: Computational Structures in Computer Graphics Triangle Scan Conversion

Triangle Area Filling Algorithms Why do we care about triangles? Edge Equations Edge Walking

We want something easier It is easier to do 1 thing VERY fast than 2 things pretty fast. Why? Think about how you code. Scan conversion Polygon Circle Clipping

Do something easier! Instead of polygons, let’s do something easy! TRIANGLES! Why? 1) All polygons can be broken into triangles 2) Easy to specify 3) Always convex 4) Going to 3D is MUCH easier

Polygons can be broken down Triangulate - Dividing a polygon into triangles. Is it always possible? Why?

Any object can be broken down into polygons

Specifying a model For polygons, we had to worry about connectivity AND vertices. How would you specify a triangle? (What is the minimum you need to draw one?) Only vertices (x1,y1) (x2,y2) (x3,y3) No ambiguity Line equations A1x1+B1y1+C1=0 A2x2+B2y2+C2=0 A3x3+B3y3+C3=0

Triangles are always convex What is a convex shape? An object is convex if and only if any line segment connecting two points on its boundary is contained entirely within the object or one of its boundaries. Think about scan lines again!

Scan Converting a Triangle Recap what we are trying to do Two main ways to rasterize a triangle Edge Equations A1x1+B1y1+C1=0 A2x2+B2y2+C2=0 A3x3+B3y3+C3=0 Edge Walking

Types of Triangles What determines the spans? Can you think of an easy way to compute spans? What is the special vertex here?

Edge Walking 1. Sort vertices in y and then x 2. Determine the middle vertex 3. Walk down edges from P0 4. Compute spans P0 P1 P2

Edge Walking Pros and Cons Fast Easy to implement in hardware Cons Special Cases Interpolation can be tricky

Color Interpolating P0 (?, ?, ?) P1 P2 (?, ?, ?)

Edge Equations x1, y1 - x2, y2 to P0 A1x1+B1y1+C1=0 A2x2+B2y2+C2=0 How do you go from: x1, y1 - x2, y2 to A1x1+B1y1+C1? P1 P2

Given 2 points, compute A,B,C C = x0y1 – x1y0 A = y0 – y1 B = x1 – x0

Edge Equations P0 What does the edge equation mean? A1x1+B1y1+C1=0 Pt1[2,1], Pt2[6,11] A=-10, B=4, C=16 What is the value of the equation for the: gray part yellow part the boundary line What happens when we reverse P0 and P1? P1

Positive Interior We add the C element from each edge area = edge0.C + edge1.C + edge2.C if (area>0) then inside points are in the positive half spaces if (area<0) then what should we do? What happens if area=0?

Combining all edge equations 1) Determine edge equations for all three edges 2) Find out if we should reverse the edges 3) Create a bounding box 4) Test all pixels in the bounding box whether they too reside on the same side P0 P1 P2

Edge Equations: Interpolating Color Given colors (and later, other parameters) at the vertices, how to interpolate across? Idea: triangles are planar in any space: This is the “redness” parameter space Note:plane follows form z = Ax + By + C Look familiar? Taken w/ permission from: David Luebke, UVA http://www.cs.virginia.edu/~gfx/Courses/2003/Intro.spring.03/lecture17.ppt

Edge Equations: Interpolating Color Given redness at the 3 vertices, set up the linear system of equations: The solution works out to:

Edge Equations: Interpolating Color Notice that the columns in the matrix are exactly the coefficients of the edge equations! So the setup cost per parameter is basically a matrix multiply Per-pixel cost (the inner loop) cost equates to tracking another edge equation value (which is?) A: 1 add

Pros and Cons of Edge Equations If you have the right hardware (PixelPlanes) then it is very fast Fast tests Easy to interpolate colors Cons Can be expensive if you don’t have hardware 50% efficient

Recap P0 P0 P1 P1 P2 P2