Viewing and Projections

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.
Defining the Viewing Coordinate System
Three Dimensional Viewing
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Viewing and Projections
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
Announcements. Projection Today’s Readings Nalwa 2.1.
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 14 Chapter 14: The Camera.
Lecture 12: Projection CS4670: Computer Vision Noah Snavely “The School of Athens,” Raphael.
The Pinhole Camera Model
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.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Transformations Dr. Amy Zhang.
Advanced Computer Graphics Three Dimensional Viewing
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.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Bing-Yu Chen National Taiwan University.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and 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.
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.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
A Photograph of two papers
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.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
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.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
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.
Lecture 18: Cameras CS4670 / 5670: Computer Vision KavitaBala Source: S. Lazebnik.
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
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Three Dimensional Viewing
Rendering Pipeline Fall, 2015.
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
3D Viewing cgvr.korea.ac.kr.
CSCE 441 Computer Graphics 3-D Viewing
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.
CENG 477 Introduction to Computer Graphics
Viewing/Projections I Week 3, Fri Jan 25
Three Dimensional Viewing
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Lecture 13: Cameras and geometry
Announcements Midterm out today Project 1 demos.
Chapter V Vertex Processing
Last Time Canonical view pipeline Projection Local Coordinate Space
Chap 3 Viewing Pipeline Reading:
Viewing (Projections)
Viewing (Projections)
Presentation transcript:

Viewing and Projections Dr. Amy Zhang

Reading Hill, Chapter 5 and 7 Red Book, Chapter 3, “Viewing”

3D Graphics Pipeline The big picture…

Outline Camera Models Viewing Transformation Projection Matrix OpenGL Transformation Pipeline

Cameras Cameras have an optical system: Filters Lenses Aperture The projection surface may be flat or curved, oriented at various angles with respect to the incoming light. Examples: A camera or the eye.

Camera Obscura The first cameras – a dark box with a small hole in it

The Pinhole Camera An abstract camera model Models the geometry of perspective projection Used in most of computer graphics

Pinhole Optics

Perspective

Perspective Derivation Consider the projection of a point onto the projection plane:

By similar triangles we can compute how much the x and y-coordinates are scaled Looking down y axis:

We get: This is clearly a non-linear transformation BUT: We can split it into a linear part followed by a nonlinear part

Homogeneous Coordinates Remember homogeneous coordinates: To get a homogeneous point we divide all the coordinates by w: This is called the perspective divide

Perspective Projections We can now rewrite the perspective projection as a linear transformation: After division by the 4th component we get:

The Reason for Lenses *

The Lens Model Lens, aperture, and image plane

Focal length f: the distance from lens to image plane A point in focus: the image of a point is on the image plane

An out-of-focus point The circle of confusion r

The Gaussian / thin lens formula:

A near point in out-of-focus

The depth of focus dfocus and the depth of field (DOF) dfield

Decreasing the aperture size reduces the size of the blur for points not in the focused plane, so that the blurring is imperceptible, and all points are within the dfield.

Viewing and Projection In OpenGL we distinguish between: Viewing: placing the camera Projection: describing the viewing frustum of the camera (and thereby the projection transformation) Perspective divide: computing homogeneous points

Outline Camera Models Viewing Transformation Projection Matrix OpenGL Transformation Pipeline

OpenGL Transformations The viewing transformation V transforms a point from world space to eye space:

Placing the Camera It is most natural to position the camera in world space as if it were a real camera Identify the eye point where the camera is located Identify the look-at point that we wish to appear in the center of our view Identify an up-vector vector that we wish to be oriented upwards in our final image

Look-At Positioning We specify the view frame using the look-at vector a and the camera up vector up The vector a points in the negative viewing direction In 3D, we need a third vector that is perpendicular to both up and a to specify the view frame

Where does it point to? The result of the cross product is a vector, not a scalar, as for the dot product Depending on the basis vectors i, j, and k, the new vector follows the right or left handed rule In OpenGL, the cross product a x b yields a right hand side (RHS) vector perpendicular to a and b

Computing Cross Products We can compute the cross product using yet another matrix-vector multiplication: The matrix is sometimes called the skew-symmetric matrix of the vector (in this case a) Cross products produce vectors for both vector and point inputs

Constructing a Frame The cross product between the up and the look-at vector will get a vector that points to the right. Finally, using the vector a and the vector r we can synthesize a new vector u in the up direction:

World and Camera Frames The relation between the world and the camera is expressed as: We move the eye (camera) by updating E

Rotation Rotation first:

Translation Translation to the eye point:

Composing the Result The final camera transformation is: Why?

The Viewing Transformation Expressing P in eye coordinates:

The Viewing Transformation As a single 4x4 matrix: Where these are normalized vectors:

gluLookAt() OpenGL provides a very helpful utility function that implements the look‐at viewing specification: These parameters are expressed in world coordinates

Outline Camera Models Viewing Transformation Projection Matrix OpenGL Transformation Pipeline

OpenGL Transformations The projection transformation P transforms a point from eye space to clip space:

Projection Transformations Projections fall into two categories: Parallel projections: The camera is placed at an infinite distance from the viewplane; lines of projection are parallel to each other Perspective projections: Lines of projection converge at a point

Parallel Projections The simplest form of parallel projection is simply along lines parallel to the z-axis onto the xy-plane This form of projection is called orthographic For other parallel projections see, e.g.: http://www.mtsu.edu/~csjudy/planeview3D/tutorialparallel .html

Orthographic Frustum The user specifies the orthographic viewing frustum by specifying minimum and maximum x/y coordinates It is necessary to indicate a range of distances along the z- axis by specifying near and far planes

Orthographic Projections to NDC Normalized Device Coordinate (NDC) makes up a coordinate system that describes positions on a virtual plotting device Here is the orthographic world-to-clip transformation: Move center to origin T(-(left+right)/2, -(bottom+top)/2,(near+far)/2)) Scale to have sides of length 2 S(2/(right-left),2/(top-bottom),2/(far-near)) P = ST =

Orthographic Projection in OpenGL This matrix is constructed with the following OpenGL call: And the 2D version (another GL utility function): Just a call to glOrtho() with near = -1 and far = +1

Properties of Parallel Projections Not realistic looking Good for exact measurements A kind of affine transformation Parallel lines remain parallel Ratios are preserved Angles (in general) not preserved Most often used in CAD, architectural drawings, etc., where taking exact measurement is important

Isometric Games A special kind of parallel projection called isometric projection is often used in games It’s essentially a shear and an orthographic projection Easier to compute than a full perspective transformation Diablo SimCity The Sims

Perspective Projections Artists (Donatello, Brunelleschi, and Da Vinci) during the renaissance discovered the importance of perspective for making images appear realistic Parallel lines intersect at a point

Perspective Viewing Frustum Just as in the orthographic case, we specify a perspective viewing frustum Values for left, right, top, and bottom are specified at the near depth.

Perspective Viewing Frustum OpenGL provides a function to set up this perspective transformation: There is also a simpler OpenGL utility function: fov = vertical field of view in degrees aspect = image width / height at near depth Can only specify symmetric viewing frustums where the viewing window is centered around the –z axis.

OpenGL Clip Space In OpenGL clip space, the viewing frustum is mapped to a cube that extends from -1 to 1 in x, y, and z. OpenGL also flips the z axis to create a left handed coordinate system during projection

OpenGL Perspective Matrix Mapping the perspective viewing frustum in OpenGL to clip space involves some affine transformations OpenGL uses a clever composition of these transformations with the perspective projection matrix:

What happens to the z value? We get the following expression for z from our perspective matrix: This mapping is non‐linear:

Uniform differences in 3D (z) depth values do not correspond to uniform differences in z’ values: The number of discernable depths is greater near the near plane than the far plane Tip: Choose the near plane as far away as possible

Properties of Perspective Projections The perspective projection is an example of a projective transformation Here are some properties of projective transformations: Lines map to lines Parallel lines do not necessarily remain parallel Ratios are not preserved One of the advantages of perspective projection is that size varies inversely with distance – looks realistic A disadvantage is that we can't judge distances as exactly as we can with parallel projections

Outline Camera Models Viewing Transformation Projection Matrix OpenGL Transformation Pipeline

OpenGL Transformations The rest of the OpenGL transformation pipeline: 3D: 2D:

Clipping & Perspective Division The scene's objects are clipped against the clip space bounding box This step eliminates any objects (and pieces of objects) that are not visible in the image Hill describes an efficient clipping algorithm for homogeneous clip space Perspective division divides all homogeneous coordinates through w Clip space becomes Normalized Device Coordinate (NDC) space after the perspective division

Viewport Transformation One last transformation from NDC space to the viewport on the screen The viewport transformation also maps NDC depth values from the range [-1,1] to [0, 1] The resulting screen space is still 3D with depth values between 0 and 1

Viewport Transformation OpenGL provides a function to set up the viewport transformation:

Screen Coordinate Systems

3D Graphics Pipeline The rasterization step scan converts the object into pixels

3D Graphics Pipeline A z-buffer depth test resolves visibility of the objects on a per-pixel basis and writes the pixels to the frame buffer

The end Questions and answers