Lecture 4: Viewing. Topics:

Similar documents
CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Chap 7, 2009 Spring Yeong Gil Shin

CS 4731/543: Computer Graphics Lecture 5 (Part I): Projection. Emmanuel Agu

Realtime 3D Computer Graphics & Virtual Reality. Viewing

CS 428: Fall Introduction to. Viewing and projective transformations. Andrew Nealen, Rutgers, /23/2009 1

Computer Graphics. Jeng-Sheng Yeh 葉正聖 Ming Chuan University (modified from Bing-Yu Chen s slides)

5.8.3 Oblique Projections

Computer Graphics. Viewing. Fundamental Types of Viewing. Perspective views. Parallel views. October 12, finite COP (center of projection)

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

COMP Computer Graphics and Image Processing. a6: Projections. In part 2 of our study of Viewing, we ll look at. COMP27112 Toby Howard

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface

Chap 7, 2008 Spring Yeong Gil Shin

Viewing with Computers (OpenGL)

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Fundamental Types of Viewing

Motivation. What we ve seen so far. Demo (Projection Tutorial) Outline. Projections. Foundations of Computer Graphics

Classical and Computer Viewing. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

3-Dimensional Viewing

Overview of Projections: From a 3D world to a 2D screen.

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

To Do. Demo (Projection Tutorial) Motivation. What we ve seen so far. Outline. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 5: Viewing

Viewing and Projection

Viewing. Reading: Angel Ch.5

To Do. Motivation. Demo (Projection Tutorial) What we ve seen so far. Computer Graphics. Summary: The Whole Viewing Pipeline

Transforms II. Overview. Homogeneous Coordinates 3-D Transforms Viewing Projections. Homogeneous Coordinates. x y z w

Introduction to Computer Graphics 4. Viewing in 3D

3D Viewing and Projec5on. Taking Pictures with a Real Camera. Steps: Graphics does the same thing for rendering an image for 3D geometric objects

Three-Dimensional Viewing Hearn & Baker Chapter 7

Computer Graphics. P05 Viewing in 3D. Part 1. Aleksandra Pizurica Ghent University

Viewing. Cliff Lindsay, Ph.D. WPI

Computer Viewing Computer Graphics I, Fall 2008

Evening s Goals. Mathematical Transformations. Discuss the mathematical transformations that are utilized for computer graphics

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

CPSC 314, Midterm Exam 1. 9 Feb 2007

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

CS 543: Computer Graphics. Projection

Viewing/Projection IV. Week 4, Fri Jan 29

Viewing/Projections III. Week 4, Wed Jan 31

Projections. Brian Curless CSE 457 Spring Reading. Shrinking the pinhole. The pinhole camera. Required:

Viewing in 3D (Chapt. 6 in FVD, Chapt. 12 in Hearn & Baker)

Viewing/Projections IV. Week 4, Fri Feb 1

Chapter 8 Three-Dimensional Viewing Operations

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

p =(x,y,d) y (0,0) d z Projection plane, z=d

What does OpenGL do?

Computer Viewing and Projection. Overview. Computer Viewing. David Carr Fundamentals of Computer Graphics Spring 2004 Based on Slides by E.

CS 475 / CS 675 Computer Graphics. Lecture 7 : The Modeling-Viewing Pipeline

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE328 Fundamentals of Computer Graphics

Chap 3 Viewing Pipeline Reading: Angel s Interactive Computer Graphics, Sixth ed. Sections 4.1~4.7

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

On the Midterm Exam. Monday, 10/17 in class. Closed book and closed notes. One-side and one page cheat sheet is allowed. A calculator is allowed

6. Modelview Transformations

Overview. By end of the week:

Chapter 5. Projections and Rendering

Must first specify the type of projection desired. When use parallel projections? For technical drawings, etc. Specify the viewing parameters

Determining the 2d transformation that brings one image into alignment (registers it) with another. And

2D and 3D Viewing Basics

CPSC 314, Midterm Exam. 8 March 2013

CS Computer Graphics: Transformations & The Synthetic Camera

Name: [20 points] Consider the following OpenGL commands:

Transformations II. Arbitrary 3D Rotation. What is its inverse? What is its transpose? Can we constructively elucidate this relationship?

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Computer Viewing. CITS3003 Graphics & Animation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley

Announcement. Project 1 has been posted online and in dropbox. Due: 11:59:59 pm, Friday, October 14

Prof. Feng Liu. Fall /19/2016

CPSC 314, Midterm Exam. 8 March 2010

Realtime 3D Computer Graphics Virtual Reality

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

Last Time. Correct Transparent Shadow. Does Ray Tracing Simulate Physics? Does Ray Tracing Simulate Physics? Refraction and the Lifeguard Problem

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

Viewing Transformations I Comp 535

Geometry: Outline. Projections. Orthographic Perspective

CS230 : Computer Graphics Lecture 6: Viewing Transformations. Tamar Shinar Computer Science & Engineering UC Riverside

Viewing and Modeling

Computer Graphics. Coordinate Systems and Change of Frames. Based on slides by Dianna Xu, Bryn Mawr College

Game Architecture. 2/19/16: Rasterization

Introduction to Computer Graphics with WebGL

1 OpenGL - column vectors (column-major ordering)

Perspective Projection Transformation

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

Uses of Transformations. 2D transformations Homogeneous coordinates. Transformations. Transformations. Transformations. Transformations and matrices

Graphics 2009/2010, period 1. Lecture 6: perspective projection

Viewing and Projection

Viewing and Projection

CS F-07 Objects in 2D 1

What and Why Transformations?

Transformations II. Week 2, Wed Jan 17

Models and The Viewing Pipeline. Jian Huang CS456

Notes. University of British Columbia

Modeling Transformations

4. Two Dimensional Transformations

So we have been talking about 3D viewing, the transformations pertaining to 3D viewing. Today we will continue on it. (Refer Slide Time: 1:15)

Introduction to Homogeneous coordinates

Transcription:

Lecture 4: Viewing Topics: 1. Classical viewing 2. Positioning the camera 3. Perspective and orthogonal projections 4. Perspective and orthogonal projections in OpenGL 5. Perspective and orthogonal projection matrices Chapter 5, Sections 5.1, 5.2, 5.3, 5.4, 5.7, 5.8. 1

Classical and computer viewing Both kinds of viewing involve: objects, a viewer, projectors, and a projection plane. The projectors meet at the centre of projection (COP. The COP is the centre of the lens or ee, or in computer graphics the origin of the camera frame. In both classical and computer viewing the viewer can be an infinite distance from the objects. As we move the COP to infinit the projectors become parallel and in the limit, the COP can be replaced b a direction of projection (DOP. Views with a finite COP are called perspective views while those with a COP at infinit are called parallel views. Projector Object Object COP Projection plane DOP Projector Projection plane 2

Classical viewing Front elevation Elevation oblique Plan oblique Isometric One-point perspective Three-point perspective In classical viewing there is an underling notion of a principal face. This is tpical in architecture where objects are often buildings having planar faces: front, back, top, bottom, right and left faces. Such objects have three orthogonal directions associated with them. 3

Parallel viewing An orthogonal projection is one in which the projectors are not onl parallel but also perpendicular to the projection plane. The classical orthographic projection is an orthogonal projection in which the projection plane is placed parallel to one of the principal faces of the object. A more general orthogonal projection is the aonometric projection, in which the projection plane can have an arbitrar orientation. Dimetric Trimetric Isometric 4

Oblique projections are parallel views in which the projection plane is not orthogonal to the projectors. The projection plane is skew. Projection plane Projection plane Projection plane (a (b (c (a construction (b top view (c side view 5

Perspective viewing In perspective viewing, the image of an object gets smaller when it is moved awa from the viewer. Therefore perspective views look more natural. However the cannot be used to make measurements, as with parallel views. (a (b (c (a Three-point perspective: three vanishing points (b Two-point perspective: two vanishing points (c One-point perspective: one vanishing point 6

Positioning the camera How do we position the camera with respect to the objects? There are two points of view: (1 we move the camera with respect to the objects or (2 we move objects relative to a fied camera. The two reciprocal movements will result in the same image. These movements are controlled b the model-view matri which represents a transformation between the world frame and the camera frame. Initiall (b default the model-view matri is set to the identit, in which case both frames are the same. The camera is at the origin pointing down the negative ais. 7

Eample 1. Objects are tpicall placed near the origin. So to view them, we need to move the camera back along the ais. The correct transformation is therefore glmatrimode(gl_modelview; glloadidentit(; gltranslatef(0,0, 0.0, -d; for some positive number d., c c, c c, c c (a (b We can think of this transformation either as a translation of the objects through the vector (0, 0, d or as a translation of the camera through the vector (0, 0, d. 8

Eample 2. We now wish to view the objects (which are again centred around the origin from the positive ais. To achieve this we need first to move the camera backwards along the positive ais, a distance d, and then rotate the camera around the ais b 90 degrees: glmatrimode(gl_modelview; glloadidentit(; gltranslatef(0,0, 0.0, -d; glrotate(-90.0, 0.0, 1.0, 0.0; The equivalent viewpoint is to think of the model-view matri being applied to the objects: the are first rotated through 90 degrees around the ais, and then translated through (0, 0, d. The model-view matri has the form M = T R, and M is applied to each object verte p, moving it to Mp. T R 9

Eample 3. To achieve more complicated orientations of the camera we can concatenate rotation matrices. However, it is easier to use a function provided in GLU: glulookat(ee, ee, ee, at, at, at, up, up, up; (at, at, at (up, up, up (ee, ee, ee This function sets the origin of the camera to be the eepoint e and sets the camera frame aes u,v,n (plaing the role of,, according to the point at and the vector up. It first sets n = e at, the normal to the projection plane. The vector v is then computed as the projection of up onto this plane. Finall u is taken to be the cross product of v and n. 10

Perspective projections Suppose the camera is at its default position at the origin, pointing along the negative ais. How do we compute a perspective projection? For simplicit, suppose the projection plane is parallel to the - plane, i.e., = d, for some negative number d. Each point (,, in space is projected towards the origin. Therefore the point where the projector hits the projection plane is ( p, p, p, where p = d/, p = d/, p = d. (,, ( p, d (, = d ( p, d (, ( p, p, p = d (a (b (c The perspective transformation (,, ( p, p, p is clearl non-affine. So how can we represent it using a 4 4 matri? 11

The answer is to etend the notion of homogeneous coordinates. Recall that the point (,, has the homogeneous representation (,,, 1. We can etend this representation b agreeing that the same point can be represented b the vector (w, w, w, w, for an w 0. To recover the representation (,,, 1, we have onl to divide the coordinates b w. With this etended homogeneous representation of points, we can represent our perspective transformation b the matri 1 0 0 0 0 1 0 0 M =. 0 0 1 0 0 0 1/d 0 The matri M transforms the point p = (,,, 1 T into the point q = (,,, /d T, and after division b the last coordinate, /d, we arrive at q = ( p, p, p, 1. This latter division is called perspective division, and can be made part of the pipeline: model-view projection perspective division 12

Orthogonal projections Orthogonal projections can be viewed as the limiting case of perspective projections as the COP goes to infinit. However, in practice it is much simpler to derive the projection equation directl. We can assume that the projection plane is = 0, in which case the point (,, is mapped to ( p, p, p where p =, p =, p = 0. ( p, p, 0 = 0 (,, In homogeneous coordinates, the transformation is p 1 0 0 0 p 0 1 0 0 =. p 0 0 0 0 1 0 0 0 1 1 Here no perspective division is necessar, but in hardware implementations we can use the same pipeline for both perspective and orthogonal projections. 13

Perspective projections in OpenGL In addition to the projections themselves, we need to specif a clipping volume or view volume, b specifing front and back clipping frames. For perspective projections, the viewing volume becomes a frustum, a truncated pramid. View volume View plane Front clipping plane Back clipping plane COP 14

In OpenGL, we can specif a perspective view b constructing and loading the matri ourselves, or b using one of two special functions. The first is glfrustum(min, ma, min, ma, near, far which sets the frustum shown in the following figure. = ma = min ( ma, ma, min ( min, min, min Here, min = near and ma = far in the figure. The near and far distances must be positive, and so min and ma are alwas negative. Note that min, ma, min, ma are the coordinates of the front clipping plane. 15

The second function for specifing a perspective projection with a clipping volume is gluperspective(fov, aspect, near, far. This function uses the angle of view fov in the direction and the aspect ratio width divided b height together with the near and far planes to completel determine the desired frustum. w h fov 16

Orthogonal projections in OpenGL To specif an orthogonal projection in OpenGL there is just one function: glortho(min, ma, min, ma, near, far whose arguments are identical to those of glfrustum. The view volume is now a parallelepiped. We have set min = near and ma = far again in the figure. ( ma, ma, ma = ma View volume = min ( min, min, min Unlike with perspective projections, the arguments near and far no longer have to be positive. The onl restriction is that near < far. 17

Orthogonal projection matrices The projection matrices used in OpenGL must also take account of the clipping volume. We begin with the projection matri for the function glortho(min, ma, min, ma, near, far Set min = near, ma = far. All OpenGL needs to do is to map the chosen view volume into the canonical one: = ±1, = ±1, = ±1. ( ma, ma, ma (1,1,1 ( min, min, min (-1,-1,-1 This can be achieved b concatenating a translation and a scaling: ( T ( min + ma /2, ( min + ma /2, ( min + ma /2, ( S 2/( ma min, 2/( ma min, 2/( ma min, giving the projection matri P = ST = 2 ma min 0 0 min+ ma ma min 0 2 ma min 0 min+ ma ma min 0 0 2 ma min min+ ma ma min 0 0 0 1. 18

Perspective projection matrices We now find the projection matri in OpenGL specified b the function gluperspective(fov, aspect, near, far. Again set min = near, ma = far. Assume for simplicit that fov = 90 and aspect = 1: (-1, -1, -1 (1, 1, -1 From our previous discussion, the simple matri 1 0 0 0 0 1 0 0 M = 0 0 1 0 0 0 1 0 provides the correct perspective projectors but sends all points into the plane = 1. 19

We need a more general matri, 1 0 0 0 0 1 0 0 N =, 0 0 α β 0 0 1 0 in order to transform the front clipping plane = min into the canonical plane = 1 and the back clipping plane = ma into = 1. The matri N clearl maps the point (,,, 1 to the point (,,, w where =, =, = α + β, w =. After dividing b w, we get = /, = /, = (α + β/, which means that the planes = ± and = ± are transformed into the planes = ±1 and = ±1, for an α, β. On the other hand, the planes = min and = ma are mapped respectivel into the planes = (α + β/ min, = (α + β/ ma. So we have to solve the simultaneous equations (α + β/ min = 1, (α + β/ ma = 1, for α, β, in order to map the front clipping plane = min into the canonical plane = 1 and the back clipping plane = ma into = 1. The solution is α = ma + min ma min, β = 2 ma min ma min. 20