Introduction to Computer Graphics with WebGL

Slides:



Advertisements
Similar presentations
Transformations Ed Angel Professor Emeritus of Computer Science
Advertisements

1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Projection Matrices modified by Ray Wisman Ed Angel Professor of Computer.
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
Objectives Derive the perspective projection matrices used for standard OpenGL projections Derive the perspective projection matrices used for standard.
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)
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
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.
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.
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
Viewing and Projection
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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 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.
Introduction to Computer Graphics with WebGL
Viewing.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Representation Ed Angel Professor Emeritus of Computer Science,
CSC461: Lecture 20 Parallel Projections in OpenGL
Introduction to Computer Graphics with WebGL
Projections and Normalization
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Projections and Hidden Surface Removal
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Chap 3 Viewing Pipeline Reading:
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
University of New Mexico
Introduction to Computer Graphics with WebGL
Transformations Ed Angel Professor Emeritus of Computer Science
Representation Ed Angel Professor Emeritus of Computer Science,
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Viewing and Projection
Representation Ed Angel
Viewing and Projection
Presentation transcript:

Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Perspective Projection Matrices Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Objectives Derive the perspective projection matrices used for standard WebGL projections Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Simple Perspective Consider a simple perspective with the COP at the origin, the near clipping plane at z = -1, and a 90 degree field of view determined by the planes x = z, y = z Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Perspective Matrices Simple projection matrix in homogeneous coordinates Note that this matrix is independent of the far clipping plane M = Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Generalization N = after perspective division, the point (x, y, z, 1) goes to x’’ = x/z y’’ = y/z Z’’ = -(a+b/z) which projects orthogonally to the desired point regardless of a and b Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Picking a and b If we pick a = b = the near plane is mapped to z = -1 the far plane is mapped to z =1 and the sides are mapped to x =  1, y =  1 Hence the new clipping volume is the default clipping volume Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Normalization Transformation distorted object projects correctly original clipping volume original object new clipping volume Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Normalization and Hidden-Surface Removal Although our selection of the form of the perspective matrices may appear somewhat arbitrary, it was chosen so that if z1 > z2 in the original clipping volume then the for the transformed points z1’ > z2’ Thus hidden surface removal 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 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

WebGL Perspective gl.frustum allows for an unsymmetric viewing frustum (although gl.perspective does not) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

OpenGL Perspective Matrix The normalization in Frustum requires an initial shear to form a right viewing pyramid, followed by a scaling to get the normalized perspective volume. Finally, the perspective matrix results in needing only a final orthogonal transformation P = NSH our previously defined perspective matrix shear and scale Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Why do we do it this way? 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 We simplify clipping Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Perspective Matrices frustum perspective Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015