Viewing and Projection

Similar documents
Viewing and Projection

3.1 Viewing and Projection

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

Transformations. CSCI 420 Computer Graphics Lecture 4

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

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

Transformation Pipeline

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

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

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

Computer Viewing Computer Graphics I, Fall 2008

OpenGL Transformations

Geometry: Outline. Projections. Orthographic Perspective

Overview. By end of the week:

Introduction to Computer Graphics 4. Viewing in 3D

Transformations (Rotations with Quaternions) October 24, 2005

Prof. Feng Liu. Fall /19/2016

CS 543: Computer Graphics. Projection

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE328 Fundamentals of Computer Graphics

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

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

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

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

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

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

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

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

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

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

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

Viewing COMPSCI 464. Image Credits: Encarta and

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

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Lecture 4. Viewing, Projection and Viewport Transformations

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

Fachhochschule Regensburg, Germany, February 15, 2017

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

CS 4204 Computer Graphics

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

Transformations Computer Graphics I Lecture 4

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

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

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Viewing Transformation

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

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

Three-Dimensional Viewing Hearn & Baker Chapter 7

3D Viewing Episode 2

Transforms 3: Projection Christian Miller CS Fall 2011

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

Basic Graphics Programming

Viewing with Computers (OpenGL)

The View Frustum. Lecture 9 Sections 2.6, 5.1, 5.2. Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2011

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

Transformations Computer Graphics I Lecture 4

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

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

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

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Computer Graphics 7: Viewing in 3-D

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

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

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

Models and The Viewing Pipeline. Jian Huang CS456

Transformation Algebra

Viewing/Projections IV. Week 4, Fri Feb 1

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

CSC 470 Computer Graphics. Three Dimensional Viewing

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

CS354 Computer Graphics Viewing and Modeling

CSC 470 Computer Graphics

Chap 7, 2008 Spring Yeong Gil Shin

Lecture 4: Viewing. Topics:

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

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

Lecture 4 of 41. Lab 1a: OpenGL Basics

Interaction. CSCI 480 Computer Graphics Lecture 3

Transforms 1 Christian Miller CS Fall 2011

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

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

5.8.3 Oblique Projections

Viewing. Reading: Angel Ch.5

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

Computer Graphics: Viewing in 3-D. Course Website:

CS 418: Interactive Computer Graphics. Projection

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

Lecture 4: 3D viewing and projections

Computer Graphics I Lecture 11

Three Main Themes of Computer Graphics

Transcription:

CSCI 480 Computer Graphics Lecture 5 Viewing and Projection Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections [Geri s Game, Pixar, 1997] January 26, 2011 Jernej Barbic University of Southern California http://www-bcf.usc.edu/~jbarbic/cs480-s11/ 1

Reminder: Affine Transformations Given a point [x y z], form homogeneous coordinates [x y z 1]. The transformed point is [x y z ]. 2

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! 3

Shear Transformations x-shear scales x proportional to y Leaves y and z values fixed 4

Specification via Shear Angle cot(θ) = (x -x)/y x = x + y cot(θ) y = y z = z y (x,y) (x,y ) θ = shear angle y θ x -x x θ 5

Specification via Ratios Shear in both x and z direction Leave y fixed Slope α for x-shear, γ for z-shear Solve Yields 6

Composing Transformations Let p = A q, and q = B s. Then p = (A B) s. s q p B A AB matrix multiplication 7

Composing Transformations Every affine transformation is a composition of rotations, scalings, and translations How do we compose these to form an x-shear? Exercise! 8

Outline Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections 9

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 10

Moving Camera and Rendering Frame Move rendering frame relative to camera frame gltranslatef(0.0, 0.0, -d); moves rendering frame 11

The Look-At Function Convenient way to position camera glulookat(e x, e y, e z, f x, f y, f z, u x, u y, u z ); e = eye point f = focus point u = up vector u e u f e f view plane 12

OpenGL code void display() { glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glmatrixmode (GL_MODELVIEW); glloadidentity(); glulookat (e x, e y, e z, f x, f y, f z, u x, u y, u z ); gltranslatef(x, y, z);... renderbunny(); glutswapbuffers(); } 13

Implementing the Look-At Function 1. Transform rendering 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 14

Rendering Frame to Camera Frame I Camera points in negative z direction n = (f e) / f e is unit normal to view plane Therefore, R maps [0 0-1 0] T to [n x n y n z 0] T u n e f view plane 15

Rendering Frame to Camera Frame II R maps y to projection of u onto view plane This projection v equals: α = (u n) / n = u n v 0 = u α n v = v 0 / v 0 u V 0 e α n f view plane 16

Rendering Frame to Camera Frame III Set w to be orthogonal to n and v w = n x v (w, v, -n) is right-handed v n w e f view plane 17

Summary of Rotation glulookat(e x, e y, e z, f x, f y, f z, u x, u y, u z ); n = (f e) / f e v = (u (u n) n) / u (u n) n w = n x v Rotation must map: (1,0,0) to w (0,1,0) to v (0,0,-1) to n 18

Rendering Frame to Camera Frame IV Translation of origin to e = [e x e y e z 1] T 19

Camera Frame to Rendering 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 20

Putting it Together Calculate V = R -1 T -1 This is different from book [Angel, Ch. 5.3.2] There, u, v, n are right-handed (here: u, v, -n) 21

Other Viewing Functions Roll (about z), pitch (about x), yaw (about y) Assignment 2 poses a related problem 22

Outline Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections 23

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 24

Orthographic Projections Parallel projection Projectors perpendicular to projection plane Simple, but not realistic Used in blueprints (multiview projections) 25

Orthographic Projection Matrix Project onto z = 0 x p = x, y p = y, z p = 0 In homogenous coordinates 26

Perspective Perspective characterized by foreshortening More distant objects appear smaller Parallel lines appear to converge Rudimentary perspective in cave drawings: Lascaux, France source: Wikipedia 27

Discovery of Perspective Foundation in geometry (Euclid) Mural from Pompeii, Italy 28

Middle Ages Art in the service of religion Perspective abandoned or forgotten Ottonian manuscript, ca. 1000 29

Renaissance Rediscovery, systematic study of perspective Filippo Brunelleschi Florence, 1415 30

Projection (Viewing) in OpenGL Remember: camera is pointing in the negative z direction 31

Orthographic Viewing in OpenGL glortho(xmin, xmax, ymin, ymax, near, far) z min = near, z max = far 32

Perspective Viewing in OpenGL Two interfaces: glfrustum and gluperspective glfrustum(xmin, xmax, ymin, ymax, near, far); z min = near, z max = far 33

Field of View Interface gluperspective(fovy, aspect, near, far); near and far as before aspect = w / h Fovy specifies field of view as height (y) angle 34

OpenGL code void reshape(int x, int y) { glviewport(0, 0, x, y); glmatrixmode(gl_projection); glloadidentity(); } gluperspective(45.0, 1.0 * x / y, 0.01, 10.0); 35

Perspective Viewing Mathematically d d = focal length y/z = y p /d so y p = y/(z/d) Note that y p is non-linear in the depth z! 36

Exploiting the 4 th Dimension Perspective projection is not affine: has no solution for M Idea: exploit homogeneous coordinates for arbitrary w 0 37

Perspective Projection Matrix Use multiple of point Solve with 38

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 (includes clipping) 39

Short film: Geri s game (Pixar 1997) 40