Viewing and Projection

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

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.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Projection Matrices Ed Angel
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 14 Chapter 14: The Camera.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
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.
Introduction to OpenGL Pipeline From Programmer View Tong-Yee Lee.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics (fall 2009)
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
1 E. Angel and D. Shreiner : Interactive Computer Graphics 6E © Addison-Wesley 2012 Classical Viewing Sai-Keung Wong ( 黃世強 ) Computer Science National.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Computer Graphics I, Fall 2010 Computer Viewing.
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
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.
University of North Carolina at Greensboro
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
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Geometric Objects and Transformations. Graphics Pipeline How can we render a triangle? High-level description: – Represent the 3D geometry – Transform.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Viewing and Projection
CS5500 Computer Graphics April 23, Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
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.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing.
University of North Carolina at Greensboro
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
3D Computer Graphics (3080/GV10) Week 5-6 Tutorial 3
CSCE 441 Computer Graphics 3-D Viewing
2D Viewing Pipeline.
Projections and Normalization
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Models and Architectures
Isaac Gang University of Mary Hardin-Baylor
Introduction to Computer Graphics with WebGL
Projections and Hidden Surface Removal
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
University of New Mexico
Viewing (Projections)
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Viewing and Projection Images were taken from the book: “Interactive Computer Graphics” by Angel and Shreiner

Graphics Pipeline Consider our program as a pipeline At each step, we manipulate the data Our goal is to output the data in screen coordinates חלק מהשלבים יכולים להיות טריוויאליים – כלומר מטריצת היחידה

Graphics Pipeline Object coordinates Camera coordinates Clip Vertices 𝑃 Projection transformation 𝑇 𝑚 𝑇 𝑤 𝑇 𝑐 −1 Model-view transformation

Positioning the Camera Initially, the object and camera frames are the same (the identity matrix) The camera is located at the origin and points in the negative 𝑧 direction We place the camera through the Model-view matrix המצלמה והאובייקט נמצאים שניהם בראשית מערכת הצירים, ולכן צריך להזיז את המצלמה/האובייקט כדאי שנראה משהו

The LookAt Function eye: The position of the camera mat4 LookAt(vec4& eye, vec4& at, vec4& up) eye: The position of the camera at: The position the camera looks at Up: The upside (𝑦) direction of the camera

The LookAt Function Translate the camera to eye and change frame mat4 LookAt(vec4& eye, vec4& at, vec4& up ) { vec4 n = normalize(eye - at); vec4 u = normalize(cross(up,n)); vec4 v = normalize(cross(n,u)); vec4 t = vec4(0.0, 0.0, 0.0, 1.0); mat4 c = mat4(u, v, n, t); return c * Translate( -eye ); }

Viewing Perspective vs. Orthographic DOP COP אפשר להסתכל על הטלה אורתוגרפית כמקרה הגבול של הטלה פרספקטיבית – מרכז ההטלה עובר לאינסוף

Orthogonal Projections How can we construct 𝑃? 𝑥 𝑝 =𝑥, 𝑦 𝑝 =𝑦, 𝑧 𝑝 =0 In matrix form: 𝑥 𝑝 , 𝑦 𝑝 , 𝑧 𝑝 ,1 𝑇 =𝑀I 𝑥,𝑦,𝑧,1 𝑇

Orthogonal Projections How can we construct 𝑃=𝑀I? 𝑥 𝑝 , 𝑦 𝑝 , 𝑧 𝑝 ,1 𝑇 =𝑀I 𝑥,𝑦,𝑧,1 𝑇 Where I is the identity matrix and 𝑀= 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1

Orthogonal Projections Take a finite portion of the projection plane The default view volume is a cube with sides of length 2 centered at the origin Namely, the planes 𝑥=±1, 𝑦=±1, 𝑧=±1, determine the clipping volume

Orthogonal Viewing We can specify a different view volume mat4 Ortho(left, right, bottom, top, near, far) Values are in Camera coordinates

Projection Normalization The graphics card has a fixed viewing volume Thus, we transform our viewing volume into the canonical one

Projection Normalization How to normalize the viewing volume? Translate: 𝑇 − 𝑟𝑖𝑔ℎ𝑡+𝑙𝑒𝑓𝑡 2 ,− 𝑏𝑜𝑡𝑡𝑜𝑚+𝑡𝑜𝑝 2 , 𝑛𝑒𝑎𝑟+𝑓𝑎𝑟 2 Scale: 𝑆 2 𝑟𝑖𝑔ℎ𝑡−𝑙𝑒𝑓𝑡 , 2 𝑡𝑜𝑝−𝑏𝑜𝑡𝑡𝑜𝑚 , 2 𝑛𝑒𝑎𝑟−𝑓𝑎𝑟 In matrix form: לשים לב לסימנים! 𝑆𝑇= 2 𝑟𝑖𝑔ℎ𝑡−𝑙𝑒𝑓𝑡 0 0 0 0 2 𝑡𝑜𝑝−𝑏𝑜𝑡𝑡𝑜𝑚 0 0 0 0 − 2 𝑓𝑎𝑟−𝑛𝑒𝑎𝑟 0 − 𝑙𝑒𝑓𝑡+𝑟𝑖𝑔ℎ𝑡 𝑟𝑖𝑔ℎ𝑡−𝑙𝑒𝑓𝑡 − 𝑡𝑜𝑝+𝑏𝑜𝑡𝑡𝑜𝑚 𝑡𝑜𝑝−𝑏𝑜𝑡𝑡𝑜𝑚 − 𝑓𝑎𝑟+𝑛𝑒𝑎𝑟 𝑓𝑎𝑟−𝑛𝑒𝑎𝑟 1

Summary: Orthogonal Projection 𝑃 Translate Scale Normalize 𝑇 𝑆 𝑀 Orthographic projection Project Projection transformation

Perspective Projections How can we construct 𝑃 for 𝑑=−1? 𝑥 𝑝 = 𝑥 𝑧/−1 , 𝑦 𝑝 = 𝑦 𝑧/−1 , 𝑧 𝑝 =−1

Perspective Projections How can we construct 𝑃? 𝑃= 1 0 0 0 0 1 0 0 0 0 1 −1 0 0 0 0 Perspective division לחשב על הלוח, להראות שמקבלים מה שרוצים אחרי חלוקה בקומפוננטה הרביעית

Perspective Projections 𝑃 corresponds to a frustum with COP at the origin, 90 degrees FOV and bounded by the planes 𝑥=±𝑧, 𝑦=±𝑧.

Perspective Viewing We can specify a different viewing frustum mat4 Frustum(left, right, bottom, top, near, far)

Perspective Viewing We can specify a different viewing frustum mat4 Perspective(fovy, aspect, near, far) aspect = 𝑤/ℎ

Perspective Normalization 𝑃 is independent of the far clipping plane We take 𝑃= 1 0 0 0 0 1 0 0 0 0 𝛼 −1 0 0 𝛽 0 Thus, 𝑥,𝑦,𝑧,1 T goes (after division) to − 𝑥 𝑧 ,− 𝑦 𝑧 ,−𝛼− 𝛽 𝑧 T

Perspective Normalization We choose 𝛼=− 𝑛𝑒𝑎𝑟+𝑓𝑎𝑟 𝑛𝑒𝑎𝑟−𝑓𝑎𝑟 , 𝛽=− 2∗𝑛𝑒𝑎𝑟∗𝑓𝑎𝑟 𝑛𝑒𝑎𝑟−𝑓𝑎𝑟 Then, our frustum is transformed into the default viewing volume (i.e., bounded by the planes 𝑥=±1, 𝑦=±1, 𝑧=±1)

Viewport Transformation How to transform into screen coordinates? 𝑟= 𝑤 2 𝑥+1 , 𝑠= ℎ 2 𝑦+1 .

Complete Graphics Pipeline Object coordinates Camera coordinates Clip coordinates Normalized device coordinates Screen coordinates Model-view Projection Perspective division Viewport 𝑉 𝑉

Suggested Readings Interactive Computer Graphics, Chapter 4