CSC461: Lecture 20 Parallel Projections in OpenGL

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

1 View Shandong University Software College Instructor: Zhou Yuanfeng
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 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
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.
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
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.
Chapter 5 Viewing.
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.
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.
Computer Graphics I, Fall 2010 Computer Viewing.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II.
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.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
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.
Computer Graphics I, Fall 2010 Implementation II.
Viewing and Projection
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Three Dimensional Viewing
Visible Surface Detection
Viewing.
Computer Graphics Implementation II
Computer Graphics - Chapter 5 Viewing
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
Unit 4 3D Viewing Pipeline Part - 2
Projections and Normalization
Introduction to Computer Graphics with WebGL
CSC461: Lecture 19 Computer Viewing
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Viewing Chapter 5.
Fundamentals of Computer Graphics Part 5 Viewing
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Isaac Gang University of Mary Hardin-Baylor
Projections and Hidden Surface Removal
Last Time Canonical view pipeline Projection Local Coordinate Space
Introduction to Computer Graphics with WebGL
Chap 3 Viewing Pipeline Reading:
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Viewing (Projections)
University of New Mexico
Viewing (Projections)
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Viewing and Projection
Viewing and Projection
Presentation transcript:

CSC461: Lecture 20 Parallel Projections in OpenGL Objectives Introduce OpenGL viewing functions Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection normalization Introduce hidden-surface removal algorithms

OpenGL Orthogonal Viewing glOrtho(xmin,xmax,ymin,ymax,near,far) glOrtho(left,right,bottom,top,near,far) near and far measured from camera

OpenGL Perspective Viewing The function: glFrustum(xmin,xmax,ymin,ymax,near,far) OpenGL figures out the transformation matrix and perspective division With glFrustum it is often difficult to get the desired view

Using Field of View (fov) The function gluPerpective(fovy, aspect, near, far) The angle fov is the angle between the top and bottom planes of the clipping volume in the y direction The aspect ratio = width/height Often provides a better interface aspect = w/h front plane

Normalization 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

Pipeline View model-view transformation projection perspective division clipping nonsingular 4D  3D against default cube 3D  2D

Notes We stay in four-dimensional homogeneous coordinates through both the model-view and projection transformations Both these transformations are nonsingular Default to identity matrices (orthogonal view) Normalization lets us clip against simple cube regardless of type of projection Delay final projection until end Important for hidden-surface removal to retain depth information as long as possible

Orthogonal Normalization glOrtho(left,right,bottom,top,near,far) Normalization  find transformation to convert specified clipping volume to default  canonical view volume Default volume: centered at the origin with the length of 2

Orthogonal Matrix Scale to have sides of length 2 Two steps Move center to origin -- translation T(-(left+right)/2, -(bottom+top)/2,(near+far)/2)) Scale to have sides of length 2 S(2/(left-right),2/(top-bottom),2/(near-far)) P = ST =

Final Projection Project on the projection plane Set z =0 Equivalent to the homogeneous coordinate transformation Hence, general orthogonal projection in 4D is Morth = P = MorthST

Oblique Projections OpenGL only supports orthogonal projection function, not general parallel projections such as oblique projections However if we look at the example of the cube it appears that the cube has been sheared Oblique Projection = Shear + Orthogonal Projection Concatenate shear and orthographic viewings

General Shear top view side view

Shear Matrix xp = x – z cotanθ, yp = y – z cotanø, zp = 0 xy shear (z values unchanged) Projection matrix: General case: Where S and T are the same as orthogonal projection H(q,f) = P = Morth H(q,f) P = Morth STH(q,f)

Equivalency

Effect on Clipping The projection matrix P = STH transforms the original clipping volume to the default clipping volume top view DOP near plane far plane object clipping volume z = -1 z = 1 x = -1 x = 1 distorted object (projects correctly)

Surface Display All surfaces should be specified Two approaches to determine which surfaces should be displayed Remove those surfaces that should not be visible Hidden-surface-removal Find those surfaces that are visible  Visible-surface Many algorithms exist OpenGL uses the z-buffer algorithm (a hidden-surface-removal algorithm)

Hidden-Surface-Removal Two categories of hidden-surface-removal algorithms Object-space algorithms: order the surfaces in the scene such that drawing surfaces in a particular order provides the correct image Example: back-face first for a cube Not easy to sort the surfaces Image-space algorithms As part of the projection process Seek to determine the relationship among object points on each projector The z-buffer algorithm

The z-buffer Algorithm A projector from the COP passes through two surfaces The closest object determines the color placed in the color buffer at the corresponding location For each pixel in the color buffer, keep the depth information in the z-buffer When a new color is projected to the pixel, check its z-value to determine if the color should be replaced The depth is the distance from the object to the origin – the viewer

Using The z-buffer Initialize the z-buffer – to a value that corresponds to the farthest distance from the viewer gluInitDisplayMode(GLUT_RGB|GLUT_DEPTH) Enable the z-buffer glEnable(GL_DEPTH_TEST) Clear the z-buffer glClear(GL_DEPTH_BUFFER_BIT)

Culling Remove all the faces pointing away from the viewer and only render the ones facing the viewer Enable culling glEnable(GL_CULL) Only works for convex objects, e.g. cube Combination of culling and the z-buffer