CS 4731/543: Computer Graphics Lecture 5 (Part I): Projection. Emmanuel Agu

Similar documents
CS 543: Computer Graphics. Projection

Viewing. Cliff Lindsay, Ph.D. WPI

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

Lecture 4: Viewing. Topics:

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

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

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

Viewing and Projection

Viewing/Projections III. Week 4, Wed Jan 31

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Viewing/Projection IV. Week 4, Fri Jan 29

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

Realtime 3D Computer Graphics & Virtual Reality. Viewing

Viewing with Computers (OpenGL)

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

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

CS Computer Graphics: Transformations & The Synthetic Camera

Viewing in 3D (Chapt. 6 in FVD, Chapt. 12 in Hearn & Baker)

5.8.3 Oblique Projections

3-Dimensional Viewing

Chap 7, 2009 Spring Yeong Gil Shin

3D Viewing and Projec5on. Taking Pictures with a Real Camera. Steps: Graphics does the same thing for rendering an image for 3D geometric objects

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

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

What does OpenGL do?

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

2D and 3D Viewing Basics

Must first specify the type of projection desired. When use parallel projections? For technical drawings, etc. Specify the viewing parameters

News. Projections and Picking. Transforming View Volumes. Projections recap. Basic Perspective Projection. Basic Perspective Projection

CPSC 314, Midterm Exam. 8 March 2013

Geometry: Outline. Projections. Orthographic Perspective

COMP3421. Introduction to 3D Graphics

p =(x,y,d) y (0,0) d z Projection plane, z=d

CS 475 / CS 675 Computer Graphics. Lecture 7 : The Modeling-Viewing Pipeline

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

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

CPSC 314, Midterm Exam 1. 9 Feb 2007

Announcements. Tutorial this week Life of the polygon A1 theory questions

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

Viewing Transformations I Comp 535

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

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

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

COMP3421. Introduction to 3D Graphics

Viewing. Reading: Angel Ch.5

COMP3421. Introduction to 3D Graphics

Models and The Viewing Pipeline. Jian Huang CS456

Lecture 4. Viewing, Projection and Viewport Transformations

Introduction to Computer Graphics 4. Viewing in 3D

Name: [20 points] Consider the following OpenGL commands:

Computer Graphics 7: Viewing in 3-D

Prof. Feng Liu. Fall /19/2016

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

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

Viewing COMPSCI 464. Image Credits: Encarta and

Chap 7, 2008 Spring Yeong Gil Shin

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

CPSC 314, Midterm Exam. 8 March 2010

CSE328 Fundamentals of Computer Graphics

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

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

Computer Graphics. Chapter 10 Three-Dimensional Viewing

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

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

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

OpenGL Transformations

Three-Dimensional Viewing Hearn & Baker Chapter 7

Last Time. Correct Transparent Shadow. Does Ray Tracing Simulate Physics? Does Ray Tracing Simulate Physics? Refraction and the Lifeguard Problem

Perspective transformations

Transforms 3: Projection Christian Miller CS Fall 2011

Computer Graphics. Viewing. Fundamental Types of Viewing. Perspective views. Parallel views. October 12, finite COP (center of projection)

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

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

CSE452 Computer Graphics

Viewing/Projections IV. Week 4, Fri Feb 1

CSE528 Computer Graphics: Theory, Algorithms, and Applications

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

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

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

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

Transformation Pipeline

3D graphics rendering pipeline (1) 3D graphics rendering pipeline (3) 3D graphics rendering pipeline (2) 8/29/11

CS Computer Graphics: Hidden Surface Removal

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

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

3D computer graphics: geometric modeling of objects in the computer and rendering them

3D Coordinates & Transformations

Transformations II. Arbitrary 3D Rotation. What is its inverse? What is its transpose? Can we constructively elucidate this relationship?

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

What and Why Transformations?

CS 543: Computer Graphics Lecture 4 (Part I): 3D Affine transforms. Emmanuel Agu

Modeling Transformations

CS4620/5620: Lecture 14 Pipeline

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

Note 2: Transformation (modeling and viewing)

Chapter 8 Three-Dimensional Viewing Operations

Institutionen för systemteknik

Transcription:

CS 4731/543: Computer Graphics Lecture 5 (Part I): Projection Emmanuel Agu

3D Viewing and View Volume Recall: 3D viewing set up

Projection Transformation View volume can have different shapes (different looks) Different tpes of projection: parallel, perspective, orthographic, etc Important to control Projection tpe: perspective or orthographic, etc. Field of view and image aspect ratio Near and far clipping planes

Perspective Projection Similar to real world Characteried b object foreshortening Objects appear larger if the are closer to camera Need: Projection center Projection plane Projection: Connecting the object to the projection center camera projection plane

Projection? Projectors Object in 3 space Projected image COP VRP

Orthographic Projection No foreshortening effect distance from camera does not matter The projection center is at infinite Projection calculation just drop coordinates

Field of View Determine how much of the world is taken into the picture Larger field of view = smaller object projection sie field of view (view angle) center of projection θ

Near and Far Clipping Planes Onl objects between near and far planes are drawn Near plane + far plane + field of view = Viewing Frustum Near plane Far plane

Viewing Frustrum 3D counterpart of 2D world clip window Objects outside the frustum are clipped Near plane Far plane Viewing Frustum

Projection Transformation In OpenGL: Set the matri mode to GL_PROJECTION Perspective projection: use gluperspective(fov, aspect, near, far) or glfrustum(left, right, bottom, top, near, far) Orthographic: glortho(left, right, bottom, top, near, far)

gluperspective(fov, aspect, near, far) Aspect ratio is used to calculate the window width fov ee w h Aspect = w / h near far

glfrustum(left, right, bottom, top, near, far) Can use this function in place of gluperspective() left top bottom right near far

glortho(left, right, bottom, top, near, far) For orthographic projection left top bottom right near far

Eample: Projection Transformation void displa() { glclear(gl_color_buffer_bit); glmatrimode(gl_projection); glloadidentit(); gluperspective(fov, aspect, near, far); glmatrimode(gl_modelview); glloadidentit(); glulookat(,,1,,,,,1,); displa_all(); // our displa routine }

Demo Nate Robbins demo on projection

Projection Transformation Projection map the object from 3D space to 2D screen Perspective: gluperspective() Parallel: glortho()

Parallel Projection After transforming the object to the ee space, parallel projection is relativel eas we could just drop the Z Xp = Yp = Zp = -d (Xp, Yp) We actuall want to keep Z wh? (,,)

Parallel Projection OpenGL maps (projects) everthing in the visible volume into a canonical view volume (ma, ma, far) (1, 1, -1) (min, min, near) (-1, -1, 1) Canonical View Volume glortho(min, ma, min, ma,near, far) Projection: Need to build 44 matri to do mapping from actual view volume to CVV

Parallel Projection: glortho Parallel projection can be broken down into two parts Translation which centers view volume at origin Scaling which reduces cuboid of arbitrar dimensions to canonical cube (dimension 2, centered at origin)

Parallel Projection: glortho Translation sequence moves midpoint of view volume to coincide with origin: E.g. midpoint of = (ma + min)/2 Thus translation factors: -(ma+min)/2, -(ma+min)/2, -(far+near)/2 And translation matri M1: 1 1 1 ( ( ( ma ma ma + + + 1 min) min) min) / / / 2 2 2

Parallel Projection: glortho Scaling factor is ratio of cube dimension to Ortho view volume dimension Scaling factors: 2/(ma-min), 2/(ma-min), 2/(ma-min) Scaling Matri M2: 2 ma min 2 ma min 2 ma min 1

Parallel Projection: glortho + + + = 1 min) ma min) /( ma ( min) ma 2 /( min) ma min) /( ma ( min) ma 2 /( min) ma min) /( ma ( min) ma 2 /( 1 2 M M Refer: Hill, 7.6.2 Concatenating M1M2, we get transform matri used b glortho 1 min ma 2 min ma 2 min ma 2 X + + + 1 2 / min) ma ( 1 2 / min) ma ( 1 2 / min) ma ( 1

Perspective Projection: Classical Side view: Projection plane (,, ) (,,) Based on similar triangle: (,,) d - Ee (projection center) - = d = d -

Perspective Projection: Classical So (*,*) the projection of point, (,,) unto the near plane N is given as: Numerical eample: P ( *, *) = N, N P P Q. Where on the viewplane does P = (1,.5, -1.5) lie for a near plane at N = 1? P (*, *) = (1 1/1.5, 1.5/1.5) = (.666,.333)

Pseudodepth Classical perspective projection projects (,) coordinates, drops coordinates But we need to find closest object (depth testing) Keeping actual distance of P from ee is cumbersome and slow ( ) 2 2 2 P + P P dis tan ce = + Introduce pseudodepth: all we need is measure of which objects are further if two points project to same (,) P ( *, *, *) = N, N, P P P Choose a, b so that pseudodepth varies from 1 to 1 (canonical cube) P ap + b

Pseudodepth Solving: * = ap + b P For two conditions, * = -1 when P = -N and * = 1 when P = -F, we can set up two simultaneuous equations Solving: a = ( F + N) F N FN b = 2 F N

Homogenous Coordinates Would like to epress projection as 44 transform matri Previousl, homogeneous coordinates of the point P = (P,P,P) was (P,P,P,1) Introduce arbitrar scaling factor, w, so that P = (wp, wp, wp, w) (Note: w is non-ero) For eample, the point P = (2,4,6) can be epressed as (2,4,6,1) or (4,8,12,2) where w=2 or (6,12,18,3) where w = 3 So, to convert from homogeneous back to ordinar coordinates, divide all four terms b last component and discard 4 th term

Perspective Projection Same for. So we have: = d / - = d / - = -d Put in a matri form: OpenGL assumes d = 1, i.e. the image plane is at = -1 ( ) ( ) = 1 / ' ' ' 1 1 1 1 1 1 d d d d d

Perspective Projection We are not done et. Need to modif the projection matri to include a and b 1 = 1 a b w (1/-d) 1 We have alread solved a and b Z = 1 = -1

Perspective Projection Not done et. OpenGL also normalies the and ranges of the viewing frustum to [-1, 1] (translate and scale) So, as in ortho to arrive at final projection matri we translate b (ma + min)/2 in -(ma + min)/2 in Scale b: 2/(ma min) in 2/(ma min) in

Perspective Projection Final Projection Matri: 2N ma min 2N ma min ma+ min ma min ma+ min ma min ( F + N) F N 1 2FN F N glfrustum(min, ma, min, ma, N, F) N = near plane, F = far plane

Perspective Projection After perspective projection, viewing frustum is also projected into a canonical view volume (like in parallel projection) (1, 1, -1) (-1, -1, 1) Canonical View Volume

References Hill, chapter 7