Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
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 , )
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
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.
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)
1 Clipping. 2 Transformation Sequence X Y Z X Y Z X Y Z X Y Z Object Coords. Eye Coords. Clip Coords. Normalized Device Coords. Screen Coords. Implementation:
Clipping Lines Lecture 7 Wed, Sep 10, The Graphics Pipeline From time to time we will discuss the graphics pipeline. The graphics pipeline is the.
Two-Dimensional Viewing Jehee Lee Seoul National University.
Line Clipping Algorithms. A Cases for Clipping Lines E B H C G J I clip rectangle 2Prepared by Narendra V G CSE MIT.
Computer Graphics Viewing.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CGPage: 1 東吳資訊科學 江清水 The process of clipping decides which part, if any, of a primitive lies inside the window. The algorithms used for line clipping can.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes.
Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.
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,
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.
Windowing and clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
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.
Clipping CSCI 440 textbook section Starter Question How do we clip these lines? X=-5 Y=-5 Y=5 X=5 [0,0] [3,3] [7,-3] [0,-3] formula from wikipedia.
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)
Windows, Viewports, and Clipping
Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,
EEL Introduction to Computer Graphics
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.
A.Aruna/Assistant Professor/SNSCE
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
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 Graphics Clipping.
Introduction to Computer Graphics with WebGL
Transformations contd.
Computer Graphics Shading in OpenGL
3D rezanje 3D Clipping view frustrum clipping planes clipped.
Implementation I Ed Angel
Graphics Pipeline Clipping
Computer Graphics : Viewing In 2D
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
Lecture 13 Clipping & Scan Conversion
Joshua Barczak CMSC 435 UMBC
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping Clipping Sutherland-Hodgman Clipping
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
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
Presentation transcript:

Graphics Pipeline Clipping CMSC 435/634

Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms – Vertex components of shading/texture – Clipping – Find the visible parts of any primitives – Rasterization – Break primitives into fragments/pixels – Fragment processing – Fragment components of shading/texture – Visibility & Blending – Which fragments can I see, how do they combine?

Clipping & Culling Cull: decide not to draw an object at all Clip: slice to keep just the visible parts Trivial Reject: Entirely off-screen Trivial Accept: Entirely on screen 3

Clipping Lines Lines intersecting a rectangular clip region are always clipped into a single line segment 4

Clipping Endpoints For a point at (x,y) to be inside the clipping rectangle 5 x min ≤ x ≤ x max, y min ≤ y ≤ y max

Clipping Conditions Both endpoints are inside (AB) One endpoint in, another end outside (CD) Both outside (EF, GH, IJ) – May or may not be in, further calculations needed 6

Cohen-Sutherland Line Clipping – First, endpoint pairs are checked for trivial acceptance – If not, region checks are performed in order to trivially reject certain lines If both x pairs are 1, then it lies outside (EF) If both y pairs are 1, then it too lies outside 7

Cohen-Sutherland Line Clipping Create bit code for each endopint Each region is assigned a 4-bit code (outcode) 1 st bit – above top edge y > y max 2 nd bit – below bottom edge y < y min 3 rd bit – right of right edge x > x max 4 th bit – left of left edge x < x min 8

Efficient Computation of Bit-Code Compute each bit – First bit is the sign bit of y max – y – Second bit is y – y min – Third bit is the sign bit of x max – x – Forth bit is x – x min 9

Bit-Code Trivial Rejects and Accepts If both bit codes are zero – trivial accept If endpoints are both outside of same edge, they will share that bit – This can easily be computed as a logical and operation – trivial reject if non-zero result If not, then need to split line at clip edge, discard portion outside, continue testing 10

Cohen-Sutherland Line Clipping Algorithm 11 code1 = outcode from endpoint1 code2 = outcode from endpoint2 if (code1 == 0 && code2 == 0) then trivial_accept else if (code1 & code2 != 0) then trivial_reject else clip against left clip against right clip against bottom clip against top if (anything is left) then accept clipped segment

Homogeneous Clipping Works for 3D planes If point is inside clipping plane: Point on line: Intersection:

Polygon Clipping Many cases (new edges, discarded edges) – Multiple polygons may result after clipping a single polygon 13

Sutherland-Hodgman Polygon Clipping Divide and conquer Simple problem is to clip polygon against a single infinite clip edge – Sequence of 4 clips against clipping rectangle 14

Sutherland-Hodgman Polygon Clipping Algorithm moves around the polygon from v n to v 1 and then on back to v n At each step – Check (v i to v i+1 ) line against the clip edge – Add zero, one, or two vertices to the output 15

Sutherland-Hodgman Polygon Clipping At each step, 1 of 4 possible cases arises – 1) Edge is completely inside clip boundary, so add vertex p to the output list – 2) Intersection i is output as vertex because it intersects with boundary – 3) Both vertices are outside boundary, so neither is output – 4) Intersection i and vertex p both added to output list 16

Sutherland-Hodgman Algorithm 17 Sutherland-Hodgman(array)‏ vertex S = array[ length(array) - 1 ] for ( j = 0 ; j < length(array) ; j++ ) do vertex P = array[ j ] if ( P is inside clip plane ) then if ( S is inside clip plane ) then /* case 1 */ Output( P ) else/* case 2 */ Output( ComputeIntersection( S, P, clip plane ) )‏ Output( P )‏ else if ( S is inside clip plane ) then/* case 2 */ Output( ComputeIntersection( P, S, clip plane ) )‏ else/* case 3 */ no op S = P