3D Rendering Pipeline (for direct illumination)

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

From Vertices To Fragments-1

Clipping and Scan Conversion

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

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

Realtime 3D Computer Graphics Virtual Reality

Two-Dimensional Viewing. Chapter 6

Topics. From vertices to fragments

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

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

Clipping Lines. Dr. Scott Schaefer

CS 591B Lecture 9: The OpenGL Rendering Pipeline

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

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

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

Computer Graphics Viewing Objective

Chapter 8: Implementation- Clipping and Rasterization

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

Computer Graphics Geometry and Transform

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

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

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

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

Part IV. 2D Clipping

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

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

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

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

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

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

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

Introduction to Computer Graphics 5. Clipping

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

Windowing And Clipping (14 Marks)

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

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

Clipping and Intersection

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

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

Computer Graphics Geometry and Transform

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

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

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

CS488 2D Graphics. Luc RENAMBOT

The Traditional Graphics Pipeline

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

From 3D World to 2D Screen. Hendrik Speleers

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

Sung-Eui Yoon ( 윤성의 )

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

The Traditional Graphics Pipeline

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

Rasterization, Depth Sorting and Culling

Unit 3 Transformations and Clipping

The Traditional Graphics Pipeline

Hidden Surfaces II. Week 9, Mon Mar 15

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

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

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

Computer Graphics: Two Dimensional Viewing

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

CSE328 Fundamentals of Computer Graphics

CS2401 COMPUTER GRAPHICS ANNA UNIV QUESTION BANK

Werner Purgathofer

Computer Graphics: 7-Polygon Rasterization, Clipping

CHAPTER 1 Graphics Systems and Models 3

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

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

Einführung in Visual Computing

Viewing Transformation. Clipping. 2-D Viewing Transformation

CS452/552; EE465/505. Geometry Transformations

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

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

Geometry. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

SE Mock Online Test 1-CG

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

Computer Science 474 Spring 2010 Viewing Transformation

(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.

Last week. Machiraju/Zhang/Möller

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

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

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

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

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

Visible Surface Detection Methods

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

OXFORD ENGINEERING COLLEGE (NAAC Accredited with B Grade) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS

The University of Calgary

CS475m - Computer Graphics. Lecture 1 : Rasterization Basics


QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

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

Graphics and Interaction Rendering pipeline & object modelling

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

Course Title: Computer Graphics Course no: CSC209

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

Direct Rendering of Trimmed NURBS Surfaces

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Transcription:

Clipping

3D Rendering Pipeline (for direct illumination) 3D Primitives 3D Modeling Coordinates Modeling Transformation Lighting 3D Camera Coordinates Projection Transformation Clipping 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion Image 3D World Coordinates 3D World Coordinates Viewing Transformation 2D Screen Coordinates 2D Image Coordinates

3D Rendering Pipeline (for direct illumination) 3D Primitives 3D Modeling Coordinates Modeling Transformation Lighting 3D Camera Coordinates Projection Transformation Clipping 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion Image 3D World Coordinates 3D World Coordinates Viewing Transformation 2D Screen Coordinates 2D Image Coordinates

2D Rendering Pipeline 3D Primitives 2D Primitives Clipping Viewport Transformation Scan Conversion Clip portions of geometric primitives residing outside the window Transform the clipped primitives from screen to image coordinates Fill pixels representing primitives in screen coordinates Image

2D Rendering Pipeline 3D Primitives 2D Primitives Clipping Viewport Transformation Scan Conversion Clip portions of geometric primitives residing outside the window Transform the clipped primitives from screen to image coordinates Fill pixels representing primitives in screen coordinates Image

Clipping Avoid drawing parts of primitives outside window o Window defines part of scene being viewed o Must draw geometric primitives only inside window Window Screen Coordinates

Clipping Avoid drawing parts of primitives outside window o Window defines part of scene being viewed o Must draw geometric primitives only inside window Viewing Window

Clipping Avoid drawing parts of primitives outside window o Points o Lines o Polygons o Circles o etc. Viewing Window

Point Clipping Is point (x,y) inside the clip window? wy2 (x,y) inside = (x >= wx1) && (x <= wx2) && (y >= wy1) && (y <= wy2); wy1 wx1 Window wx2

Line Clipping Find the part of a line inside the clip window P 7 P 1 P 3 P 4 P 8 P 2 P 6 P 10 P 5 P 9 Before Clipping

Line Clipping Find the part of a line inside the clip window P 7 P 3 P 4 P 8 P 6 P 5 After Clipping

Cohen Sutherland Line Clipping Use simple tests to classify easy cases first P 7 P 1 P 3 P 4 P 8 P 2 P 6 P 10 P 5 P 9

Cohen Sutherland Line Clipping Unique 4-bit binary number: b 0 b 1 b 2 b 3 (outcode) b 0 = 1 if x<x min, 0 otherwise b 1 = 1 if x>x max, 0 otherwise b 2 = 1 if y<y min, 0 otherwise b 3 = 1 if y>y max, 0 otherwise 1001 0001 0101 y max 1000 0000 0100 1010 0010 0110 y min x min x max

Cohen Sutherland Line Clipping 1001 P 7 0001 0101 Bit 4 P 1 1000 P 3 P 4 P 8 0000 0100 1010 P 2 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen Sutherland Line Clipping Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 P 7 0001 0101 Bit 4 P 1 1000 P 3 P 4 P 8 0000 0100 1010 P 2 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen Sutherland Line Clipping Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen Sutherland Line Clipping Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly: y=mx+h 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 P 7 0001 0101 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 0010 P 9 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 P 9 0010 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 P 10 P 9 0010 0110 Bit 1 Bit 2 Bit 3

Cohen-Sutherland Line Clipping Compute interesections with window boundary for lines that can t be classified quickly 1001 0001 0101 P 7 Bit 4 1000 P 3 P 4 P 8 0000 0100 1010 P 5 P 6 0010 0110 Bit 1 Bit 2 Bit 3

Liang-Barsky Clipping Use parametric form for lines More efficient Line segment, p 1 and p 2 Matrix form p(α)=(1-α)p 1 + αp 2 Scalar form x(α)=(1- α)x 1 + αx 2 y(α)=(1- α)y 1 + αy 2

Liang-Barksy Clipping α varies from 0 1 moving along line from p 1 to p 2 -α yields points on other side of p 1 from p 2 α>1 yields points past on one past p 2 going off to infinity Intersection at 4 points of extended window

Liang-Barksy Clipping α α α α α α α α

Liang-Barksy Order the points 1>α 4 > α 3 > α 2 > α 1 >0 accept, α 3 and α 2 define clipped line 1>α 4 > α 2 > α 3 > α 1 >0 trivially reject entire line ymax y1 α = y2 y1 y(α)=(1- α)y 1 + αy 2 intersection at top of window similar for other sides, ymin, Xmax, and Xmin

Liang-Barksy Rewrite the equation as: α(y 2 -y 1 )=α y=y max -y 1 = y max All tests can be rewritten in the form of y max, y, x max, x No floating point division for any testing Only required if line must be shortened Many lines can be rejected before all computations are done

Clipping Avoid drawing parts of primitives outside window o Points o Lines o Polygons o Circles o etc. Window 2D Screen Coordinates

Polygon Clipping

Polygon Clipping Find the part of a polygon inside the clip window? Before Clipping

Polygon Clipping Find the part of a polygon inside the clip window? After Clipping

Sutherland Hodgeman Clipping Clip to each window boundary one at a time

Sutherland Hodgeman Clipping Clip to each window boundary one at a time

Sutherland Hodgeman Clipping Clip to each window boundary one at a time

Sutherland Hodgeman Clipping Clip to each window boundary one at a time

Sutherland Hodgeman Clipping Clip to each window boundary one at a time

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary P Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary P Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary P Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary P P Inside Outside P 3 P 5 P 4

Clipping to a Boundary Do inside test for each point in sequence, Insert new points when cross window boundary, Remove points outside window boundary P 2 P 1 Window Boundary P P Inside Outside

Polygon Clipping Single polygon with edges that overlap along the sides of the window Causes implementation difficulties

Polygon Clipping Divide (tessellate) a given polygon into a set of convex polygons

Problems With Clipping Polygons Forbid concave polygons Convex polygons result in at most one convex polygon Unpredictable results o Multiple Polygons o How to handle? Tesselate concave polygons Clip each line in a polygon

Sutherland-Hodgeman Clipping Fits well with pipeline architectures Black Box Input: pair of vertices from segment Output: pair of vertices of clipped line segment or nothing.

Sutherland-Hodgeman Clipping Instead of clipping window with four line segments, think of an object created by the intersection of four infinite lines for the top, bottom, right and left sides of the window Subdivide clipper into a pipeline of simpler clippers Each clipper works against a single line that is an extension of an edge of the window

Sutherland-Hodgeman Clipping Clipping against the top Black Box Input: pair of vertices from segment Output: one of three pairs {(x 1,y 1 ),(x 2,y 2 )}, {(x 1,y 1 ),(x i,y max )}, {(x i,y max ),(x 2,y 2 )} Parameter: y max

Sutherland-Hodgeman Clipping Arrange the four clippers in a pipeline

Sutherland-Hodgeman Clipping Build into hardware and clipper works on four vertices concurrently

Bounding Boxes Entire polygon lies outside the clipping window Bounding Box of the polygon is the smallest rectangle, aligned with the window, that contains the polygon. Go through the vertices of the polygon and find the min and max of both the x and y values

Bounding Boxes Detailed clipping only if bounding box straddles the window Powerful technique for 2D and 3D Modeling systems automatically compute and store the bounding box with the object

Curves, Surfaces and Text Approximate curves with line segments; surfaces with planar polygons Use bounding boxes Extremes: bitmapped vs stroke characters

Clipping in the Frame Buffer Scissoring is a technique for clipping in the frame buffer Generally used only on raster objects or blocks of pixels OpenGL allows both techniques: bitmapped in frame buffer, or clip geometric objects (stroke char)

Clipping in Three Dimensions Cohen-Sutherland o Extend 4 bit outcode to 6 bits o Set if in front or behind clipping volume Liang-Barsky o Add equation: z(α)=(1-α)z 1 +αz 2 o Six Intersections Clipping against surfaces instead of lines o p(α)=(1-α)p 1 +αp 2 o n (p(α)-p 0 )=0 o α=(n p 0 -p 1 ))/ (n p 2 -p 1 ))

Cohen-Sutherland

Clipping Against Surfaces

2D Rendering Pipeline 3D Primitives 2D Primitives Clipping Viewport Transformation Scan Conversion Clip portions of geometric primitives residing outside the window Transform the clipped primitives from screen to image coordinates Fill pixels representing primitives in screen coordinates Image

Viewport Transformation Transform 2D geometric primitives from screen coordinate system (normalized device coordinates) to image coordinate system (pixels) Screen Image Viewport Window

Viewport Transformation Window-to-viewport mapping wy2 Window vy2 Viewport (wx,wy) wy1 wx1 wx2 Screen Coordinates (vx,vy) vy1 vx1 vx2 Image Coordinates vx = vx1 + (wx - wx1) * (vx2 - vx1) / (wx2 - wx1); vy = vy1 + (wy - wy1) * (vy2 - vy1) / (wy2 - wy1);

Summary of Transformations p(x,y,z) 3D Object Coordinates Modeling Transformation 3D World Coordinates Viewing Transformation 3D Camera Coordinates Projection Transformation 2D Screen Coordinates Window-to-Viewport Transformation p (x,y ) 2D Image Coordinates } Modeling } Viewport transformation Viewing transformations transformation

Summary 3D Primitives 2D Primitives Clipping Viewport Transformation Scan Conversion Clip portions of geometric primitives residing outside the window Transform the clipped primitives from screen to image coordinates Fill pixels representing primitives in screen coordinates Image

Summary 3D Primitives 3D Modeling Coordinates Modeling Transformation Lighting 3D World Coordinates 3D World Coordinates Viewing Transformation 3D Camera Coordinates Projection Transformation Clipping 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion Image 2D Screen Coordinates 2D Image Coordinates Viewing Window

Next Time 3D Primitives 3D Modeling Coordinates Modeling Transformation Lighting 3D Camera Coordinates Projection Transformation Clipping 3D World Coordinates 3D World Coordinates Viewing Transformation 2D Screen Coordinates P 2 P 1 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion 2D Image Coordinates Image Scan Conversion! P 3