Viewing Transformation

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

Geometry: Outline. Projections. Orthographic Perspective

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

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

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

Computer Viewing Computer Graphics I, Fall 2008

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

Advanced Computer Graphics (CS & SE )

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

Matrix-Rechnung I ' z =... Universität Frankfurt

Fundamental Types of Viewing

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

COMP3421. Introduction to 3D Graphics

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Computer Graphics. Chapter 10 Three-Dimensional Viewing

OpenGL Transformations

1 (Practice 1) Introduction to OpenGL

CS354 Computer Graphics Viewing and Modeling

COMP3421. Introduction to 3D Graphics

COMS 4160: Problems on Transformations and OpenGL

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

COMP3421. Introduction to 3D Graphics

CS 4204 Computer Graphics

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

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

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

MORE OPENGL. Pramook Khungurn CS 4621, Fall 2011

Prof. Feng Liu. Fall /19/2016

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

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Fachhochschule Regensburg, Germany, February 15, 2017

CSC 470 Computer Graphics. Three Dimensional Viewing

Computer Graphics. Bing-Yu Chen National Taiwan University

CSC 470 Computer Graphics

Precept 2 Aleksey Boyko February 18, 2011

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

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

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

Transformations (Rotations with Quaternions) October 24, 2005

Transforms 3: Projection Christian Miller CS Fall 2011

3.1 Viewing and Projection

Viewing COMPSCI 464. Image Credits: Encarta and

3D Viewing Episode 2

Viewing and Projection

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

Wire-Frame 3D Graphics Accelerator IP Core. C Library Specification

Lecture 4. Viewing, Projection and Viewport Transformations

Viewing and Projection

Overview. By end of the week:

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

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

Computer Graphics. Basic 3D Programming. Contents

Order of Transformations

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

2D and 3D Viewing Basics

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

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Lecture 9 Sections 2.6, 5.1, 5.2. Wed, Sep 16, 2009

Viewing with Computers (OpenGL)

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

Graphics and Visualization

Transformation Pipeline

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

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

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

Chapter 3 - Basic Mathematics for 3D Computer Graphics

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

Introduction to OpenGL

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

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

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

part 3 Martin Samuelčík Room I4

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

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

Viewing transformations. 2004, Denis Zorin

Transformation, Input and Interaction. Hanyang University

Viewing and Projection

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

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

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

CS 4204 Computer Graphics

3D Viewing Episode 2

Visualizing Molecular Dynamics

1 OpenGL - column vectors (column-major ordering)

Lecture 4 of 41. Lab 1a: OpenGL Basics

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

OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL

Perspective transformations

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

Affine Transformations in 3D

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

Realtime 3D Computer Graphics & Virtual Reality. Viewing

Lecture 4: 3D viewing and projections

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Graphics and Computation Introduction to OpenGL

Computer Viewing. Prof. George Wolberg Dept. of Computer Science City College of New York

Three-Dimensional Viewing Hearn & Baker Chapter 7

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

Transcription:

CS38: Computer Graphics Viewing Transformation Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg/

Class Objectives Know camera setup parameters Understand viewing and projection processes 2

Viewing Transformations Map points from world spaces to eye space Can be composed from rotations and translations 3

Viewing Transformations Goal: specify position and orientation of our camera Defines a coordinate frame for eye space 4

Framing the Picture A new camera coordinate Camera position at the origin Z-axis aligned with the view direction Y-axis aligned with the up direction More natural to think of camera as an object positioned i in the world frame 5

Viewing Steps Rotate to align the two coordinate frames and, then, translate to move world space origin to camera s origin 6

An Intuitive Specification Specify three quantities: Eye point (e) Look-at point (p) Up-vector ( u a ) the image - position of the camera - center of the image - will be oriented upwards in 7

Deriving the Viewing Transformation First compute the look-at vector and normalize l p e l Compute right vector and normalize Perpendicular to the look-at and up vectors r r l u a r r Compute up vector u a is only approximate direction Perpendicular to right and look-at vectors u r l l l 8

Rotation Component Map our vectors to the cartesian coordinate axes r u R v l R v To compute we invert the matrix on the right 9 This matrix M is orthonormal (or orthogonal) its rows are orthonormal basis vectors: vectors mutually orthogonal and of unit length - T Then, M M t r So, R v t u l t

Translation Component Translation Component Th t ti th t j t d i d i ifi d b t The rotation that we just derived is specified about the eye point in world space Need to translate all world-space coordinates so that the Need to translate all world space coordinates so that the eye point is at the origin Composing these transformations gives our viewing transform, V e v t t e w T R e u e r u r e e u u u r r r y x z y x z y x T R V e l e u l u e l l l z y z y x y e v T R V Transform a world-space point into a point in the eye-space

Viewing Transform in OpenGL OpenGL utility (glu) library provides a viewing transformation function: glulookat (double eyex, double eyey, double eyez, double centerx, double centery, double centerz, double upx, double upy, double upz) Computes the same transformation that we derived and composes it with the current matrix

Example in the Skeleton Codes of PA2 2 void setcamera () { // initialize camera frame transforms for (i=; i < cameracount; i++ ). } { } double* c = cameras[i]; wld2cam.push_back(framexform()); glpushmatrix(); glloadidentity(); glulookat(c[],c[],c[2], c[3],c[4],c[5], c[6],c[7],c[8]); glgetdoublev( GL_MODELVIEW_MATRIX, wld2cam[i].matrix() ); glpopmatrix(); cam2wld.push_back(wld2cam[i].inverse());

Projections Map 3D points in eye space to 2D points in image space Two common methods Orthographic projection Perspective projection 3

Orthographic Projection Projects points along lines parallel to z-axis Also called parallel projection Used for top and side views in drafting and modeling applications Appears unnatural due to lack of perspective foreshortening Notice that the parallel lines of the tiled floor remain parallel after orthographic projection! 4

Orthographic Projection Orthographic Projection Th j ti t i f th hi j ti The projection matrix for orthographic projection is very simple x x z y x z y x Next step is to convert points to NDC 5

View Volume and Normalized Device Coordinates Define a view volume Compose projection with a scale and a translation that maps eye coordinates to normalized device coordinates 6

Orthographic Projections to NDC x y z 2 right left 2 topbottom Some sanity checks: x left x 2 far near (i (right left) right left (top bottom) topbottom (far near) far near x y z right left right left right 2 left left right left right left Scale the z coordinate in exactly the same way.technically, this coordinate is not part of the projection. But, we will use this value of z for other purposes x right x 2right right left right left right left right left right left 7

Orthographic Projection in OpenGL This matrix is constructed by the following OpenGL call: void glortho(double left, double right, double bottom, double top, double near, double far ); 2D version (another GL utility function): void gluortho2d( double left, GLdouble right, double bottom, GLdouble top);, which is just a call to glortho( ) with near =- and far = 8

Perspective Projection Artists (Donatello, Brunelleschi, Durer, and Da Vinci) during the renaissance discovered the importance of perspective for making images appear realistic Perspective causes objects nearer to the viewer to appear larger than the same object would appear farther away Homogenous coordinates allow perspective projections using linear operators 9

Signs of Perspective Lines in projective space always intersect at a point 2

Perspective Projection 2 y y s d z

Perspective Projection Matrix The simplest transform for perspective projection is: wx x wy y wz z w We divide by w to make the fourth coordinate In this example, w = z Therefore, x = x / z, y = y / z, z = 22

Normalized Perspective As in the orthographic case, we map to normalized device coordinates 23

NDC Perspective Matrix wx 2near (right right left right wy 2 near (top topbottom top wz far far w left) left bottom) bottom near near 2 far near far near x y z The values of left, right, top, and bottom are specified at the near depth. Let s try some sanity checks: x left z near x x right x z near 2 right near left left 2nearright right left near(right left ) right left near near(right left ) right left near near near near near 24

NDC Perspective Matrix wx 2near (right right left right wy 2 near (top topbottom top wz far far w left) left bottom) bottom near near 2 far near far near x y z The values of left, right, top, and bottom are specified at the near depth. Let s try some sanity checks: z far z far far near far near far 2 far near far near far ( far near) far near far z near z near far far near near near 2 far near far near near( nearfar ) far near near 25

Perspective in OpenGL OpenGL provides the following function to define perspective transformations: void glfrustum(double left, double right, double bottom, double top, double near,, double far); Some think that using glfrustum( ) is nonintuitive. So OpenGL provides a function with simpler, but less general capabilities void gluperspective(double vertfov, double aspect, double near, double far); 26

gluperspective() Simple cameralike model Can only specify symmetric frustums Substituting the extents t into glfrustum() 27

gluperspective() Simple cameralike model Can only specify symmetric frustums Substituting the extents into glfrustum() vertfov COT( wx 2 ) x aspect wy vertfov COT( y 2 ) wz far near 2 far near z far near far near w 28

Example in the Skeleton Codes of PA2 void reshape( int w, int h) { width = w; height = h; glviewport(,, width, height); glmatrixmode(gl_projection); // Select The Projection Matrix glloadidentity(); // Reset The Projection Matrix // Define perspective projection frustum double aspect = width/double(height); i ht) gluperspective(45, aspect,, 24); glmatrixmode(gl_modelview); // Select The Modelview Matrix glloadidentity(); // Reset The Projection Matrix } 29

Class Objectives were: Know camera setup parameters Understand viewing and projection processes 3

Reading Assignment Read the chapter Data Structure for Graphics 3

PA3 32 PA2: perform the transformation at the modeling space PA3: perform the transformation at the viewing space

Next Time Interaction 33