Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
Three Dimensional Viewing
1 Computer Graphics Chapter 8 3D Transformations.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Camera Models A camera is a mapping between the 3D world and a 2D image The principal camera of interest is central projection.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Based on slides created by Edward Angel
Projection Matrices Ed Angel
Lecture 3 – Transformation And Coordinate Systems
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Introduction to 3D viewing 3D is just like taking a photograph!
COMP 175: Computer Graphics March 24, 2015
Viewing and Projections
Computer Graphics (fall 2009)
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
Advanced Computer Graphics Three Dimensional Viewing
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner : Interactive Computer Graphics 6E © Addison-Wesley 2012 Classical Viewing Sai-Keung Wong ( 黃世強 ) Computer Science National.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 Computer Graphics Three-Dimensional Graphics III.
CS-378: Game Technology Lecture #2.1: Projection Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Viewing and Projection
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Modeling and The Viewing Pipeline Jian Huang CS594 The material in this set of slides have referenced slides from Ohio State, Minnesota and MIT.
OpenGL LAB III.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Outline 3D Viewing Required readings: HB 10-1 to 10-10
CSCE 441 Computer Graphics 3-D Viewing
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
CENG 477 Introduction to Computer Graphics
Projections and Normalization
OpenGL 2D Viewing Pipeline
Isaac Gang University of Mary Hardin-Baylor
Last Time Canonical view pipeline Projection Local Coordinate Space
Chap 3 Viewing Pipeline Reading:
Viewing (Projections)
THREE-DIMENSIONAL VIEWING II
Presentation transcript:

Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia Engineering

ILE5014 Computer Graphics 10F 2 Getting Geometry on the Screen Given geometry in the world coordinate system, how do we get it to the display? Transform to camera coordinate system Transform (warp) into canonical view volume Clip Project to display coordinates Rasterize

ILE5014 Computer Graphics 10F 3 Vertex Transformation Pipeline

ILE5014 Computer Graphics 10F 4 Vertex Transformation Pipeline glMatrixMode(GL_MODELVIEW) glMatrixMode(GL_PROJECTION) glViewport(…)

ILE5014 Computer Graphics 10F 5 OpenGL Transformation Overview glMatrixMode(GL_MODELVIEW) gluLookAt(…) glMatrixMode(GL_PROJECTION) glFrustrum(…) gluPerspective(…) glOrtho(…) glViewport(x,y,width,height)

ILE5014 Computer Graphics 10F 6 Viewing and Projection Our eyes collapse 3-D world to 2-D retinal image (brain then has to reconstruct 3D) In CG, this process occurs by projection Projection has two parts: – Viewing transformations: camera position and direction – Perspective/orthographic transformation: reduces 3-D to 2-D Use homogeneous transformations

ILE5014 Computer Graphics 10F 7 Pinhole Optics Stand at point P, and look through the hole—anything within the cone is visible, and nothing else is Reduce the hole to a point - the cone becomes a ray Pin hole is the focal point, eye point or center of projection P F

ILE5014 Computer Graphics 10F 8 Perspective Projection of a Point View plane or image plane - a plane behind the pinhole on which the image is formed – sees anything on the line (ray) through the pinhole F – a point W projects along the ray through F to appear at I (intersection of WF with image plane) F Image World I W

ILE5014 Computer Graphics 10F 9 Image Formation Projecting a shape – project each point onto the image plane – lines are projected by projecting end points only F Image World F Image World I W Note: Since we don't want the image to be inverted, from now on we'll put F behind the image plane. Camera lens

ILE5014 Computer Graphics 10F 10 Orthographic Projection When the focal point is at infinity the rays are parallel and orthogonal to the image plane When xy-plane is the image plane (x,y,z) -> (x,y,0) front orthographic view Image World F

ILE5014 Computer Graphics 10F 11 Multiview Orthographic Projection Good model for CAD and architecture. No perspective effects. front side top

ILE5014 Computer Graphics 10F 12 Assume view transformation is done Let’s start with a simple case where the camera is put at the origin, and looks along the negative z-axis! Simple “canonical” views: orthographic projectionperspective projection

ILE5014 Computer Graphics 10F 13 Orthographic Viewing Cube (l,b,n) = (left, bottom, near) (r,t,f) = (right, top, far)

ILE5014 Computer Graphics 10F 14 Orthographic Projection Map orthographic viewing cube to the canonical view volume 3D window transformation [l, r] x [b, t] x [f, n]  [-1, 1]x[-1, 1]x[-1,1]

ILE5014 Computer Graphics 10F 15 Orthographic Projection (cont.) 3D window transform (last class) [l, r] x [b, t] x [f, n]  [-1, 1]x[-1, 1]x[-1,1] z canonical is ignored

ILE5014 Computer Graphics 10F 16 Map Image Plane to Screen (1,1) (-1,-1) Image Plane Screen x y y x (n x, n y )

ILE5014 Computer Graphics 10F 17 Map Image Plane to Screen If y-axis of screen coord. points downward [-1,1] x [-1, 1]  [-0.5, n x -0.5] x [ n y -0.5, -0.5] reflectionscaletranslation

ILE5014 Computer Graphics 10F 18 Orthographic Projection Matrix Put everything together

ILE5014 Computer Graphics 10F 19 Arbitrary Viewing Position What if we want the camera somewhere other than the canonical location? Alternative #1: derive a general projection matrix. (hard) Alternative #2: transform the world so that the camera is in canonical position and orientation (much simpler)

ILE5014 Computer Graphics 10F 20 Camera Control Values All we need is a single translation and angle- axis rotation (orientation), but... Good animation requires good camera control--we need better control knobs Translation knob - move to the lookfrom point Orientation can be specified in several ways: – specify camera rotations – specify a lookat point (solve for camera rotations)

ILE5014 Computer Graphics 10F 21 A Popular View Specification Approach Focal length, image size/shape and clipping planes are in the perspective transformation In addition: – lookfrom: where the focal point (camera) is – lookat:the world point to be centered in the image Also specify camera orientation about the lookfrom- lookfat axis

ILE5014 Computer Graphics 10F 22 Implementing lookat/lookfrom/vup viewing scheme Translate by lookfrom, bring focal point to origin Rotate lookfrom - lookat to the z-axis with matrix R: – w = (lookfrom-lookat) (normalized) and z = [0,0,1] – rotation axis: a = (w × z)/|w × z| – rotation angle: cosθ = wz and sinθ = |w × z| Rotate about z-axis to get vup parallel to the y-axis

ILE5014 Computer Graphics 10F 23 It's not so complicated… Translate LOOKFROM to the origin Multiply by the projection matrix and everything will be in the canonical camera position Rotate the view vector (lookfrom - lookat) onto the z-axis. Rotate about z to bring vup to y-axis START HERE w lookfrom vup x y z y x x x y y z z z

ILE5014 Computer Graphics 10F 24 Translate Camera Frame Let e=(e x, e y, e z ) be the “lookfrom” position Translate LOOKFROM to the origin START HERE w lookfrom vup x y z x y z

ILE5014 Computer Graphics 10F 25 Rotate Camera Frame You can derive these two rotation matrices based on what you learned in the last class Translate LOOKFROM to the origin Rotate the view vector (lookat -lookfrom) onto the z-axis. Rotate about z to bring vup to y-axis x y z y x x y z z

ILE5014 Computer Graphics 10F 26 Rotate Camera Frame (cont.) Alternatively, we can view these two rotations as a single rotation that aligns u-v- w -axes to x-y-z -axes! x y z w v w : lookat – lookfrom v : view up direction u = v x w

ILE5014 Computer Graphics 10F 27 Viewing Transformation Put translation and rotation together

ILE5014 Computer Graphics 10F 28 Recall Global vs. Local Coordinate… x, y, u, v, o, e are all vectors in global system In global coord. ( x p,y p ) In local coord. ( u p,v p )

ILE5014 Computer Graphics 10F 29 Think about 3D case …. Given two coordinate frames, how do you represent a vector specified in one frame in the other frame? e u v w X Y Z P ? ?

ILE5014 Computer Graphics 10F 30 Viewing Transformation Put translation and rotation together world coordinate local coordinate e u v w X Y Z P

ILE5014 Computer Graphics 10F 31 Orthographic Projection Summary Given 3D geometry (a set of points a ) Compute view transformation M v Compute orthographic projection M o Compute M = M o M v For each point a i, compute p = Ma i

ILE5014 Computer Graphics 10F 32 A Simple Perspective Camera Canonical case: – camera looks along the z-axis (toward negative z-axis) – focal point is the origin – image plane is parallel to the xy-plane at distance d – We call d the focal length, mainly for historical reasons Image plane Center of projection

ILE5014 Computer Graphics 10F 33 Geometry Eq. for Perspective Projection Diagram shows y-coordinate, x-coordinate is similar Point ( x,y,z ) projects to view plane e g z y ysys d e : eye position g : gaze direction

ILE5014 Computer Graphics 10F 34 Perspective Projection Matrix Projection using homogeneous coordinates: – transform ( x,y,z ) to 2-D image point: – discard third coordinate – apply viewport transformation to obtain physical pixel coordinates Divide by 4 th coordinate (the “w” coordinate)

ILE5014 Computer Graphics 10F 35 View Volume Pyramid in space defined by focal point and window in the image plane (assume window mapped to viewport) Defines visible region of space Pyramid edges are clipping planes

ILE5014 Computer Graphics 10F 36 View Frustum Truncated pyramid with near and far clipping planes – Why far plane? Allows z to be scaled to a limited fixed- point value (z-buffering) – Why near plane? Prevent points behind the camera being seen

ILE5014 Computer Graphics 10F 37 Why Canonical View Volume? Rather than derive a different projection matrix for each type of projection, we can convert all projections to orthogonal projections with the default view volume This strategy allows us to use standard transformations in the pipeline and makes for efficient clipping

ILE5014 Computer Graphics 10F 38 Why Canonical (normalized) View Volume? Normalization allows for a single pipeline for both perspective and orthogonal viewing We stay in four dimensional homogeneous coordinates as long as possible to retain three-dimensional information needed for hidden-surface removal and shading Normalization let us clip against a simple cube regardless of type of projection

ILE5014 Computer Graphics 10F 39 Taking Clipping into Account After the view transformation, a simple projection and viewport transformation can generate screen coordinate. However, projecting all vertices are usually unnecessary. Clipping with 3D volume. Associating projection with clipping and view volume normalization.

ILE5014 Computer Graphics 10F 40 Normalizing the Viewing Frustum Solution: transform frustum to a cube before clipping Converts perspective frustum to orthographic frustum This is yet another homogeneous transform!

ILE5014 Computer Graphics 10F 41 Map Perspective View Volume to Orthographic View Volume We already know how to map orthographic view volume to canonical view volume Set view plane at the near plane

ILE5014 Computer Graphics 10F 42 Map Perspective View Volume to Orthographic View Volume Map [x,y,n] to [x, y, n] Map [xf/n,yf/n,f] to [x, y, f]

ILE5014 Computer Graphics 10F 43 Projection Matrix is not unique M p is not unique

ILE5014 Computer Graphics 10F 44 Properties of Perspective Transform Lines and planes are preserved Parallel lines (not parallel to the projection plan) won’t be parallel after transform – vanishing point: parallel lines intersect at the vanishing point vanishing point

ILE5014 Computer Graphics 10F 45 Orthographic Projection Summary Given 3D geometry (a set of points a ) Compute view transformation M v Compute orthographic projection M o Compute M = M o M v For each point a i, compute p = Ma i

ILE5014 Computer Graphics 10F 46 Perspective Projection Summary Given 3D geometry (a set of points a ) Compute view transformation M v Map perspective to orthographic M p Compute orthographic projection M o Compute M = M o M p M v For each point a i, compute p = Ma i

ILE5014 Computer Graphics 10F 47 Orthographic projection Perspective projection Perspective Projection with hidden lines removed