CS 551 / 645: Introductory Computer Graphics

Slides:



Advertisements
Similar presentations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Clipping Concepts, Algorithms for line clipping 1 of 16 Clipping - 10/16/12.
Advertisements

Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
CS 445 / 645 Introduction to Computer Graphics Lecture 9 Clipping Clipping.
David Breen, William Regli and Maxim Peysakhov
Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)
Computer Graphics Viewing.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
March 1, 2009Dr. Muhammed Al-Mulhem1 ICS 415 Computer Graphics Clipping Dr. Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem March 1, 2009.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping Week 8, Wed Mar.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping II, Hidden Surfaces.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
UBI 516 Advanced Computer Graphics Two Dimensional Viewing ( Chapter 6 ) Aydın Öztürk Two Dimensional.
2-Dimension Viewing and Clipping
Clipping Apart from clipping to the view volume, clipping is a basic operation in many other algorithms –Breaking space up into chunks –2D drawing and.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
1 Computer Graphics Clipping Fall FCC Line Clipping What happens when one or both endpoints of a line segment are not inside the specified drawing.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Clipping.
Introduction to Computer Graphics with WebGL
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
3D rezanje 3D Clipping view frustrum clipping planes clipped.
Concepts, algorithms for clipping
Implementation I Ed Angel
Graphics Pipeline Clipping
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
© University of Wisconsin, CS559 Fall 2004
(c) 2002 University of Wisconsin, CS559
3D rezanje 3D Clipping view frustrum clipping planes clipped.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping Polygons Dr. Scott Schaefer.
Clipping Clipping Sutherland-Hodgman Clipping
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
COMPUTER GRAPHICS Clipping
Presentation transcript:

CS 551 / 645: Introductory Computer Graphics Clipping II: Clipping Polygons David Luebke 6/26/2018

Administrivia Assignment 2 due David Luebke 6/26/2018

Recap: Clipping Lines Discard segments of lines outside viewport Trivially accept lines with both endpoints inside all edges of the viewport Trivially reject lines with both endpoints outside the same edge of the viewport Otherwise, reduce to trivial cases by splitting into two segments David Luebke 6/26/2018

Recap: Cohen-Sutherland Line Clipping Divide viewplane into regions defined by viewport edges Assign each region a 4-bit outcode: 1001 1000 1010 0001 0000 0010 0101 0100 0110 David Luebke 6/26/2018

Recap: Cohen-Sutherland Line Clipping Set bits with simple tests x > xmax y < ymin etc. Assign an outcode to each vertex of line If both outcodes = 0, trivial accept bitwise AND vertex outcodes together If result  0, trivial reject David Luebke 6/26/2018

Recap: Cohen-Sutherland Line Clipping If line cannot be trivially accepted or rejected, subdivide so that one or both segments can be discarded Pick an edge that the line crosses Intersect line with edge Discard portion on wrong side of edge and assign outcode to new vertex Apply trivial accept/reject tests and repeat if necessary David Luebke 6/26/2018

Cohen-Sutherland Line Clipping Outcode tests and line-edge intersects are quite fast (how fast?) But some lines require multiple iterations (see F&vD figure 3.40) Fundamentally more efficient algorithms: Cyrus-Beck uses parametric lines Liang-Barsky optimizes this for upright volumes F&vD for more details David Luebke 6/26/2018

Clipping Polygons Clipping polygons is more complex than clipping the individual lines Input: polygon Output: polygon, or nothing When can we trivially accept/reject a polygon as opposed to the line segments that make up the polygon? David Luebke 6/26/2018

How many sides can a clipped triangle have? Why Is Clipping Hard? What happens to a triangle during clipping? Possible outcomes: triangletriangle trianglequad triangle5-gon How many sides can a clipped triangle have? David Luebke 6/26/2018

Why Is Clipping Hard? A really tough case: David Luebke 6/26/2018

Why Is Clipping Hard? A really tough case: concave polygonmultiple polygons David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped David Luebke 6/26/2018

Sutherland-Hodgman Clipping: The Algorithm Basic idea: Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all planes, the polygon is fully clipped Will this work for non-rectangular clip regions? What would 3-D clipping involve? David Luebke 6/26/2018

Sutherland-Hodgman Clipping Input/output for algorithm: Input: list of polygon vertices in order Output: list of clipped poygon vertices consisting of old vertices (maybe) and new vertices (maybe) Note: this is exactly what we expect from the clipping operation against each edge David Luebke 6/26/2018

Sutherland-Hodgman Clipping Sutherland-Hodgman basic routine: Go around polygon one vertex at a time Current vertex has position p Previous vertex had position s, and it has been added to the output if appropriate David Luebke 6/26/2018

Sutherland-Hodgman Clipping Edge from s to p takes one of four cases: (Purple line can be a line or a plane) inside outside s p p output inside outside s p i output inside outside s p no output inside outside s p i output p output David Luebke 6/26/2018

Sutherland-Hodgman Clipping Four cases: s inside plane and p inside plane Add p to output Note: s has already been added s inside plane and p outside plane Find intersection point i Add i to output s outside plane and p outside plane Add nothing s outside plane and p inside plane Add i to output, followed by p David Luebke 6/26/2018

Point-to-Plane test A very general test to determine if a point p is “inside” a plane P, defined by q and n: (p - q) • n < 0: p inside P (p - q) • n = 0: p on P (p - q) • n > 0: p outside P P n p q q q n n p p P P David Luebke 6/26/2018

Point-to-Plane Test Dot product is relatively expensive 3 multiplies 5 additions 1 comparison (to 0, in this case) Think about how you might optimize or special-case this David Luebke 6/26/2018

Finding Line-Plane Intersections Use parametric definition of edge: E(t) = s + t(p - s) If t = 0 then E(t) = s If t = 1 then E(t) = p Otherwise, E(t) is part way from s to p David Luebke 6/26/2018

Finding Line-Plane Intersections Edge intersects plane P where E(t) is on P q is a point on P n is normal to P (E(t) - q) • n = 0 t = [(q - s) • n] / [(p - s) • n] The intersection point i = E(t) for this value of t David Luebke 6/26/2018

Line-Plane Intersections Note that the length of n doesn’t affect result: t = [(q - s) • n] / [(p - s) • n] Again, lots of opportunity for optimization David Luebke 6/26/2018