Viewing and Projection

Similar documents
Viewing and Projection

Viewing and Projection

3.1 Viewing and Projection

Reminder: Affine Transformations. Viewing and Projection. Shear Transformations. Transformation Matrices in OpenGL. Specification via Ratios

Viewing and Projection

Fundamental Types of Viewing

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

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

Overview. By end of the week:

Computer Viewing Computer Graphics I, Fall 2008

CSE328 Fundamentals of Computer Graphics

CSE528 Computer Graphics: Theory, Algorithms, and Applications

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Transformations Computer Graphics I Lecture 4

Introduction to Computer Graphics 4. Viewing in 3D

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

Lecture 5: Transforms II. Computer Graphics and Imaging UC Berkeley CS184/284A

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

Transformations Computer Graphics I Lecture 4

GEOMETRIC TRANSFORMATIONS AND VIEWING

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

Transformation Pipeline

Computer Graphics I Lecture 11

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

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

Lecture 4. Viewing, Projection and Viewport Transformations

CS 4204 Computer Graphics

OpenGL Transformations

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

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

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

3D Viewing Episode 2

Affine Transformations in 3D

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

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

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

CSE 167: Introduction to Computer Graphics Lecture #3: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Transformations (Rotations with Quaternions) October 24, 2005

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

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

Specifying Complex Scenes

CSE 167: Introduction to Computer Graphics Lecture #3: Coordinate Systems

Geometry: Outline. Projections. Orthographic Perspective

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

CSE 167: Introduction to Computer Graphics Lecture #3: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Fachhochschule Regensburg, Germany, February 15, 2017

5.8.3 Oblique Projections

Prof. Feng Liu. Fall /19/2016

Transformations. CSCI 420 Computer Graphics Lecture 4

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

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

MAE : Lecture #12 - Projection and Perspective. Lecture Overview:

Viewing with Computers (OpenGL)

CS 418: Interactive Computer Graphics. Projection

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

CS354 Computer Graphics Viewing and Modeling

Clipping and Scan Conversion

CSC 470 Computer Graphics. Three Dimensional Viewing

Lecture 4: Viewing. Topics:

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

CSC 470 Computer Graphics

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Transforms 1 Christian Miller CS Fall 2011

Graphics and Interaction Transformation geometry and homogeneous coordinates

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

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

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

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

CS452/552; EE465/505. Geometry Transformations

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

Chapter 5. Projections and Rendering

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

Viewing. Reading: Angel Ch.5

Transforms. COMP 575/770 Spring 2013

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Last week. Machiraju/Zhang/Möller/Fuhrmann

Computer Graphics 7: Viewing in 3-D

3D GRAPHICS. design. animate. render

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

Models and The Viewing Pipeline. Jian Huang CS456

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

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

Lecture 4: 3D viewing and projections

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

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

Vector Algebra Transformations. Lecture 4

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

Visualisation Pipeline : The Virtual Camera

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

3D Viewing. CS 4620 Lecture 8

Coordinate Transformations & Homogeneous Coordinates

Projection Lecture Series

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

Game Architecture. 2/19/16: Rasterization

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

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

Chap 7, 2008 Spring Yeong Gil Shin

Viewing Transformation

Transcription:

15-462 Computer Graphics I Lecture 5 Viewing and Projection Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections [Angel, Ch. 5.2-5.4] January 30, 2003 [Red s Dream, Pixar, 1987] Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

Transformation Matrices in OpenGL Transformation matrices in OpenGl are vectors of 16 values (column-major matrices) In glloadmatrixf(glfloat *m); m = {m 1, m 2,..., m 16 } represents Some books transpose all matrices! 01/30/2003 15-462 Graphics I 2

Pondering Transformations Derive transformation given some parameters Choose parameters carefully Consider geometric intuition, basic trigonometry Compose transformation from others Use translations to and from origin Test if matrix describes some transformation Determine action on basis vectors Meaning of dot product and cross product 01/30/2003 15-462 Graphics I 3

Shear Transformations x-shear scales x proportional to y Leaves y and z values fixed 01/30/2003 15-462 Graphics I 4

Specification via Angle cot(θ) = (x -x)/y x = x + y cot(θ) y = y z = z y (x,y) (x,y ) y θ x -x x 01/30/2003 15-462 Graphics I 5

Specification via Ratios Shear in both x and z direction Leave y fixed Slope α for x-shear, γ for z-shear Solve Yields 01/30/2003 15-462 Graphics I 6

Composing Transformations Every affine transformation is a composition of rotations, scalings, and translations How do we compose these to form an x-shear? Exercise! 01/30/2003 15-462 Graphics I 7

Thinking in Frames Action on frame determines affine transfn. Frame given by basis vectors and origin xz-shear: preserve basis vectors u x and u z Move u y = [0 1 0 0] T to u v = [α 1 γ 0] T 01/30/2003 15-462 Graphics I 8

Preservation of Origin Preserve origin P 0 Results comprise columns of the transfn. matrix 01/30/2003 15-462 Graphics I 9

Outline Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections 01/30/2003 15-462 Graphics I 10

Camera in Modeling Coordinates Camera position is identified with a frame Either move and rotate the objects Or move and rotate the camera Initially, pointing in negative z-direction Initially, camera at origin 01/30/2003 15-462 Graphics I 11

Moving Camera and World Frame Move world frame relative to camera frame gltranslatef(0.0, 0.0, -d); moves world frame 01/30/2003 15-462 Graphics I 12

Order of Viewing Transformations Think of moving the world frame Viewing transfn. is inverse of object transfn. Order opposite to object transformations glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0, 0.0, -d); /*T*/ glrotatef(-90.0, 0.0, 1.0, 0.0); /*R*/ 01/30/2003 15-462 Graphics I 13

The Look-At Function Convenient way to position camera glulookat(e x, e y, e z, a x, a y, a z, p x, p y, p z ); e = eye point a = at point p = up vector p e a view plane 01/30/2003 15-462 Graphics I 14

Implementing the Look-At Function (1) Transform world frame to camera frame Compose a rotation R with translation T W = T R (2) Invert W to obtain viewing transformation V V = W -1 = (T R) -1 = R -1 T -1 Derive R, then T, then R -1 T -1 01/30/2003 15-462 Graphics I 15

World Frame to Camera Frame I Camera points in negative z direction n = (a e) / a e is unit normal to view plane R maps [0 0-1 0] T to [n x n y n z 0] T p n e a view plane 01/30/2003 15-462 Graphics I 16

World Frame to Camera Frame II R maps y to projection of p onto view plane α = (p n) / n = p n v 0 = p α n v = v 0 / v 0 p V 0 e α n a view plane 01/30/2003 15-462 Graphics I 17

World Frame to Camera Frame III x is orthogonal to n and v in view plane u = n v (u, v, -n) is right-handed p v n u e a view plane 01/30/2003 15-462 Graphics I 18

Summary of Rotation glulookat(e x, e y, e z, a x, a y, a z, p x, p y, p z ); n = (a e) / a e v = (p (p n) n) / p (p n) n u = n v 01/30/2003 15-462 Graphics I 19

World Frame to Camera Frame IV Translation of origin to e = [e x e y e z 1] T 01/30/2003 15-462 Graphics I 20

Camera Frame to World Frame V = W -1 = (T R) -1 = R -1 T -1 R is rotation, so R -1 = R T T is translation, so T -1 negates displacement 01/30/2003 15-462 Graphics I 21

Putting it Together Calculate V = R -1 T -1 This is different from book [Angel, Ch. 5.2.2] There, u, v, n are right-handed (here: u, v, -n) 01/30/2003 15-462 Graphics I 22

Other Viewing Functions Roll (about z), pitch (about x), yaw (about y) Assignment 2 poses related problem 01/30/2003 15-462 Graphics I 23

Outline Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections 01/30/2003 15-462 Graphics I 24

Projection Matrices Recall geometric pipeline Projection takes 3D to 2D Projections are not invertible Projections also described by matrix Homogenous coordinates crucial Parallel and perspective projections 01/30/2003 15-462 Graphics I 25

Orthographic Projections Parallel projection Projectors perpendicular to projection plane Simple, but not realistic Used in blueprints (multiview projections) 01/30/2003 15-462 Graphics I 26

Orthographic Projection Matrix Project onto z = 0 x p = x, y p = y, z p = 0 In homogenous coordinates 01/30/2003 15-462 Graphics I 27

Perspective Perspective characterized by foreshortening More distant objects appear smaller Parallel lines appear to converge Rudimentary perspective in cave drawings 01/30/2003 15-462 Graphics I 28

Discovery of Perspective Foundation in geometry (Euclid) Mural from Pompeii 01/30/2003 15-462 Graphics I 29

Middle Ages Art in the service of religion Perspective abandoned or forgotten Ottonian manuscript, ca. 1000 01/30/2003 15-462 Graphics I 30

Renaissance Rediscovery, systematic study of perspective Filippo Brunelleschi Florence, 1415 01/30/2003 15-462 Graphics I 31

Perspective Viewing Mathematically More on history of perspective (icscis) http://www.cyberus.ca/~icscis/icscis.htm y/z = y p /d so y p = y/(z/d) Note this is non-linear! 01/30/2003 15-462 Graphics I 32

Exploiting the 4 th Dimension Perspective projection is not affine: has no solution for M Idea: represent point [x y z 1] T by line in 4D for arbitrary w 0 01/30/2003 15-462 Graphics I 33

Perspective Projection Matrix Represent multiple of point Solve with 01/30/2003 15-462 Graphics I 34

Perspective Division Normalize [x y z w] T to [(x/w) (y/w) (z/w) 1] T Perform perspective division after projection Projection in OpenGL is more complex 01/30/2003 15-462 Graphics I 35

Parallel Viewing in OpenGL glortho(xmin, xmax, ymin, ymax, near, far) z min = near, z max = far 01/30/2003 15-462 Graphics I 36

Perspective Viewing in OpenGL Two interfaces: glfrustum and gluperspective glfrustum(xmin, xmax, ymin, ymax, near, far); z min = near, z max = far 01/30/2003 15-462 Graphics I 37

Field of View Interface gluperspective(fovy, aspect, near, far); near and far as before Fovy specifies field of view as height (y) angle 01/30/2003 15-462 Graphics I 38

Matrices for Projections in OpenGL Next lecture: Use shear for predistortion Use projections for fake shadows Other kinds of projections 01/30/2003 15-462 Graphics I 39

Announcements Assignment 1 due Thursday midnight (100 pts) Late policy Up to 3 days any time, no penalty No other late hand-in permitted Assignment 2 out Thursday (1 week, 50 pts) Extra credit policy Up to 20% of assignment value Recorded separately Weighed for borderline cases Remember: no collaboration on assignments! 01/30/2003 15-462 Graphics I 40

Looking Ahead Lighting and shading Video: Red s Dream, John Lasseter, Pixar,1987 http://www.pixar.com/shorts/rd/index.html 01/30/2003 15-462 Graphics I 41