Prof. Feng Liu. Fall /19/2016

Similar documents
Viewing COMPSCI 464. Image Credits: Encarta and

CS464 Oct 3 rd Assignment 3 Due 10/6/2017 Due 10/8/2017 Implementation Outline

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

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

Geometry: Outline. Projections. Orthographic Perspective

Viewing with Computers (OpenGL)

CS 4204 Computer Graphics

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

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

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

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

3.1 Viewing and Projection

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

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

Viewing and Projection

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

Lecture 4. Viewing, Projection and Viewport Transformations

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

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

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

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

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

COMP3421. Introduction to 3D Graphics

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

COMP3421. Introduction to 3D Graphics

Viewing and Projection

Fundamental Types of Viewing

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

COMP3421. Introduction to 3D Graphics

Computer Viewing Computer Graphics I, Fall 2008

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

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

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

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

Introduction to Computer Vision

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

Computer Graphics. Chapter 7 2D Geometric Transformations

Computer Graphics 7: Viewing in 3-D

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

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

Transformation Pipeline

Three-Dimensional Viewing Hearn & Baker Chapter 7

Computer Vision cmput 428/615

Viewing. Announcements. A Note About Transformations. Orthographic and Perspective Projection Implementation Vanishing Points

Computer Vision Projective Geometry and Calibration. Pinhole cameras

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

Models and The Viewing Pipeline. Jian Huang CS456

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

CSE328 Fundamentals of Computer Graphics

COMS 4160: Problems on Transformations and OpenGL

CS 543: Computer Graphics. Projection

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

Fachhochschule Regensburg, Germany, February 15, 2017

CSC 305 The Graphics Pipeline-1

3D Viewing. CS 4620 Lecture 8

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

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

Viewing. Reading: Angel Ch.5

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

CSC 470 Computer Graphics. Three Dimensional Viewing

Computer Vision Project-1

CSC 470 Computer Graphics

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

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

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Game Architecture. 2/19/16: Rasterization

Lecture 4: Viewing. Topics:

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Drawing in 3D (viewing, projection, and the rest of the pipeline)

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

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

Computer Graphics. Lecture 04 3D Projection and Visualization. Edirlei Soares de Lima.

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

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

1 OpenGL - column vectors (column-major ordering)

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

Perspective transformations

Perspective matrix, OpenGL style

Introduction to Computer Graphics 4. Viewing in 3D

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

Transforms 3: Projection Christian Miller CS Fall 2011

Reading on the Accumulation Buffer: Motion Blur, Anti-Aliasing, and Depth of Field

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

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

3D Viewing Episode 2

Overview. By end of the week:

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

Viewing and Projection

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)

Graphics Pipeline. CS535 Fall Daniel G. Aliaga Department of Computer Science Purdue University

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

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

CS354 Computer Graphics Viewing and Modeling

Drawing in 3D (viewing, projection, and the rest of the pipeline)

CS 591B Lecture 9: The OpenGL Rendering Pipeline

Transforms 1 Christian Miller CS Fall 2011

Transcription:

Prof. Feng Liu Fall 26 http://www.cs.pdx.edu/~fliu/courses/cs447/ /9/26

Last time More 2D Transformations Homogeneous Coordinates 3D Transformations The Viewing Pipeline 2

Today Perspective projection Homework 2 due in class today In-class Middle-Term Wednesday, Nov. 2 Close-book exam Notes on page of A4 or Letter size paper To-know list available online 3

Graphics Pipeline Local Coordinate Space World Coordinate Space View Space Canonical View Volume Display Space 4

Defining Cameras View Space is the camera s local coordinates The camera is in some location The camera is looking in some direction It is tilted in some orientation It is inconvenient to model everything in terms of View Space Biggest problem is that the camera might be moving we don t want to have to explicitly move every object too We specify the camera, and hence View Space, with respect to World Space How can we specify the camera? 5

Specifying a View The location of View Space with respect to World Space A point in World Space for the origin of View Space, (e x,e y,e z ) The direction in which we are looking: gaze direction Specified as a vector: (g x,g y,g z ) This vector will be normal to the image plane A direction that we want to appear up in the image (up x,up y,up z ), this vector does not have to be perpendicular to g We also need the size of the view volume l,r,t,b,n,f Specified with respect to the eye and image plane, not the world 6

General Orthographic e Subtle point: it doesn t precisely matter where we put the image plane image plane g t,n y t,f (,) x b,n b,f 7

Getting there We wish to end up in View Space, so we need a coordinate system with: A vector toward the viewer, View Space z A vector pointing right in the image plane, View Space x A vector pointing up in the image plane, View Space y The origin at the eye, View Space (,,) We must: Say what each of these vectors are in World Space Transform points from the World Space into View Space We can then apply the orthographic projection to get to Canonical View Space, and so on 8

View Space in World Space Given our camera definition, in World Space: Where is the origin of view space? It will transform into (,,) view What is the normal to the view plane, w? It will become z view How do we find the right vector, u? It will become x view How do we find the up vector, v? It will become y view Given these points, how do we do the transformation? 9

View Space The origin is at the eye: (e x,e y,e z ) The normal vector is the normalized viewing direction w gˆ We know which way up should be, and we know we have a right handed system, so u=up w, normalized: û We have two vectors in a right handed system, so to get the third: v=w u

World to View We must translate so the origin is at (e x,e y,e z ) To complete the transformation we need to do a rotation After this rotation: The direction u in world space should be the direction (,,) in view space The vector v should be (,,) The vector w should be (,,) The matrix that does the rotation is: It s a change of basis matrix ux vx wx u v w y y y u v z z w z

All Together We apply a translation and then a rotation, so the result is: And to go all the way from world to screen: 2 w v u e e e M z y x z y x z y x z y x z y x z y x z y x view world w w w v v v u u u e e e w w w v v v u u u world canonical world canonical view world canonical view canonical world x M x M M M

Graphics Pipeline Local Coordinate Space World Coordinate Space View Space Canonical View Volume Display Space 3

OpenGL and Transformations OpenGL internally stores two matrices that control viewing of the scene The GL_MODELVIEW matrix is intended to capture all the transformations up to view space The GL_PROJECTION matrix captures the view to canonical conversion You also specify the mapping from the canonical view volume into window space Directly through a glviewport function call Matrix calls, such as glrotate, multiply some matrix M onto the current matrix C, resulting in CM Set view transformation first, then set transformations from local to world space last one set is first one applied This is the convenient way for modeling, as we will see 4

Graphics Pipeline Local Coordinate Space World Coordinate Space View Space Canonical View Volume Display Space GL_MODELVIEW GL_PROJECTION glviewport 5

OpenGL Camera The default OpenGL image plane has u aligned with the x axis, v aligned with y, and n aligned with z Means the default camera looks along the negative z axis Makes it easy to do 2D drawing (no need for any view transformation) glortho( ) sets the view->canonical matrix Modifies the GL_PROJECTION matrix glulookat( ) sets the world->view matrix Takes an image center point, a point along the viewing direction and an up vector Multiplies a world->view matrix onto the current GL_MODELVIEW matrix You could do this yourself, using glmultmatrix( ) with the matrix from the previous slides 6

Typical Usage glmatrixmode(gl_projection); glloadidentity(); glortho(l, r, b, t, n, f); glmatrixmode(gl_modelview); glloadidentity(); glulookat(ex,ey,ez,cx,cy,cx,ux,uy,uz); GLU functions, such as glulookat( ), are not part of the core OpenGL library They can be implemented with other core OpenGL commands For example, glulookat( ) uses glmultmatrix( ) with the matrix from the previous slides They are not dependent on a particular graphics card 7

Left vs Right Handed View Space You can define u as right, v as up, and n as toward the viewer: a right handed system uv=w Advantage: Standard mathematical way of doing things You can also define u as right, v as up and n as into the scene: a left handed system vu=w Advantage: Bigger n values mean points are further away OpenGL is right handed Many older systems, notably the Renderman standard developed by Pixar, are left handed 8

Graphics Pipeline Local Coordinate Space World Coordinate Space View Space Canonical View Volume Display Space 9

Review View Space is a coordinate system with the viewer looking down the z axis, with x to the right and y up The World->View transformation takes points in world space and converts them into points in view space The Projection matrix, or View->Canonical matrix, takes points in view space and converts them into points in Canonical View Space Canonical View Space is a coordinate system with the viewer looking along z, x to the right, y up, and everything to be drawn inside the cube [-,]x[-,]x[-,] using parallel projection 2

Perspective Projection Abstract camera model - box with a small hole in it Pinhole cameras work in practice 2

Distant Objects Are Smaller 22

Parallel lines meet 23

Vanishing points Each set of parallel lines (=direction) meets at a different point: The vanishing point for this direction Classic artistic perspective is 3-point perspective Sets of parallel lines on the same plane lead to collinear vanishing points: the horizon for that plane Good way to spot faked images

Basic Perspective Projection We are going to temporarily ignore canonical view space, and go straight from view to window Assume you have transformed to view space, with x to the right, y up, and z back toward the viewer Assume the origin of view space is at the center of projection (the eye) Define a focal distance, d, and put the image plane there (note d is negative) You can define d to control the size of the image 25

Basic Perspective Projection If you know P(x v,y v,z v ) and d, what is P(x s,y s )? Where does a point in view space end up on the screen? y v P(x s,y s ) P(x v,y v,z v ) x v d -z v 26

Basic Case Similar triangles gives: xs d x z v v ys d y z v v y v P(x s,y s ) P(x v,y v,z v ) d View Plane -z v 27

Simple Perspective Transformation Using homogeneous coordinates we can write: Our next big advantage to homogeneous coordinates 28 d z z y x d y x v v v v s s v s d P P

Parallel Lines Meet? Parallel lines are of the form: Parametric form: x is a point on the line, t is a scalar (distance along the line from x ) and d is the direction of the line (unit vector) Different x give different parallel lines Transform and go from homogeneous to regular: Limit as t is d x x t d d d d d d d tz z ty y tz z tx x f z y x f t z y x f w z y x f z fy z fx d d d d

General Perspective The basic equations we have seen give a flavor of what happens, but they are insufficient for all applications They do not get us to a Canonical View Volume They make assumptions about the viewing conditions To get to a Canonical Volume, we need a Perspective Volume 3

Perspective View Volume Recall the orthographic view volume, defined by a near, far, left, right, top and bottom plane The perspective view volume is also defined by near, far, left, right, top and bottom planes the clip planes Near and far planes are parallel to the image plane: z v =n, z v =f Other planes all pass through the center of projection (the origin of view space) The left and right planes intersect the image plane in vertical lines The top and bottom planes intersect in horizontal lines 3

Clipping Planes x v Near Clip Plane Left Clip Plane n l View Volume Far Clip Plane r f -z v Right Clip Plane 32

Where is the Image Plane? Notice that it doesn t really matter where the image plane is located, once you define the view volume You can move it forward and backward along the z axis and still get the same image, only scaled The left/right/top/bottom planes are defined according to where they cut the near clip plane Or, define the left/right and top/bottom clip planes by the field of view 33

Field of View x v Assumes a symmetric view volume FOV Near Clip Plane View Volume Far Clip Plane f Left Clip Plane -z v Right Clip Plane 34

Perspective Parameters We have seen several different ways to describe a perspective camera Focal distance, Field of View, Clipping planes The most general is clipping planes they directly describe the region of space you are viewing For most graphics applications, field of view is the most convenient It is image size invariant having specified the field of view, what you see does not depend on the image size You can convert one thing to another 35

Focal Distance to FOV You must have the image size to do this conversion Why? Same d, different image size, different FOV height/2 d FOV/2 d FOV tan 2 FOV 2 tan height 2d height 2d 36

OpenGL gluperspective( ) Field of view in the y direction, FOV, (vertical field-of-view) Aspect ratio, a, should match window aspect ratio Near and far clipping planes, n and f Defines a symmetric view volume glfrustum( ) Give the near and far clip plane, and places where the other clip planes cross the near plane Defines the general case Used for stereo viewing, mostly 37

gluperspective to glfrustum As noted previously, glu functions don t add basic functionality, they are just more convenient So how does gluperspective convert to glfrustum? Symmetric, so only need t and l y FOV / 2 t? n z 38

Perspective Projection Matrices We want a matrix that will take points in our perspective view volume and transform them into the orthographic view volume This matrix will go in our pipeline before an orthographic projection matrix (r,t,f) (r,t,n) (r,t,f) (l,b,n) (r,t,n) (l,b,n) 39

Mapping Lines We want to map all the lines through the center of projection to parallel lines This converts the perspective case to the orthographic case, we can use all our existing methods The relative intersection points of lines with the near clip plane should not change The matrix that does this looks like the matrix for our simple perspective case 4

General Perspective 4 This matrix leaves points with z=n unchanged It is just like the simple projection matrix, but it does some extra things to z to map the depth properly We can multiply a homogenous matrix by any number without changing the final point, so the two matrices above have the same effect nf f n n n n f n f n M P

Complete Perspective Projection 42 After applying the perspective matrix, we map the orthographic view volume to the canonical view volume: 2 2 2 nf f n n n f n f n f n b t b t b t l r l r l r P O canonical view M M M world canonical world canonical view world canonical view canonical world x M x M M M

Near/Far and Depth Resolution It may seem sensible to specify a very near clipping plane and a very far clipping plane Sure to contain entire scene But, a bad idea: OpenGL only has a finite number of bits to store screen depth Too large a range reduces resolution in depth - wrong thing may be considered in front See Shirley for a more complete explanation Always place the near plane as far from the viewer as possible, and the far plane as close as possible 43

OpenGL Perspective Projection 44 For OpenGL you give the distance to the near and far clipping planes The total perspective projection matrix resulting from a glfrustum call is: 2 2 2 f n n f f n f n b t b t b t n l r l r l r n M OpenGL

Next Time Clipping Rasterization 45