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.

Slides:



Advertisements
Similar presentations
Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
Advertisements

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 , )
Objectives Define Clipping Various clipping methods. Line clipping methods.
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.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
3/2/04© University of Wisconsin, CS559 Spring 2004 Last Time General Perspective –Methods for specifying the view volume As a set of clip planes As a field.
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)
Course Website: Computer Graphics 4: Viewing In 2D.
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:
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.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
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 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
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.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
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,
Now Playing: California Stars Billy Bragg & Wilco from Mermaid Avenue
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
2-Dimension Viewing and Clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
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:
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
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.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Windows, Viewports, and Clipping
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)
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
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.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
2D Viewing.
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.
Two-Dimensional Viewing Hearn & Baker Chapter 6
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Concepts, Algorithms for line clipping
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Concepts, algorithms for clipping
Graphics Pipeline Clipping
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Last Time 2D and 3D Transformations
© University of Wisconsin, CS559 Fall 2004
(c) 2002 University of Wisconsin, CS559
Clipping Clipping Sutherland-Hodgman Clipping
Clipping University of British Columbia CPSC 314 Computer Graphics
COMPUTER GRAPHICS Clipping
Presentation transcript:

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 –Modelling May require more complex geometry than rectangular boxes

Hardware Sutherland-Hodgman Suitable for hardware implementation –Only need the clip edge, the endpoints of the current edge, and the last output point –Polygon edges are output as they are found, and passed right on to the next clip region edge Clip Top Vertices in Clip Right Clip Bottom Clip Left Clipped vertices out

Inside-Outside Testing Edges/Planes store a vector pointing toward the outside of the clip region Dot products give inside/outside information OutsideInside n s f i x s-x

Inside/Outside in Screen Space In screen space, clip planes are x s =±1, y s =±1, z s =0, z s =1 Inside/Outside reduces to comparisons before perspective divide

Finding Intersection Pts Watt Sect 1.4.3, Use the parametric form for the line between two points, x 1 and x 2 : For planes of the form x=a: Similar forms for y=a, z=a Solution for general plane in textbook

Additional Clipping Planes Useful for doing things like cut-away views –Use a clip plane to cut off part of the object –Only works if piece to be left behind is convex OpenGL allows you to do it Also one way to use OpenGL to identify objects in a region of space (uses the selection mechanism)

Clipping Lines Lines can also be clipped by Sutherland-Hodgman –Slow, unless you already have hardware Better algorithms exist –Cohen-Sutherland –Liang-Barsky –Nicholl-Lee-Nicholl

Cohen-Sutherland (1) Works basically the same as Sutherland-Hodgman –Was developed earlier Clip line against each edge of clip region in turn –If both endpoints outside, discard line and stop –If both endpoints in, continue to next edge (or finish) –If one in, one out, chop line at crossing pt and continue

Cohen-Sutherland (2)

Cohen-Sutherland (3) Some cases lead to premature acceptance or rejection –If both endpoints are inside all edges –If both endpoints are outside one edge

Cohen-Sutherland - Details Only need to clip line against edges where one endpoint is out Use outcode to record endpoint in/out wrt each edge. One bit per edge, 1 if out, 0 if in. Trivial reject: –outcode(x 1 )&outcode(x 2 )!=0 Trivial accept: –outcode(x 1 )|outcode(x 2 )==0 Which edges to clip against? –outcode(x 1 )^outcode(x 2 )

Liang-Barsky Clipping Parametric clipping - view line in parametric form and reason about the parameter values More efficient, as not computing the coordinate values at irrelevant vertices Clipping conditions on parameter: Line is inside clip region for values of t such that:

Liang-Barsky (2) Infinite line intersects clip region edges when: where

Liang-Barsky (3) When p k <0, as t increases line goes from outside to inside - enter When p k >0, line goes from inside to outside - leave When p k =0, line is parallel to an edge (clipping is easy) If there is a segment of the line inside the clip region, sequence of infinite line intersections must go: enter, enter, leave, leave

Liang-Barsky (4) Enter Leave Enter Leave Enter Leave

Liang-Barsky - Algorithm Compute entering t values, which are q k /p k for each p k <0 Compute leaving t values, which are q k /p k for each p k >0 Parameter value for small t end of line is:t small = max(0, entering t’s) parameter value for large t end of line is: t large =min(1, leaving t’s) if t small <t large, there is a line segment - compute endpoints by substituting t values Improvement (and actual Liang-Barsky): –compute t’s for each edge in turn (some rejects occur earlier like this.)

Nicholl-Lee-Nicholl clipping Some edges are irrelevant to clipping, particularly if one vertex lies inside region. Cases: –x 1 in –x 1 in corner region –x 1 in edge region For each case, we generate specialized test regions for x 2, which use simple tests (slope, >, <), and tell which edges to clip against.

Nicholl-Lee-Nicholl (2) Special cases for each endpoint location and slope Number of cases explodes in 3D, making it unsuitable Reject Top Top, Right Top, Bottom Left Left, bottom

Weiler Atherton Polygon Clipping For clockwise polygon: –for out-to-in pair, follow usual rule –for in-to-out pair, follow clip edge Easiest to start outside

General Clipping Clipping general against general polygons is quite hard Outline of Weiler algorithm: –Replace crossing points with vertices –Double all edges and form linked lists of edges –Change links at vertices –Enumerate polygon patches Can use clipping to break concave polygon into convex pieces; main issue is inside-outside for edges

Weiler Algorithm (1)

Changes to Rearranging pointers makes it possible to enumerate all components of the intersection