Virtual Cameras & Their Matrices

Similar documents
Course no. DIS4566 National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor

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

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

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

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

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

Fundamental Types of Viewing

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

CS452/552; EE465/505. Intro to Lighting

Introduction to Computer Graphics 4. Viewing in 3D

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

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

CS 418: Interactive Computer Graphics. Projection

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

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

Phong Lighting & Materials. Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ.

Overview. By end of the week:

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

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

EECS : Introduction to Computer Graphics Building the Virtual Camera ver. 1.4

EECS : Introduction to Computer Graphics Building the Virtual Camera ver. 1.5

Lecture 4. Viewing, Projection and Viewport Transformations

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

Three-Dimensional Viewing Hearn & Baker Chapter 7

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

Three Main Themes of Computer Graphics

Transforms 3: Projection Christian Miller CS Fall 2011

CSC 305 The Graphics Pipeline-1

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

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

The Graphics Pipeline and OpenGL I: Transformations!

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

Introduction to Computer Graphics with WebGL

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

CSE328 Fundamentals of Computer Graphics

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

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

3D Viewing. CS 4620 Lecture 8

Virtual Cameras and The Transformation Pipeline

Projection and viewing. Computer Graphics CSE 167 Lecture 4

CS 4204 Computer Graphics

Introduction to Computer Graphics with WebGL

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

Viewing and Projection

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

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

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

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

Viewing with Computers (OpenGL)

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Viewing and Projection

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

Today s Agenda. Geometry

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

Lecture 4: 3D viewing and projections

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

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

CS4620/5620: Lecture 14 Pipeline

Introduction to Computer Graphics with WebGL

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

COMP3421. Introduction to 3D Graphics

Viewing. Reading: Angel Ch.5

1 OpenGL - column vectors (column-major ordering)

3.1 Viewing and Projection

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

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

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

Single View Geometry. Camera model & Orientation + Position estimation. What am I?

CS488. Implementation of projections. Luc RENAMBOT

COMP3421. Introduction to 3D Graphics

Prof. Feng Liu. Fall /19/2016

Perspective transformations

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

Viewing and Projection

Viewing and Projection Transformations

Viewing and Projection

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Chapter 4-3D Camera & Optimizations, Rasterization

Rasterization Overview

Viewing/Projections IV. Week 4, Fri Feb 1

Models and The Viewing Pipeline. Jian Huang CS456

Models and Architectures

The Graphics Pipeline and OpenGL I: Transformations!

Fachhochschule Regensburg, Germany, February 15, 2017

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

Single View Geometry. Camera model & Orientation + Position estimation. What am I?

5.8.3 Oblique Projections

3D Viewing Episode 2

Computer Viewing Computer Graphics I, Fall 2008

Geometry: Outline. Projections. Orthographic Perspective

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

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

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

Projection Lecture Series

Transcription:

Virtual Cameras & Their Matrices J.Tumblin-Modified, highly edited SLIDES from: Ed Angel Professor Emeritus of Computer Science University of New Mexico 1

What is Projection? Any operation that reduces dimension (e.g., 3D to 2D) Orthographic Projection Perspective Projection

V U N Center of Projection (Camera Origin) Image Plane ( Splits the Universe )

Perspective Projection z = not allowed (what happens to points on plane z =?) Operation well-defined for all other points

The View Frustum

Vertex Stream WebGL: Vertex Position Pipeline gl.modelview gl.projection model + model view + view transformation transformation projection transformation HTML-5 Canvas divide: x/w, y/w, z/w 4D 3D The CVV clipping ViewPort transformation gl.viewport(llx, lly width,height) (in pixels) 6

Notes KEEP our four-dimensional homogeneous coordinates throughout all transforms by MODEL, VIEW, and PROJECTION matrix: - All are nonsingular - All default to identity matrices (CVV sets limits) Delay final perspective-divides until the end - Important for hidden-surface removal: we NEED depth information to draw pixels! - Efficient : FP division == expensive to compute E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 7

WebGL: Vertex Position Pipeline Wher do these matrices fit into the SceneGraph? MODEL (jointed objects) VIEW (camera-positioning) PROJECTION (lens-like) VIEWPORT (screen) group4 CVV t1 HTML-5 Canvas t group1 t2 group2 t7 group3... t3 t4 obj1 obj5 obj2 group3 8

WebGL: Vertex Position Pipeline RECALL: in scene graphs, Vertices & values move upwards, transform calls move downwards Project A: CVV == World drawing axes (group) CVV HTML-5 Canvas group4 t1 t group1 t2 t7 group3... t3 group2 t4 obj1 obj5 obj2 group3 9

WebGL: Vertex Position Pipeline RECALL: in scene graphs, Vertices & values move upwards, transform calls move downwards CVV HTML-5 Canvas Viewport Project A: CVV == World drawing axes (group) World CAM View Projection Project B: Viewport output HTML Canvas CVV output Viewport input Lens Axes CVV input Camera Axes Lens Input group4 t group1 t1 t2 group2 group3... t7 t3 t4 obj2 group3 World Coords Camera Axes 1 obj1 obj5

Simple Perspective Consider a simple point-perspective image with the COP at the origin, the near clipping plane at z = -1, and a 9 degree field of view determined by the planes x = z, y = z E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 11

Simple Perspective Consider a simple point-perspective image with the COP at the origin, the near clipping plane at z = -1, and a 9 degree field of view determined by the planes x = z, y = z E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 12

Orthographic Camera Simple Orthographic Projection Matrix: re-scale a rectangular volume in CAM coords to fit within the CVV gl.ortho(left,right,bottom,top,near,far) E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 13

Step 1: Orthogonal Matrix Two steps: - Translate the camera s frustum center to the origin T(-(left+right)/2, -(bottom+top)/2, (near+far)/2)) - Scale to have sides of length 2 (to match the CVV) S(2/(left-right),2/(top-bottom),2/(near-far)) P = ST = 2 right left 2 top bottom 2 near far right left right left top bottom top bottom far near far near 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 14

Clipping & Display: Put it into the CVV! Keep 3D clipping simple, fixed and fast Don t form different clipping volumes for each kind of frustum, lens or camera! Instead, map them all into the CVV become orthogonal projections to screen One camera one matrix One camera type One function E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 15

Simple Perspective Consider a simple point-perspective image with the COP at the origin, the near clipping plane at z = -1, and a 9 degree field of view determined by the planes x = z, y = z E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 16

(Naïve) Perspective Matrix Simple projection matrix in homogeneous coordinates M = 1 1 1 1 Trouble! matrix ignores near clipping plane, and CVV sets far plane by default to +1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 17

One Weird Trick to fix it (perfectionists hate it ) N = 1 1 α β 1 after perspective division, the point at (x, y, z, 1) becomes x = x/z y = y/z Z = -(az+b)/z Choose a and b carefully E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 18

Generalize to fix it: N = 1 1 α β 1 after perspective division, the point (x, y, z, 1) goes to x = x/z y = y/z Z = -(az+b)/z Could it span -1 to +1 (as x,y might)? could we fit it into the CVV? E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 19

Pseudo-Depth : Picking a and b If we pick a = b = near far far near 2near far near far the near plane is mapped to z = 1 the far plane is mapped to z =-1 and the sides are mapped to x = 1, y = 1 Hence the viewing frustum fills the CVV exactly! E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 2

Normalization Transformation distorted object projects correctly original clipping volume original object new clipping volume E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 21

Posing the Camera AWKWARD: Define position in WORLD coords 22

END E. Angel and D. Shriener: Interactive Computer Graphics 6E Addison-Wesley 212 23

Normalization and Hidden-Surface Removal Although our pseudo-depth may SEEM weirdly arbitrary, it ensures monotonic depth: if z 1 > z 2 in the original clipping volume, then inside the CVV we always have z 1 > z 2 Thus hidden surface removal still works fine based on CVV s z value However pseudo-depth DISTORTS distances. It compresses far-away depths, expands nearby ones; z = -(az+b) /z Tiny znear? Giant zfar? Expect coarse depth quantization! E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 24

Set z = Step 2: Final Projection (perspective) Equivalent to the homogeneous coordinate transformation M orth = 1 1 1 Hence, general orthogonal projection in 4D is P = M orth ST E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212 25