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

Similar documents
MIT EECS 6.837, Teller and Durand 1

Rasterization Overview

CS4620/5620: Lecture 14 Pipeline

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

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

CS 130 Exam I. Fall 2015

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

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

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Pipeline Operations. CS 4620 Lecture 10

Rasterization. MIT EECS Frédo Durand and Barb Cutler. MIT EECS 6.837, Cutler and Durand 1

Pipeline Operations. CS 4620 Lecture 14

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

From Vertices To Fragments-1

Chapter 5. Projections and Rendering

Intersection of planar figures. Intersection of a parallelogram and a triangle

Clipping. Administrative. Assignment 1 Gallery. Questions about previous lectures? Overview of graphics pipeline? Assignment 2

RASTERIZING POLYGONS IN IMAGE SPACE

CS 112 The Rendering Pipeline. Slide 1

CEng 477 Introduction to Computer Graphics Fall 2007

Last week. Machiraju/Zhang/Möller

Hidden Surface Removal

Graphics and Interaction Rendering pipeline & object modelling

Perspective Mappings. Contents

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Fondamenti di Grafica 3D The Rasterization Pipeline.

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Two basic types: image-precision and object-precision. Image-precision For each pixel, determine which object is visable Requires np operations

Computer Graphics 7: Viewing in 3-D

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

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

Culling. Computer Graphics CSE 167 Lecture 12

Rendering If we have a precise computer representation of the 3D world, how realistic are the 2D images we can generate? What are the best way to mode

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

The Traditional Graphics Pipeline

Final projects. Rasterization. The Graphics Pipeline. Illumination (Shading) (Lighting) Viewing Transformation. Rest of semester. This week, with TAs

CSE528 Computer Graphics: Theory, Algorithms, and Applications

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

Visibility: Z Buffering

Intro to Modeling Modeling in 3D

The Traditional Graphics Pipeline

Triangle Rasterization

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

Three-Dimensional Viewing Hearn & Baker Chapter 7

Sung-Eui Yoon ( 윤성의 )

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Shadows in the graphics pipeline

Hidden-Surface Removal.

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

8. Hidden Surface Elimination

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Werner Purgathofer

CS 130 Exam I. Fall 2015

9. Visible-Surface Detection Methods

The Traditional Graphics Pipeline

Realtime 3D Computer Graphics Virtual Reality

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

3D Rendering Pipeline (for direct illumination)

Computer Graphics Shadow Algorithms

For each question, indicate whether the statement is true or false by circling T or F, respectively.

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

Lecture 4. Viewing, Projection and Viewport Transformations

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

CSE328 Fundamentals of Computer Graphics

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

CSE328 Fundamentals of Computer Graphics: Concepts, Theory, Algorithms, and Applications

Hidden surface removal. Computer Graphics

Models and The Viewing Pipeline. Jian Huang CS456

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Viewing with Computers (OpenGL)

Prof. Feng Liu. Fall /19/2016

Topic #1: Rasterization (Scan Conversion)

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

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

Basics of Computational Geometry

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

Hidden Surfaces II. Week 9, Mon Mar 15

CSE452 Computer Graphics

CS 130 Final. Fall 2015

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

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

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

Computer Graphics Viewing

Last Time? Ray Casting. Administrivia: Lab & Office Hours. Notes on Assignments. Ray Casting. Overview of Today

Lecture 11: Ray tracing (cont.)

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

COMP3421. Introduction to 3D Graphics

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

Clipping and Scan Conversion

Clipping and Intersection

CHAPTER 1 Graphics Systems and Models 3

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III.

Viewing. Reading: Angel Ch.5

Transcription:

Interactive Computer Graphics The Graphics Pipeline: The Graphics Pipeline Input: - geometric model - illumination model - camera model - viewport Some slides adopted from F. Durand and B. Cutler, MIT Output: 2D image for framebuffer display The Graphics Pipeline The Graphics Pipeline 3D models are defined in their own coordinate system Modeling transformations orient the models within a common coordinate frame (world coordinates) Vertices are lit (shaded) according to material properties, surface properties and light sources Uses a local lighting model 1

The Graphics Pipeline The Graphics Pipeline Maps world space to eye (camera) space Viewing position is transformed to origin and viewing direction is oriented along some axis (typically z) Transforms to Normalized Device Coordinates Portions of the scene outside the viewing volume (view frustum) are removed (clipped) Eye space NDC The Graphics Pipeline The Graphics Pipeline The objects are projected to the 2D imaging plane (screen space) Rasterizes objects into pixels Interpolate values inside objects (color, depth, etc.) NDC Screen Space 2

The Graphics Pipeline Handles occlusions Determines which objects are closest and therefore visible Eliminate portions of objects outside the viewing frustum View frustum boundaries of the image plane projected in 3D a near & far clipping plane User may define additional clipping planes left near right bottom top far Why clipping? When to clip? Avoid degeneracy e.g. don t draw objects behind the camera Improve efficiency e.g. do not process objects which are not visisble left near right bottom top Before perspective transform in 3D space use the equation of 6 planes natural, not too degenerate In homogeneous coordinates after perspective transform (clip space) before perspective divide (4D space, weird w values) canonical, independent of camera simplest to implement In the transformed 3D screen space after perspective division problem: objects in the plane of the camera 3

The concept of a halfspace The concept of a halfspace Y X The concept of a halfspace The concept of a halfspace 4

The concept of a halfspace in 3D Plane equation F(x, y, z) = 0 or Ax + By + Cz + D = 0 For all points in this halfspace F(x i, y i, z i ) > 0 Reminder: Homogeneous Coordinates Recall: For each point (x,y,z,w) there are an infinite number of equivalent homogenous coordinates: (sx, sy, sz, sw) H = (A,B,C,D) For all points in this halfspace F(x i, y i, z i ) < 0 Infinite number of equivalent plane expressions: sax+sby+scz+sd = 0 H = (sa,sb,sc,sd) Point-to-Plane Distance a Point with respect to a Plane If (A,B,C) is normalized: d = H p = H T p (the dot product in homogeneous coordinates) d is a signed distance: positive = "inside" negative = "outside" d H = (A,B,C,D) If d = H p 0 Pass through If d = H p < 0: Clip (or cull or reject) d H = (A,B,C,D) 5

with respect to View Frustum Test against each of the 6 planes Normals oriented towards the interior Clip (or cull or reject) point p if any H p < 0 What are the View Frustum Planes? (right*far/near, top*far/near, far) (left, bottom, near) H near = H far = H bottom = H top = H left = H right = ( 0 0 1 near) ( 0 0 1 far ) ( 0 near bottom 0 ) ( 0 near top 0 ) ( left near 0 0 ) ( right near 0 0 ) Line Plane Intersection Explicit (Parametric) Line Equation L(t) = P 0 + µ (P 1 P 0 ) How do we intersect? Insert explicit equation of line into implicit equation of plane or use the normal vector Line Plane Intersection Compute the intersection between the line and plane for any vector p lying on the plane n p = 0 Let the intersection point be µp 1 + (1-µ)p 0 and assume that v is a point on the plane, a vector in the plane is given by µp 1 + (1-µ)p 0 - v Thus n (µp 1 + (1-µ)p 0 - v) = 0 and we can solve this for µ i and hence find the point of intersection We then replace p 0 with the intersection point 6

Segment Segment If H p > 0 and H q < 0 p If H p > 0 and H q < 0 clip q to plane p If H p < 0 and H q > 0 If H p < 0 and H q > 0 n If H p > 0 and H q > 0 If H p > 0 and H q > 0 q If H p < 0 and H q < 0 If H p < 0 and H q < 0 q Segment Segment If H p > 0 and H q < 0 clip q to plane If H p > 0 and H q < 0 clip q to plane p If H p < 0 and H q > 0 If H p < 0 and H q > 0 clip p to plane If H p > 0 and H q > 0 n p clip p to plane If H p > 0 and H q > 0 pass through n If H p < 0 and H q < 0 If H p < 0 and H q < 0 q q 7

Segment If H p > 0 and H q < 0 clip q to plane If H p < 0 and H q > 0 clip p to plane If H p > 0 and H q > 0 pass through If H p < 0 and H q < 0 clipped out n p q against the frustum For each frustum plane H If H p > 0 and H q < 0, clip q to H If H p < 0 and H q > 0, clip p to H If H p > 0 and H q > 0, pass through If H p < 0 and H q < 0, clipped out Result is a single segment. Two Definitions of Convex Algorithm for determining if an object is convex 1. A line joining any two points on the boundary lies inside the object. 2. The object is the intersection of planar halfspaces. convex = true for each face of the object { find the plane equation of the face F(x,y,z) = 0 choose one object point (x i,y i,z i ) not on the face and find sign(f(x i,y i,z i )) for all other points of the object { if (sign(f(x j,y j,z j ))! = sign(f(x i,y i,z i ))) then convex = false } } 8

Testing for Convex Testing for Containment A frequently encountered problem is to determine whether a point is inside an object or not. We need this for clipping against polyhedra Algorithm for Containment let the test point be (x t,y t,z t ) contained = true for each face of the object { find the plane equation of the face F(x,y,z) = 0 } choose one object point (x i,y i,z i ) not on the face and find sign(f(x i,y i,z i )) if (sign(f (x t,y t,z t ))!= sign(f(x i,y i,z i ))) then contained = false Vector formulation The same test can be expressed in vector form. This avoids the need to calculate the Cartesian equation of the plane, if, in our model we store the normal n vector to each face of our object. 9

Vector test for containment Normal vector to a face The vector formulation does not require us to find the plane equation of a face, but it does require us to find a normal vector to the plane; same thing really since for plane Ax + By + Cz + D = 0 a normal vector is n = (A, B, C) Finding a normal vector But which normal vector points inwards? The normal vector can be found from the cross product of two vectors on the plane, say two edge vectors 10

Checking the normal direction Concave Objects Containment and clipping can also be carried out with concave objects. Most algorithms are based on the ray containment test. The Ray test in two dimensions Calculating intersections with rays Test Point Ray Rays have equivalent equations to lines, but go in only one direction. For test point T a ray is defined as Polygon R = T + µ d µ>0 We choose a simple to compute direction eg Find all intersections between the ray and the polygon edges. If the number of intersections is odd the point is contained d = [1,0,0] 11

Valid Intersections Extending the ray test to 3D Line segment P = V2 + ν (V1 - V2) V1 T Ray P = T + µ d (d = [1,0]) Test point V2 Intersection T + µ d = V2 + ν (V1 - V2) Solve for ν and µ Valid intersection if µ >0, 0<= ν <1 A ray is projected in any direction. If the number of intersections with the object is odd, then the test point is inside 3D Ray test There are two stages: 1. Compute the intersection of the ray with the plane of each face. 2. If the intersection is in the positive part of the ray (µ>0) check whether the intersection point is contained in the face. The plane of a face Unfortunately the plane of a face does not in general line up with the Cartesian axes, so the second part is not a two dimensional problem. However, containment is invariant under orthographic projection, so it can be simply reduced to two dimensions. 12

to concave volumes Splitting a volume into convex parts Find every intersection of the line to be clipped with the volume. This divides the line into one or more segments. Test a point on the first segment for containment Adjacent segments will be alternately inside and out. If all the object vertices lie on one side of the plane of of a face, we proceed to the next face If the plane of a face cuts the object: New Face Split the Object New Face Split Face Split Face Repeat on all concave sub parts 13