Viewing Transformations II

Slides:



Advertisements
Similar presentations
3D Clipping & Viewing process
Advertisements

Three Dimensional Viewing
1 Computer Graphics Chapter 8 3D Transformations.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
©Larry F. Hodges (modified by Amos Johnson) 1 Arbitrary 3-D View-Plane.
CS 325 Introduction to Computer Graphics 02 / 24 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
Visualization- Determining Depth From Stereo Saurav Basu BITS Pilani 2002.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Introduction to 3D viewing 3D is just like taking a photograph!
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Copyright  1999 by James H. Money. All rights reserved. Except as permitted under United States Copyright Act of 1976, no part of this publication may.
Computer Graphics (fall 2009)
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
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.
1 Computer Graphics Week9 -3D Geometric Transformation.
CS 376 Introduction to Computer Graphics 02 / 23 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 02 / 26 / 2010 Instructor: Michael Eckmann.
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.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
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
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Transformations: Projection CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed
CS 4731: Computer Graphics Lecture 12: More 3D Viewing Emmanuel Agu.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Viewing in 3D Lecture 11. Viewing in 3D2 u The 3D viewing process is inherently more complex than is the 2D viewing process. F In 2D, we simply specify.
3D Viewing and Clipping Ming Ouhyoung 歐陽明 Professor Dept. of CSIE and GINM NTU.
Chapter 11 Three-Dimensional Geometric and Modeling Transformations
Three Dimensional Viewing
Computer Graphic 2 D Viewing.
Rendering Pipeline Fall, 2015.
Computer Graphics CC416 Week 14 3D Graphics.
University of North Carolina at Greensboro
Computer Graphics CC416 Week 15 3D Graphics.
Transformations contd.
3D Viewing cgvr.korea.ac.kr.
Prof. Lizhuang Ma Shanghai Jiao Tong University
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
Normalizing Transformation (I)
Viewing in 3D Chapter 6.
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.
3D Transformation Pipeline
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CENG 477 Introduction to Computer Graphics
3D Clipping.
CSC461: Lecture 19 Computer Viewing
Viewing Rectangle Coordinates (VRC)
Three Dimensional Viewing
OpenGL 2D Viewing Pipeline
Computer Graphics Lecture 20
Last Time Canonical view pipeline Projection Local Coordinate Space
Chap 3 Viewing Pipeline Reading:
Interactive Computer Graphics Viewing
Prof. Lizhuang Ma Shanghai Jiao Tong University
Window to Viewport Transformations
THREE-DIMENSIONAL VIEWING II
Presentation transcript:

Viewing Transformations II CS 455 – Computer Graphics Viewing Transformations II

Arbitrary Views Suppose we want to look at the environment from somewhere other than along the z-axis How do we do this? What is the perspective matrix? Where should an object project onto our new viewplane? Solution: set up our arbitrary view transform it into the situation we know how to handle (i.e., viewpoint on the +z axis looking at the origin) apply that transformation to the environment then apply the perspective computation

Specifying and Arbitrary View What do we need to specify and arbitrary view? 1. Projection plane (or View plane) Specified with a point and a normal We will call the point on the plane the “View Reference Point” or VRP We will call the normal to the plane the “View Plane Normal” or VPN We can define these anywhere in world space Viewplane VRP VPN

Specifying and Arbitrary View What else? 2. A window in the infinite viewplane We want to specify a subset of the viewplane that we will project onto the screen Objects outside the window will not be seen How do we define that window? Very difficult to do in world coordinates! Viewplane Window VRP VPN

Specifying the Window We would like to specify the window relative to the VRP (some number of units above, below, left and right) To do this, we must create a new coordinate system This will be called the “View-Reference Coordinate System” (VRC) The origin of the VRC is the VRP One axis is the VPN A second axis will be the “up” axis This will need to be specified by the programmer It is simply the direction that is to be “up” i.e. the up direction of the eye or camera

Specifying the Window The “view up” vector (VUP) is projected onto the viewplane to get the second (V) axis This allows the programmer to specify any vector - not just a vector exactly perpendicular to N VUP projected onto Viewplane (V axis) Viewplane VUP VRP (VRC origin) VPN (N axis)

Specifying the Window The third axis (U) is obtained by taking the cross product of V and N VUP projected onto Viewplane (V axis) Viewplane U axis VRP (VRC origin) VPN (N axis)

Computing the VRC system The actual way this is done is: VRP and VPN are specified N = VPN View Up is specified U = VUP X N V = N X U V Viewplane VUP U N

Specifying the Window With the VRC system defined, we can now specify the window Window = (umin, vmin) -> (umax, vmax) the Center of the Window (CW) is midway between (umin, vmin) and (umax, vmax) V (umax, vmax) Viewplane CW U (umin, vmin) N

Specifying an Arbitrary View Back to specifying our arbitrary view What else do we need? 3. Projection type Parallel Perspective V (umax, vmax) Viewplane CW U (umin, vmin) N

Specifying an Arbitrary View What else do we need? 4. Projection Reference Point (PRP) Specified in VRC For perspective projection, it is the center of projection Defines the view volume as a semi-infinite pyramid whose apex is the PRP V Viewplane U N PRP - Center of Projection

Specifying an Arbitrary View For parallel projection, the direction of projection is obtained from the PRP and the CW The view volume is the infinite parallelepiped whose sides are parallel to the direction of projection (DOP) and pass through the borders of the window Viewplane V DOP CW U N PRP

Specifying an Arbitrary View And Finally: 5. Front and back clipping planes If desired Limits the view volume to a finite volume and clips objects that don’t fall within it Perspective Viewing Back Clipping Plane Window Front Clipping Plane VRP B F

Specifying an Arbitrary View Parallel Viewing Back Clipping Plane Window Front Clipping Plane VRP B F

Specifying an Arbitrary View Summary Need to specify: View Reference Point - VRP Projection Reference Point - PRP View Plane Normal - VPN View Up vector - VUP Window bounds Can be specified either as (umin, vmin), (umax, vmax) or FieldOfViewx, FieldOfViewy Projection Type

Specifying an Arbitrary View Summary Generally this is simplified for the user to: LookAt Point - VRP LookFrom Point - PRP, view point, or center of projection View Up vector - VUP Field of View - gives the window size (could be different for vertical and horizontal, or could be the same) Projection Type Then with these quantities specified: VRP = LookAt PRP = LookFrom VPN = LookFrom - LookAt N = VPN U = VUP X N V = N X U

Arbitrary View So, we have: Back plane V Viewplane VUP Field of View in U VUP LookAt U Front plane Field of View in V LookFrom N

Arbitrary View In world space we have: y v u n x z

Transforming the Arbitrary View Now we need to put the arbitrary view into a situation we know how to handle, i.e., LookFrom on the +z axis, LookAt at the origin How? Perform a sequence of transformations that will perform this

Transforming the Arbitrary View Step 1: Translate LookAt to origin T(-xvrp, -yvrp, -zvrp) y v y v’ n u n’ x u’ x z z

Transforming the Arbitrary View Step 2: Rotate about y to bring n into the yz plane Ry(Q) y y v’ v’’ n’ u’’ u’ x n’’ x z z

Transforming the Arbitrary View What is Q? Looking down the y axis: x Q n’z n’ z

Transforming the Arbitrary View Step 3: Rotate about x to bring n coincident with the z axis Rx(F) y y v’’ v’’’ u’’ n’’ x n’’’ u’’’ x z z

Transforming the Arbitrary View What is F? Looking down the x axis: y n’’z z F n’’

Transforming the Arbitrary View Step 4: Rotate about z to bring v coincident with the y axis and u coincident with the x axis Rz(g) y y v’’’ viv n’’’ niv u’’’ uiv x x z z

Transforming the Arbitrary View What is g? Looking down the z axis: y u’’’x x g u’’’

Transforming the Arbitrary View Now we have the arbitrary view transformed into a situation we know how to handle At this point, we can apply the perspective transformation, then render Final transformation: y viv niv uiv x z

Applying the Arbitrary View Once we have Marb_view computed, we multiply each point in each object by that Marb_view This has the effect of transforming our objects around so that the image we render is the image we would see from the given LookFrom point Marb_view is complex to compute - is there a better way? Yes! Remember linear algebra….. Transforming from one space to another

Transforming between Spaces Given our 3D cartesian coordinate system (x, y, z) and a separate 3D system defined somewhere in world space, how do we transform between them? y v u n x z

Transforming between Spaces Given u = (u1, u2, u3) v = (v1, v2, v3) n = (n1, n2, n3) And we want u to line up with the x axis v to line up with the y axis n to line up with the z axis z y x v u n

Transforming between Spaces Step 1: Translate the VRP to the World Coordinate origin Step 2: Apply the following matrix to transform from uvn space to xyz space y v u n x z y v u n x z

Canonical View Volumes In order to simplify clipping against a view volume, the notion of a canonical view volume is used. It is just a particular view volume that allows for clipping to be done very quickly We will take our viewing situation, and go through a sequence of transformations to place us in the canonical view volume. Objects are then clipped against this view volume, then rendered

Canonical View Volumes Parallel canonical view volume Defining Planes: x = -1 x = 1 y = -1 y = 1 z = 0 z = -1 y Back plane x z Front plane

Canonical View Volumes Perspective canonical view volume Defining Planes: x = -z x = z y = -z y = z z = -zmin z = -1 Back plane y Front plane x z

Canonical View Volumes Perspective Canonical view volume Looking down x: Looking down y: y -x -1 -1 -z -z x -y zmin zmin

Transforming to Canonical View Volume How do we go from our situation (eye on +z looking at origin) to the canonical view volume? y y ? viv x niv z uiv x LookFromiv More transformations! z

Transforming to Canonical View Volume Step 1: translate Projection Reference Point (LookFrom) to origin z y x uiv viv niv z y x uiv viv niv vrpzv prpiv T(0, 0, -prpzIV)

Transforming to Canonical View Volume Step 2: Scale so that the View Volume becomes the Canonical View Volume Part a: scale in x and y such that the view plane has dimensions 2*vrpz current viewplane dimensions: (umax - umin) by (vmax - vmin)

Canonical View Volumes Step 2a Looking down x: Before 1st scale After 1st scale y -z -y vrpz vrpz+B vrpz+F y -z -y vrpz vrpz+B vrpz+F

Transforming to Canonical View Volume Step 2b: Scale so that the View Volume sides have correct slope, and so that the z coordinate of the back clipping plane is -1 Back clipping plane is located at vrpz + B, so the scale factor is

Transforming to Canonical View Volume So the total scale is,

Canonical View Volumes Step 2a Looking down x: Before 2nd scale After 2nd scale y vrpz y -z -y viewplane z=-1 z=zmin -z vrpz+B -y vrpz+F

Canonical View Wrap Up Now we apply the perspective projection The final matrix sequence is: or (for change of basis): y x z

Clipping against the Canonical View Once we are in the canonical view, clipping is much easier. Extend the 2D Cohen-Sutherland clipping algorithm to 3D Use a 6-bit code Bit codes signify: bit 1 - point above view volume (y > -z) bit 2 - point below view volume (y < z) bit 3 - bit right of view volume (x > -z) bit 4 - bit left of view volume (x < z) bit 5 - bit behind view volume (z < -1) bit 6 - bit in front of view volume (z > zmin)

Example Given: Where does (-1, 1, 0) project? LookFrom at (2, 0, 2) LookAt at (1, 0, 1) ViewUp (0, 1, 0) ViewAngle 45 degrees Viewport (500, 500) Where does (-1, 1, 0) project? z y x v u n (-1, 1, 0)

Example z y x v u n (-1, 1, 0) First, compute what we need: N: U: V:

Example Next, compute transformation matrices: Translate: z y x v u n (-1, 1, 0) Next, compute transformation matrices: Translate: Change of Basis:

Example z y x v u n (-1, 1, 0) Multiply matrices together:

Example The UVN coordinate system will be lined up with XYZ. (-1, 1, 0) The UVN coordinate system will be lined up with XYZ. Where will (-1, 1, 0) now be?

Example Where does the LookFrom point transform to? y v’ x n’ u’ z (-.707, 1, -2.121) x n’ u’ z

Example Next, compute the Perspective Matrix: What is d? y v’ x n’ u’ (-.707, 1, -2.121) x n’ u’ What is d? z

Example Where does the point project onto the viewplane using the y Where does the point project onto the viewplane using the perspective projection? v’ (-.283, 0.4, 0) x n’ u’ z

Example Next: Window-to-viewport What are the window bounds? y v’ (-.283, 0.4, 0) Looking down y x x Q = 22.5o z xwin n’ u’ z So the window is defined between (-0.59, 0.59) Note: the projected point falls in that bound, so it will appear in the viewport

Example Window-to-viewport First, translate: y Window-to-viewport First, translate: v’ (.337, 1.02, 0) x n’ u’ z applying to the point gives:

Example y Window-to-viewport Next, scale: v’ (.337, 1.02, 0) x n’ u’ z

Example Window-to-viewport Applying to the point: (.307, .99, 0) x n’ u’ z So, the point projects to (124, 399) in the viewport

Quiz What does the perspective matrix look like for the situation where the LookFrom point is on the -x axis, and the LookAt point is the origin?