CS 418: Interactive Computer Graphics. Projection

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Introduction to Computer Graphics 4. Viewing in 3D

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

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

Fundamental Types of Viewing

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

Viewing with Computers (OpenGL)

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

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

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

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

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

Virtual Cameras & Their Matrices

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

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

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

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

Overview. By end of the week:

Chapter 5. Projections and Rendering

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

CS 4204 Computer Graphics

Game Architecture. 2/19/16: Rasterization

2D and 3D Viewing Basics

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

Geometry: Outline. Projections. Orthographic Perspective

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

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

Viewing. Reading: Angel Ch.5

OpenGL Transformations

Models and The Viewing Pipeline. Jian Huang CS456

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

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

Lecture 4: 3D viewing and projections

Computer Graphics. Ch 6. 3D Viewing

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

Computer Graphics. Jeng-Sheng Yeh 葉正聖 Ming Chuan University (modified from Bing-Yu Chen s slides)

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

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

Transforms 3: Projection Christian Miller CS Fall 2011

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

Three-Dimensional Viewing Hearn & Baker Chapter 7

5.8.3 Oblique Projections

CS452/552; EE465/505. Intro to Lighting

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

CS452/552; EE465/505. Models & Viewing

CSC 305 The Graphics Pipeline-1

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Lecture 4. Viewing, Projection and Viewport Transformations

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

(Refer Slide Time: 00:01:26)

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)

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

Viewing and Projection

CS6670: Computer Vision

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

Viewing and Projection

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

Virtual Cameras and The Transformation Pipeline

Computer Vision CS 776 Fall 2018

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

3D Viewing. CS 4620 Lecture 8

CSE328 Fundamentals of Computer Graphics

Projections. Brian Curless CSE 457 Spring Reading. Shrinking the pinhole. The pinhole camera. Required:

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

Perspective projection. A. Mantegna, Martyrdom of St. Christopher, c. 1450

Viewing. Part II (The Synthetic Camera) CS123 INTRODUCTION TO COMPUTER GRAPHICS. Andries van Dam 10/10/2017 1/31

3.1 Viewing and Projection

The Graphics Pipeline and OpenGL I: Transformations!

Viewing and Projection

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

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

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Three Main Themes of Computer Graphics

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

Graphics pipeline and transformations. Composition of transformations

Practical Linear Algebra: A Geometry Toolbox

(Refer Slide Time: 00:04:20)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

Chapter 5-3D Camera & Optimizations, Rasterization

Projection Matrix Tricks. Eric Lengyel

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

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Lecture 4: Viewing. Topics:

Shadows in the graphics pipeline

Rasterization Overview

CSE452 Computer Graphics

COMP30019 Graphics and Interaction Perspective Geometry

Projection and viewing. Computer Graphics CSE 167 Lecture 4

CMPSCI 670: Computer Vision! Image formation. University of Massachusetts, Amherst September 8, 2014 Instructor: Subhransu Maji

Building Models. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Projection Lecture Series

Camera model and multiple view geometry

Rigid Body Motion and Image Formation. Jana Kosecka, CS 482

Agenda. Rotations. Camera models. Camera calibration. Homographies

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

Transcription:

CS 418: Interactive Computer Graphics Projection Eric Shaffer Based on John Hart s CS 418 Slides

Hierarchical Solar System Model Without push/pop, You can t move the Earth scale to before you draw the moon: R e T e R m T m S m drawmoon R e T e S e R m T m S m drawmoon The S e will change both the T m and S m

Hieararchical Solar System Model You can move the Earth scale to before you draw the moon: R e T e Push S e drawearth Pop R m T m S m drawmoon

Projections In computer graphics, eventually we need to move from 3D space to 2D space More accurately, from four-dimensional homogenous coordinates to three dimensional homogenous coordinates A projection is a transformation that maps from a highdimensional space into a lower-dimensional space. We will look at some common projections and then we will discuss projection within WebGL

Planar Geometric Projections Standard projections project onto a plane Projectors are lines that either converge at a center of projection are parallel Such projections preserve lines but not necessarily angles Non-planar projections are used in map construction 5

Perspective Projection 6

Orthographic Projection

Oblique Projections Oblique parallel projection Oblique perspective projection Linear projections can be categorized By whether the projectors are parallel By whether the projectors are orthogonal to the view plane

Definition to Know: Foreshortening Foreshortening is the visual effect or optical illusion that causes an object or distance to appear shorter than it actually is because it is angled toward the viewer. i.e. projections squash receding surfaces Andrea Mantegna The Lamentation over the Dead Christ

WebGL Secrets Model Coords Model Xform World Coords Viewing Xform Viewing Coords Perspective Distortion Homogeneo us Divide Still Clip Coords. Clipping Clip Coords. Window Coordinates Window to Viewport Viewport Coordinates WebGL only performs an orthogonal projection Everything is projected to the z= plane in the normalized view volume But you can distort your geometry to achieve a perspective projection The projection occurs when the geometry is in clip space (NDC) and after homogeneous divide Even then, depth information is kept around to do hidden surface removal What form is this depth information? 1

Orthographic Projection y (left,top,-near) View Volume Foreshortens No change in size by depth Classic Orthographic Projection matrix simply zeros the z- coordinate é ù é 1 ù é ù é ù 1 W2V View Model 1 ë û ë û ë û ë û z x Viewing Coordinates Ortho Clip Coordinates -z (right,bottom,-far) mat4.ortho(out,left,right,bottom,top,near,far) 2 r + l r l r l 2 t + b t b t b 2 f + n f n f n 1

GLMatrix ortho matrix ortho(left,right,bottom,top,near,far) near and far are distances measured from camera where is the camera? l,r,b,t are coordinates of the bounding planes what does the matrix do?

GLMatrix ortho matrix ortho(left,right,bottom,top,near,far) near and far are distances measured from camera where is the camera? At the origin due to the view transformation l,r,b,t are coordinates of the bounding planes what does the matrix do? It scales and translates the specified box to fit into the NDC view volume.it decides what you see and what gets clipped

Perspective Brain depends on shape constancy Real world objects do not resize Change in size due to depth Closer objects larger Farther objects smaller

Ames Distorting Room

Hering Illusion

Perspective Projection Objects further from viewer are projected smaller than the same sized objects closer to the viewer (diminution) Looks realistic Equal distances along a line are not projected into equal distances (nonuniform foreshortening) Angles preserved only in planes parallel to the projection plane More difficult to construct by hand than parallel projections

Perspective Distortion

Simple Perspective Projection Brain depends on shape constancy Real world objects do not resize Change in size due to depth Closer objects larger Farther objects smaller How large, how small? Albrecht Durer woodcut c. 1525, swiped from Marc Levoy s CS48N notes c. 27 More Durer, swiped from Fredo Durand s Art of Depiction?

Simple Perspective y screen y view y clip -z d Eye is at origin (,,) Screen is distance d from the eye. Looking down negative z-axis. y clip d = y - z view z view view The two triangles are similar (two angles are obviously congruent) This means corresponding sides are in the same proportions y y view view clip = d = - z view - z view / d y

Simple Perspective x screen x view x clip d z view -z Same process derives the projection for the x coordinate. x -./ = x 2/34 z 2/34 /d What is z clip?

Simple Perspective x screen x view x clip d z view -z 1. This transformation is not invertible 2. It does preserve lines (except when?) 3. It is not an affine transformation (it does not preserve ratios of distances 4. For graphics we will want use a variant that preserves relative distances for hidden surface removal we ll see that later

Projections Using Homogeneous Coordinates We can extend our use of homogenous coordinates to handle projections Let the fourth homogeneous coordinate be any non-zero value w To find the point it corresponds to: multiply all four coordinates by 1/w When homogeneous coordinate is zero Denotes a point at infinity Represents a vector instead of a point Not affected by translation A point in 3D corresponds to what in the 4D homogenous space? é xù é wxù y wy º z wz 1 w ë û ë û é xù é x/ wù y y/ w º z z/ w w 1 ë û ë û é xù é 1 aù é xù y 1 b y = z 1 cz 1 ë û ë û ë û

Simple Perspective y screen y view d y clip z view -z By allowing w to change we represent more kinds of transformations y y clip d clip y = - z y = - z view view view view / d é xview ù é 1 ù é xview ù é xview ù - zview / d 1 y view y view y view = º 1 zview zview - zview / d 1/ d 1 zview / d ë - û ë û ë - û - d 1 ë û

Parameter d y screen y view y clip d y' clip z view -z d y clip = d y view /(-z view ) y' clip = d y view /(-z view ) = (d /d) y clip Using d Using d Changing parameter d just changes scale of projection

Parameter d y screen screen y view y' clip y clip d z view -z d To change degree of perspective distortion, need to change distance from eye to scene, by moving scene closer or farther to eye, along z axis in viewing coordinates

Perspective Projection in WebGL Just like with parallel viewing we will Define a viewing volume Construct a normalization transformation We turn a perspective projection into orthogonal projection This allows us to use the built-in orthogonal projection in WebGL

Perspective Normalization Consider a simple perspective 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

Perspective Matrices Simple projection matrix in homogeneous coordinates Note that this matrix is independent of the far clipping plane û ù ë é - 1 1 1 1 M =

Generalization N = é 1 ë 1 ù α β - 1 û after perspective division, the point (x, y, z, 1) goes to x = -x/z y = -y/z z = -(a +b /z)

Generalization If we apply an orthogonal projection after N Get the correct x and y coordinates after homogenous divide The same as produced by the simple perspective projection x = -x/z y = -y/z z =

Picking a and b If we pick α = β = near + far far near 2near far near far the near plane is mapped to z = 1 the far plane is mapped to z = -1 the sides are mapped to x = ± 1, y = ± 1 The new clipping volume is the default clipping volume

Normalization Transformation distorted object projects correctly original clipping volume original object new clipping volume 3 6

Normalization and Hidden-Surface Removal For two points p 1 and p 2, if z 1 > z 2 in the original clipping volume then the order for the transformed points z 1 > z 2 Thus hidden surface removal using depth comparison works if we first apply the normalization transformation However, the formula z = -(a +b /z) implies that the distances are distorted by the normalization which can cause numerical problems especially if the near distance is small

WebGL Perspective mat4.frustum allows for an asymmetric viewing frustum using left, right, bottom, top, near, far mat4.perspective generates a symmetric frustum using fovy, aspect, near, far fovy à vertical viewing angle in radians aspect à aspect ratio of the viewport near à distance from center of projection to near clip plane far à distance from center of projection to far clip plane it computes a frustum with right=top x aspect top = near x tan(fovy) left = -right and bottom = -top

Perspective Matrices from glmatrix frustum " $ $ $ $ P = $ $ $ $ $ # perspective 2 * near right left 2 * near top bottom right + left right left top + bottom top bottom far + near far near 1 é near right near P = top far + near - - far - near ë - 1 2 * far * near far near 2* far * near far - near ù û % ' ' ' ' ' ' ' ' ' &