Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
1 Computer Graphics Chapter 8 3D Transformations.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Viewing and Projections
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
CS485/685 Computer Vision Prof. George Bebis
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.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
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.
Transformation & Projection Feng Yu Proseminar Computer Graphics :
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
Geometric transformations The Pipeline
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.
2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented.
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.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
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.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
University of North Carolina at Greensboro
CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.
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.
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
©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,
Introduction to Computer Graphics: Viewing Transformations Rama C
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
A Photograph of two papers
Viewing and Projection
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
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
A Photograph of two papers The Model: 2 papers – 8cm x 8cm and 5cm x 5cm The Camera – Simple pinhole – No focusing capability The Scene – Arrangements.
University of North Carolina at Greensboro
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
CENG 477 Introduction to Computer Graphics
A Photograph of two papers
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Computer Graphics (Spring 2003)
Projection in 3-D Glenn G. Chappell
Last Time Canonical view pipeline Projection Local Coordinate Space
Viewing (Projections)
Viewing (Projections)
Presentation transcript:

Viewing and Projection

The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation

World coordinate others Transformation Pipeline Projection Matrix World->Eye Local coordinate Eye coordinate Local->World ModelView Matrix ModelView Matrix Clip coordinate Screen coordinate

Projection The projection transforms a point from a high- dimensional space to a low-dimensional space. In 3D, the projection means mapping a 3D point onto a 2D projection plane (or called image plane). There are two basic projection types: Parallel: orthographic, oblique Perspective

Orthographic Projection Image Plane Direction of Projection z=k z-axis

Orthographic Projection

Oblique Projection Image Plane Direction of Projection

Properties of Parallel Projection Definition: projection directions are parallel. Doesn’t look real. Can preserve parallel lines Projection Parallel in 3DParallel in 2D

Properties of Parallel Projection Definition: projection directions are parallel. Doesn’t look real. Can preserve parallel lines Can preserve ratios Projection

Properties of Parallel Projection Definition: projection directions are parallel. Doesn’t look real. Can preserve parallel lines Can preserve ratios CANNOT preserve angles Projection

Properties of Parallel Projection Definition: projection directions are parallel. Doesn’t look real. Can preserve parallel lines Can preserve ratios CANNOT preserve angles Often used in CAD, architecture drawings, when images can be used for measurement.

Properties of Parallel Projection No foreshortening Image Plane

Perspective Projection Perspective projection has foreshortening: Image Plane Center of Projection

Perspective Projection Images are mapped onto the image plane in different ways: Image Plane Center of Projection An image (640*640)

Perspective Projection Images are mapped onto the image plane in different ways: Image Plane Center of Projection An image (640*640)

Perspective Projection Angle of view tells us the mapping from the image to the image plane: Image Plane Center of Projection Angle of view Field of view

Perspective Projection Not everything will be displayed. Image Plane Center of Projection Near PlaneFar Plane Frustum

Perspective Projection The frustum of perspective projection looks like: Center of Projection Image Plane Near Plane

Ortho Projection What’s the frustum of orthographic projection? Image Plane NearFar

In general, the homogeneous coordinate system is define as: For example, Homogenous Coordinates In 3D In homogeneous space

Both homogenous vectors and matrices are scalable: Homogenous Coordinates

Perspective Projection Derivation: Image Plane Z Axis XY Plane

Perspective Projection Derivation: Image Plane Z Axis XY Plane

Perspective Matrix Derivation: How? The z axis now becomes useless…

OpenGL Perspective Matrix In practice, OpenGL uses the z axis for depth test. Its matrix looks like this: The depth value now can be used for depth test. We will discuss this in more details later...

Vanishing Point Given a ray: Its projection:

Vanishing Point When t goes to infinity: What if there is another ray: Parallel lines meet at the vanishing point.

Properties of Perspective Projection Lines are mapped to lines. Parallel lines may not remain parallel. Instead, they may meet at the vanishing point. Ratios are not preserved. It has foreshortening effects. So it looks real. Distances cannot be directly measured, as in parallel projection.

Basic OpenGL Projection Everything will be considered in the eye space: Geometry objects have been transformed into the eye coordinate system using the GL_MODELVIEW matrix. You define the projection matrix in GL_PROJECTION, also in the eye space. OpenGL always assume that the viewing direction is the –z direction. OpenGL automatically processes each vertex using GL_PROJECTION: After projection, the frustum is converted into a canonical view volume ( [-1, 1] in all coordinates)

OpenGL Orthographic Projection glOrtho(left, right, bottom, top, near, far) (left, bottom, near) X rangeY rangeZ range (right, top, far) (-1, -1, -1) (1, 1, 1)

OpenGL Orthographic Projection glOrtho(l, r, b, t, n, f) Translation so that the center is the origin. Scaling so that the size becomes (2, 2, 2).

OpenGL Perspective Projection glFrustum(left, right, bottom, top, near, far) Center of Projection Near Plane (Image Plane) Far Plane Frustum (left, right, bottom, top) may not be centered along the axis Always positive, although it’s facing the –z direction

OpenGL Perspective Projection gluPerspective(fov, aspect_ratio, near, far) Center of Projection Near Plane (Image Plane) Far Plane Frustum fov ratio=image_width/image_height top: near*ctan(fov/2) right: near*ratio*ctan(fov/2) Always positive, although it’s facing the –z direction

OpenGL Perspective Projection glFrustum(…) is less useful than gluPerspective(...). But we can still use it for demonstration purpose next.

OpenGL Perspective Projection Projection

OpenGL Perspective Projection Projection in (-1, 1) in (-n, -f), why???

OpenGL Perspective Projection

Projection (l/n, b/n, -1) (r/n, t/n, 1)

OpenGL Perspective Projection Transform (l/n, b/n, -1) (r/n, t/n, 1) (-1, -1, -1) (1, 1, 1) TranslationScaling

OpenGL Perspective Projection Projection (-1, -1, -1) (1, 1, 1) Original ProjectionTransformation

What happens after projection? Clipping Viewport transformation Rasterization clipping (-1, -1) (1, 1) viewport (0, 0) (800, 800) rasterize

Depth Test Before rasterization, all processes are done based on vertices. The z coordinate at each vertex is transformed into a new z value (or called the depth value). During rasterization, the z value of each pixel is interpolated from vertices. The z value then stored in the depth buffer, for occlusion tests. (smaller z means closer).

Depth Test The depth buffer is part of the frame buffer: To enable or disable the depth buffer: Without the depth test, the occlusion is determined by the drawing order. glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); glEnable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);

Common Issues When you set up the perspective matrix: Near ( n ) cannot be zero! f : n cannot be too large! (far cannot be too large, or near cannot be too small.) Why?