Two-Dimensional Viewing. Chapter 6

Similar documents
Computer Graphics. The Two-Dimensional Viewing. Somsak Walairacht, Computer Engineering, KMITL

CSCI 4620/8626. Computer Graphics Clipping Algorithms (Chapter 8-5 )

2D Viewing. Viewing Pipeline: Window-Viewport Transf.

From Vertices To Fragments-1

3D Rendering Pipeline (for direct illumination)

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17

Part IV. 2D Clipping

Examples. Clipping. The Rendering Pipeline. View Frustum. Normalization. How it is done. Types of operations. Removing what is not seen on the screen

Computer Graphics: Two Dimensional Viewing

Unit 3 Transformations and Clipping

Clipping and Scan Conversion

Clipping Lines. Dr. Scott Schaefer

Chapter 8: Implementation- Clipping and Rasterization

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

CS452/552; EE465/505. Clipping & Scan Conversion

Viewing Transformation. Clipping. 2-D Viewing Transformation

Clipping and Intersection

Part 3: 2D Transformation

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Windowing And Clipping (14 Marks)

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

MODULE - 9. Subject: Computer Science. Module: Line Clipping. Module No: CS/CGV/9

CS602 MCQ,s for midterm paper with reference solved by Shahid

Clipping Points Consider a clip window which is rectangular in shape. P(x, y) is a point to be displayed.

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

SE Mock Online Test 1-CG

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Topics. From vertices to fragments

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

Clipping Algorithms; 8-5. Computer Graphics. Spring CS4815

Lecture 7 of 41. Viewing 4 of 4: Culling and Clipping Lab 1b: Flash Intro

Realtime 3D Computer Graphics Virtual Reality

Illumination Models III: Ray Tracing (View Dependent Global Illumination)

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

Computer Science 474 Spring 2010 Viewing Transformation

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Computer Graphics Viewing Objective

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

CS 450: COMPUTER GRAPHICS REVIEW: CLIPPING SPRING 2015 DR. MICHAEL J. REALE

(Refer Slide Time: 00:02:02)

COMPUTATIONAL GEOMETRY

Chapter 3. Sukhwinder Singh

Computer Graphics (CS 543) Lecture 10 (Part 1): 3D Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

8. Hidden Surface Elimination

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

COMP3421. Vector geometry, Clipping

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Sung-Eui Yoon ( 윤성의 )

Points and lines, Line drawing algorithms. Circle generating algorithms, Midpoint circle Parallel version of these algorithms

Set the Viewport. Set the Viewport Clipping. Set the Viewport. Set the Viewport. Set the Viewport. Resizing the Viewport W = H

Practical Linear Algebra: A Geometry Toolbox

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

CS2401 COMPUTER GRAPHICS ANNA UNIV QUESTION BANK

15. Clipping. Projection Transformation. Projection Matrix. Perspective Division

window World space (Object space)

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Computer Graphics Geometry and Transform

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Binghamton University. EngiNet. Thomas J. Watson. School of Engineering and Applied Science. Computer Graphics. State University of New York.

CHAPTER 1 Graphics Systems and Models 3

Two Dimensional Viewing

Hidden Surfaces II. Week 9, Mon Mar 15

Werner Purgathofer

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

RASTERIZING POLYGONS IN IMAGE SPACE

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Einführung in Visual Computing

Graphics (Output) Primitives. Chapters 3 & 4

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

Z- Buffer Store the depth for each pixel on the screen and compare stored value with depth of new pixel being drawn.

Lecture outline. COMP30019 Graphics and Interaction Rendering pipeline & object modelling. Introduction to modelling

Roll No. : Invigilator's Signature :.. GRAPHICS AND MULTIMEDIA. Time Allotted : 3 Hours Full Marks : 70

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

SRI VENKATESWARA COLLEGE OF ENGINEERING. COURSE DELIVERY PLAN - THEORY Page 1 of 6

The Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

CS602- Computer Graphics Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring 2013 CS602- Computer Graphics

SAZ4C COMPUTER GRAPHICS. Unit : 1-5. SAZ4C Computer Graphics

Graphics and Interaction Rendering pipeline & object modelling

Chapter - 2: Geometry and Line Generations

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Motivation. Culling Don t draw what you can t see! What can t we see? Low-level Culling

521493S Computer Graphics Exercise 1 (Chapters 1-3)

CSCI 4620/8626. Coordinate Reference Frames

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

UNIT 2 2D TRANSFORMATIONS

CS 591B Lecture 9: The OpenGL Rendering Pipeline

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

From 3D World to 2D Screen. Hendrik Speleers

Computer Graphics. - Rasterization - Philipp Slusallek

Math 414 Lecture 2 Everyone have a laptop?

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

8. Hidden Surface Elimination

Transcription:

Two-Dimensional Viewing Chapter 6

Viewing Pipeline

Two-Dimensional Viewing Two dimensional viewing transformation From world coordinate scene description to device (screen) coordinates

Normalization and Viewport Transformation World coordinate clipping window Normalization square: usually [-1,1]x[-1,1] Device coordinate viewport

Normalization and Viewport Normalization and Viewport Normalization and Viewport Normalization and Viewport Transformation Transformation + 2 i min max i xw xw xw xw xw xw + = 1 2 min max min max min max min max min max, yw yw yw yw yw yw xw xw xw xw M normsquare window 1 + 2 2 min max min max xv xv xv xv + = 1 2 2 min max min max, yv yv yv yv M viewport normsquare

Clipping Remove portions of a picture outside viewport or screen boundaries Two approaches: Clip during scan conversion: per-pixel bounds check, or span endpoint tests. Clip analytically, then scan-convert the modified primitive.

Two-Dimensional Clipping Point clipping trivial xw yw min min x y xw yw max max Line clipping (straight-line segments) Cohen-Sutherland Cyrus-Beck Liang-Barsky Fill-area clipping (polygons) Sutherland-Hodgeman Weiler-Atherton Ah Curve clipping Text clipping i

Line Clipping Basic calculations Is an endpoint inside or outside the clip rectangle? Find the point of intersection, if any, between a line segment and an edge of the clip rectangle. Both endpoints inside trivial accept One inside find intersection ti and clip Both outside either x = y = x y + u( x + u( y end end x y ) ) u 1 clip or reject

Cohen-Sutherland Line-Clipping Algorithm 11 1 11 1 View port 1 11 1 11 < Region code for each endpoint > Bit 4 3 2 1 above below right left

Cohen-Sutherland Line-Clipping Algorithm Trivially accepted if ( rc1 rc2 == ) // completely inside Trivially rejected if ( rc1 rc2 ) // completely outside Otherwise, divide line into two segments test intersection edges in a fixed order. (e.g., in the order of left, right, bottom, top)

Cohen-Sutherland Line-Clipping Algorithm y = x = y x + m ( x ) x ( y y + m ) m = ( y end y ) /( x end x ) Fixed order testing ti and clipping i cause needless clipping (external intersections)

Cohen-Sutherland Line-Clipping Algorithm When this is good If it can trivially reject or accept most cases Works well if a window is large w.r.t. data Works well if a window is small w.r.t. data i.e., it works well in extreme cases

Parametric Line Clipping (Cyrus-Beck Technique) Use a parametric line equation P ( t) = P + t( P1 P ), t 1 Reduce the number of calculating intersections by simple comparisons of parameter t.

Parametric Line Clipping (Cyrus-Beck Technique) Algorithm For each edge E i of the clip region N i : outward normal of E i

Parametric Line Clipping (Cyrus-Beck Technique) Choose an arbitrary point PE i on edge Ei and consider three vectors P( t) N N N i ( P( t) ) < i P E i ( E i a P E i point in the outside halfplane ( P( t) ) = an intersection point ( P ( t ) ) > a point in the inside halfplane i P E i P E

Parametric Line Clipping (Cyrus-Beck Technique) Solve for the value of t at the intersection of P P 1 with the edge: N i [P(t)-P Ei ]=. P(t) = P + t(p 1 - P ) and let D = (P 1 - P ), Then N i, t = N i [ P P N i D D (h (that is P P 1 ), N i D (if not, no intersection) Ei ] (edge and line are parallel )

Parametric Line Clipping (Cyrus-Beck Technique) Given the four values of t for a line segment, determine which pair of t's s are internal intersections. If t [,1] then discard else choose a (PE, PL) pair that defines the clipped line.

Parametric Line Clipping (Cyrus-Beck Technique) PE(potentially entering) intersection if moving from P to P 1 causes us to cross an edge to enter the edge's inside half plane PL(potentially ti leaving) intersection: ti if moving from P to P 1 causes us to leave the edge's inside half plane. N i N i P P 1 < P P > 1 PE PL Intersections can be categorized! Inside the clip rectangle (t E, t L ) t E : select PE with largest t value t L : select PL with the smallest t value 1.

Parametric Line Clipping (Cyrus-Beck Technique) This is an efficient algorithm when many line segments need to be clipped Can be extended easily to convex polygon windows

Liang-Barsky line clipping The ideas for clipping line of Liang-Barsky and Cyrus-Beck are the same. The only difference is Liang-Barsky algorithm has been optimized for an upright rectangular clip window. Finds the appropriate end points with more efficient computations.

Liang-Barsky line clipping Let PQ be the line which we want to study Q(x2,y2) Parametric equation of t R the line segment P(x1,y1) t B t L t T x= x + ( x x ) t = x + dx t 1 2 1 1 y = y + ( y y ) t = y + dy t t 1 2 1 1 = P( x, y ) 1 1 t = 1 Q ( x, y ) 2 2

Liang-Barsky Line Clipping 1. Set t min = and t max = 1 2. Calculate the values of t T, t B, t L, t R, L R t T T t B B

Liang-Barsky Line Clipping If t < t min or t > t max, ignore it and go to the next edge. Otherwise classify the t value as entering or exiting value (using the inner product to classify) Let PQ be the line and N is normal vector If N ( Q P), the parameter t is entering If N ( Q P ) >, the parameter t is exiting(leaving) If t is entering value, set t min = t If t is exiting value set t max =t N t R t T

Liang-Barsky Line Clipping 3. If t min < t max then draw a line from ( x + dx t, y + dy t ) 1 min 1 min to ( x + dx t, y + dy t ) 1 max 1 max Q(x2,y2) t R t T P(x1,y1) t L t B

Clipping Line clipping using nonrectangular polygon clip windows extend Cyrus-Beck algorithm (parametric clipping procedure) Line clipping using nonlinear clipping-window boundary Circles or other curved-boundary clipping regions More processing for non-linear intersection calculations

Polygon Fill-Area Clipping To clip a polygon fill area, can not directly apply a line-clipping method Line-clipping methods would not produce a closed polyline We need one or more closed polylines

Polygon Fill-Area Clipping Process a polygon fill area against successive clipping-window clip against 4 infinite clip edges in succession

Sutherland-Hodgeman Algorithm An efficient method for clipping a convex-polygon fill area Accept a series of vertices (polygon) and outputs a list of vertices Send a pair of endpoints for each successive polygon line segment through the series of clippers Left, right, bottom, and top clippers As soon as a clipper completes the processing of one vertex pair, the clipped coordinate values, if any, are sent to the next clipper.

Sutherland-Hodgeman Algorithm Four possible cases

Sutherland-Hodgeman Algorithm

Sutherland-Hodgeman Algorithm When applied to a concave polygon, it may display extraneous lines.

Sutherland-Hodgeman Algorithm How to correctly clip a concave polygon [Way I] Split the concave polygon into two or more convex polygons and process each convex polygon separately. [Way II] Modify the algorithm to check the final vertex list for multiple vertex points along any clip window boundary and correctly join pairs of vertices. [Way III] Use a more general polygon clipper

Splitting Concave Polygons Split the concave polygon into two or more convex polygons and process each convex polygon separately. vector method for splitting concave polygons Calculate edge-vector cross products in a counterclockwise order. If any z component turns out to be negative, the polygon is concave.

Weiler-Atherton Polygon Clipping For an inside-to-outside pair of vertices, follow the window boundary in a counterclockwise direction. For an outside-to-inside pair of vertices, follow the polygon boundary.

Weiler-Atherton Polygon Clipping 1. Process the polygon edges in a counterclockwise order until an inside-outside pair of vertices is encountered for one of clipping boundaries 2. Follow the window boundaries in a counterclockwise order from the exit-intersection pt. to another intersection point. If this is a previously processed pt., proceed to the next step If this is a new intersection pt., follow the polygon edges until a previously processed vertex is encountered 3. Form the vertex list 4. Return to the exit-intersection pt. and dfollow the polygon edges

Weiler-Atherton Polygon Clipping Polygon clipping using nonrectangular polygon clip windows

Texture Clipping 1. all-or-none text clipping : Using boundary box for the entire text 2. all-or-none character clipping : Using boundary box for each individual 3. clip individual id characters vector : clip line segments bitmap : clip individual pixels