©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Based on slides created by Edward Angel
Viewing and Projections
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Transformations and Projections (Some slides adapted from Amitabh Varshney)
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Introduction to 3D viewing 3D is just like taking a photograph!
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.
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Week 2 - Wednesday CS361.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented.
Fundamentals of Computer Graphics Part 5 Viewing prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Computer Graphics I, Fall 2010 Computer Viewing.
10/7/04© University of Wisconsin, CS559 Fall 2004 Last Time Transformations Homogeneous coordinates Directions Rotation Geometry 101 – Points, edges, triangles/polygons.
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.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Introduction to Computer Graphics: Viewing Transformations Rama C
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
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.
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.
OpenGL LAB III.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Rendering Pipeline Fall, 2015.
Viewing.
Computer Viewing.
Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin
Isaac Gang University of Mary Hardin-Baylor
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
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.
CSC461: Lecture 19 Computer Viewing
Viewing/Projections I Week 3, Fri Jan 25
Fundamentals of Computer Graphics Part 5 Viewing
Computer Graphics (Spring 2003)
Last Time Canonical view pipeline Projection Local Coordinate Space
University of New Mexico
Viewing (Projections)
Interactive Computer Graphics Viewing
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Learning Objectives Camera model –Describe external and internal camera parameters –Describe the geometry of perspective and orthogonal projections Camera Representation –Derive matrix representations of projections

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Learning Objectives OpenGL Cameras –Describe how cameras are represented in OpenGL –Initialize OpenGL projections –Be able to program a moving, variable zoom camera.

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Vocabulary Orthogonal projection Perspective projection Camera frame View-Reference Point (VRP) View-Plane Normal (VPN) View-Up Vector (VUP) Roll, Pitch, Yaw Frustum Field of view Depth (Z) buffer Culling

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Viewing Determine 2D view given: –World model (vertices and objects) –Camera model: position and orientation orthographic or perspective aspect ratio field of view  projection from 3D to 2D

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Pinhole Camera Projection of object vertices through single point (center of projection) Image formed on projection plane Distance from COP to plane is focal length ( d )

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE General Viewing Camera may be anywhere in scene Camera may be facing any direction Camera may vary focal length –even to infinity!

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE External Parameters Camera wrt. the rest of the world –position in world coordinates –rotation away from world frame Specified with a rigid-body transformation –translation –rotation

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Moving Camera (1) Moving camera  moving world  –camera transform is inverse of instance transform –view transform follows model transform ModelViewProject pq GL_MODELVIEWGL_PROJECTION

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Moving Camera (2) In matrix terms: –instance transform for model –inverse instance transform for camera –reverse order of pipeline –all combined in model-view matrix

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Moving Camera (3) Relative position, orientation determine view –e.g. move both camera and model together –same image as with no transform at all

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Moving Camera: OpenGL Camera position: –COP at ( p x,p y,p z ) –Rotated  degrees around axis ( a x,a y,a z ) glMatrixMode (GL_MODELVIEW); glLoadIdentity (); glRotatef (-theta, ax,ay,az); glTranslatef (-px,-py,-pz);

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Moving Camera: PHIGS PHIGS and GKS –separate view and model matrices –specification of camera frame in terms of VRP: view reference point VPN: view plane normal VUP: view up

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Moving Camera: LookAt Place camera at eye point Face towards at point Specify up direction glMatrixMode (GL_MODELVIEW); glLoadIdentity (); gluLookAt (ex,ey,ez, ax,ay,az, ux,uy,uz);

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Projections Reduce from 3D space to 2D –p is 3D –q is 2D input to renderer produced by projection and division Model View ProjectClip p q GL_MODELVIEWGL_PROJECTION Render

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Pinhole Algebra Project through origin Project onto line z = d  division by z/d (foreshortening)

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Homogeneous Projection Allow points to exist in unnormalized form –final coordinate allowed to vary (  0) –to normalize we must divide by w –unnormalized form temporary

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Perspective Projection Matrix creates unnormalized points –normalize by division

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Orthogonal Projection Aligned with z axis into screen –project by collapsing to z = 0

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE View Frustum(1) Frustum: Volume projected onto screen –distance varies from near to far –( left,right ) and ( bottom,top )

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Canonical View Volume Both perspective and ortho collapse visible space to a canonical view volume –x, y, and z all vary from -1 to 1

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE View Frustum(2) Transform frustrum to –canonical view volume –x, y, and z all vary from -1 to 1

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE View Frustum(3) Examples:

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE View Frustum: OpenGL Specify frustum by providing: –[ left,right ] and [ bottom,top ] bounds –[ near,far ] distance range glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum (left,right, bottom,top, near,far); glMatrixMode (GL_MODELVIEW); /* Define external camera parameters */

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Orthographic Projection(1) Project along z axis (not through point) –distance varies from near to far –( left,right ) and ( bottom,top )

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Orthographic Projection(2) Transform box to –canonical view volume –x, y, and z all vary from -1 to 1

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Canonical Clipping Volume Canonical view volume determines what will be drawn on screen Throw away everything outside of CVV Must draw partial objects at edges

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE Z-Buffer Algorithm From CCV (part of rasterization): Z values retain relative depth Clear Z buffer when draw buffer cleared Interpolate Z value of every polygon pixel If Z < current Z at that pixel: –Draw pixel –Update current Z at that pixel Otherwise ignore it.

©2005, Lee Iverson Lee Iverson UBC Dept. of ECE New Pipeline Transform by model-view Project to canonical view volume Clip primitives against CVV Rasterize into depth and frame buffers Model View Project CVV Clip p q GL_MODELVIEWGL_PROJECTION Render Z+FB