CS5500 Computer Graphics April 23, 2007. Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

CS 691 Computational Photography Instructor: Gianfranco Doretto Image Warping.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Projection Matrices Ed Angel
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
Objectives Derive the perspective projection matrices used for standard OpenGL projections Derive the perspective projection matrices used for standard.
3-D Geometry.
Hidden Surface Removal April 30, Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
Representation CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Introduction to 3D viewing 3D is just like taking a photograph!
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Viewing and Projections
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
CS-378: Game Technology Lecture #2.1: Projection Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
Foundations of Computer Graphics (Fall 2012) CS 184, Lectures 13,14: Reviews Transforms, OpenGL
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Computer Graphics Week9 -3D Geometric Transformation.
Computer Graphics I, Fall 2010 Computer Viewing.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Preserving Normals Lecture 28 Wed, Nov 12, The Effect of a Transformation on a Normal What happens to a normal vector under a linear transformation?
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Introduction to Computer Graphics: Viewing Transformations Rama C
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Viewing and Projection
Lecture 5: Introduction to 3D
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
Viewing and Projection
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
Viewing.
Computer Viewing.
Review: Transformations
Isaac Gang University of Mary Hardin-Baylor
CSCE 441 Computer Graphics 3-D Viewing
Lecture 7 Geometric Transformations (Continued)
Projections and Normalization
CSC461: Lecture 19 Computer Viewing
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Projection in 3-D Glenn G. Chappell
Projections and Hidden Surface Removal
Introduction to Computer Graphics with WebGL
University of New Mexico
Computer Graphics Computer Viewing
Lecture 8: 3D Transforms Li Zhang Spring 2008
Computer Viewing Ed Angel Professor Emeritus of Computer Science
CS5500 Computer Graphics April 24, 2006.
Presentation transcript:

CS5500 Computer Graphics April 23, 2007

Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct the projection matrix? References: –[Ed Angel] Sections 5.3.3, 5.5.1, 5.9. –McMillan’s lecture slides

Two Tasks for Today Deriving the viewing matrix –e.g., For gluLookAt() Deriving the projection matrix –e.g., for glFrustum()

Specifying the View Eye position Look-at point Up direction Remember gluLookAt(eye, center, up)? Note that the up vector may not be orthogonal to the viewing direction (i.e., from eye to look-at)

Defining the Eye Space We have two vectors: viewing direction and up vector. Can we set up the three basis vectors for the eye space? v: viewing direction –The easy one = (look_at – eye) r: right vector –Orthogonal to both v and the up vector u: almost like up vector, except: –Orthogonal to both v and r

Inverse = Transpose For an orthonormal matrix, its inverse matrix is its transpose.

Task #2 for Today Deriving the viewing matrix –e.g., For gluLookAt() Deriving the projection matrix –e.g., for glFrustum()

Simple Perspective Consider a simple perspective with the COP at the origin, the near clipping plane at z = -1, and a 90 degree field of view determined by the planes x =  z, y =  z

Simple Perspective After division by w, Sometimes, we write is as: x’ =y’ =

Perspective in OpenGL glFrustum(left, right, bottom, top, near, far ) gluPerpective( FOV_vertical, aspect_ratio, near, far )

Scaling & Translation in X,Y Find Sx, Sy, Tx, Ty, so that: –(left, bottom, near, 1)  (-1, -1, -1, 1) –(right, top, near, 1)  (1, 1, -1, 1)

The Z Component So far, we have ignored the Z coordinate. We want to convert Z so that the range of [near, far] becomes [-1, 1] Note that this is NOT a “uniform” scaling. We will see why after a few slides.

Now let’s look at the Z more carefully…

Range of Z If Z = near, what is Z’? If Z = far, what is Z’? 1 Does Z’ change linearly with Z? –No! –Let a= b= –Z’ = Zw / w = (a*Z+b) / Z = a + b/Z

Why Not Linear? To make it linear, we will have to make WZ’ = a*Z 2 + bZ (so that Z’ = WZ’/W = a*Z + b) But that’s impossible with the 4x4 perspective matrix…

Z Resolution Since screen Z’ is expressed in the form of a+b/Z, most of the Z resolution is used up by the Z’s closer to the near plane. So, what does this mean? You should NOT set zNear to be very close to the eye position.

Now, some more math…

Transformation of Normals Transformation does not necessarily preserve the normal vectors. –If a.b=0, does T(a).T(b)=0 also? For example: what happen if we scale (X, Y) by (0.5, 1.0) in a 2D image?

We shouldn’t transform the two end points of a normal vector. What we should do is to transform (three points of) the plane first, then find its normal. What does that mean in math? (See Appendix F of the OpenGL red book.)

Transformation of Normals (Foley/vanDam pages ) –N T.P = 0 but is (MN) T.MP=0? Not always!! –Let (QN) T.MP=0 (i.e., transform P first, then try to find its normal) –N T Q T MP=0 –So Q T M=I  Q T = M -1 or Q=(M -1 ) T Special case when M -1 =M T –If M consists of only the composition of rotation, translation, and uniform scaling. –Q=M