Viewing and Perspective Kurt Akeley CS248 Lecture 9 23 October 2007

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Now Playing: Coulibaly Amadou & Mariam from Dimanche a Bamako Released August 2, 2005.
Texture Mapping Kurt Akeley CS248 Lecture October 2007
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
3-D Transformations Kurt Akeley CS248 Lecture 8 18 October 2007
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)
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Introduction to 3D viewing 3D is just like taking a photograph!
Computer Graphics (fall 2009)
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Bing-Yu Chen National Taiwan University.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Foundations of Computer Graphics (Fall 2012) CS 184, Lectures 13,14: Reviews Transforms, OpenGL
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
10/7/04© University of Wisconsin, CS559 Fall 2004 Last Time Transformations Homogeneous coordinates Directions Rotation Geometry 101 – Points, edges, triangles/polygons.
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.
Three-Dimensional Viewing
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Viewing and Projection
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
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
Visible Surface Detection
Rendering Pipeline Fall, 2015.
Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin
3D Viewing cgvr.korea.ac.kr.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
CENG 477 Introduction to Computer Graphics
CS451Real-time Rendering Pipeline
Models and Architectures
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
OpenGL 2D Viewing Pipeline
Computer Graphics (Spring 2003)
Projection in 3-D Glenn G. Chappell
Lecture 13 Clipping & Scan Conversion
Models and Architectures
Chap 3 Viewing Pipeline Reading:
Models and Architectures
Viewing (Projections)
Presentation transcript:

Viewing and Perspective Kurt Akeley CS248 Lecture 9 23 October

CS248 Lecture 9Kurt Akeley, Fall 2007 Projection Transforms points from an n to an n-1 coordinate system n Other definitions? … Surface of projection n Typically a plane (“planar”) n Curved in special cases n E.g., dome simulator Projectors (connect points through the center of projection) n Typically straight lines (“geometric”) n Curved in special cases n Cartographic (e.g., Mercator) n Fish-eye lens (e.g., Omnimax) Image courtesy of Wikipedia

CS248 Lecture 9Kurt Akeley, Fall 2007 Planar geometric projections Straight lines project to straight lines p 1, p 2, and c define a plane n The intersection of this plane and the plane of projection is a line But distances may be distorted Center of projection (aka point of projection, viewpoint) p1p1 p2p2 Plane of projection c

CS248 Lecture 9Kurt Akeley, Fall 2007 Taxonomy of planar geometric projections Planar geometric ParallelPerspective 1-point2-point3-pointOrthographicOblique CabinetTopCavalierFrontSide True projection type Viewing transformation

CS248 Lecture 9Kurt Akeley, Fall 2007 The vertex pipeline Vertex assembly Primitive assembly Rasterization Fragment operations Display Vertex operations Application Primitive operations struct { float x,y,z,w; float nx,ny,nz; float r,g,b,a; } vertex; Framebuffer

CS248 Lecture 9Kurt Akeley, Fall 2007 OpenGL coordinate systems Vertex operations Transform v o by M Transform n o by M -1 Transform v e by P Object coordinates Eye coordinates (lighting calculations) Clip coordinates vovo veve vcvc nono nene “Model-view” transformation (non-rigid) Projection transformation (non-rigid)

CS248 Lecture 9Kurt Akeley, Fall 2007 The vertex pipeline Vertex assembly Primitive assembly Rasterization Fragment operations Display Vertex operations Application Primitive operations struct { float x,y,z,w; float nx,ny,nz; float r,g,b,a; } vertex; Framebuffer struct { float x,y,z,w; float r,g,b,a; } clipvertex;

CS248 Lecture 9Kurt Akeley, Fall 2007 OpenGL coordinate systems Vertex operations Transform v e by P Object coordinates Eye coordinates (lighting calculations) Clip coordinates (clip to unit cube) vovo veve vcvc nono nene Model-view transformation Projection transformation vdvd Divide by w c Map to Window Transform v o by M Transform n o by M -1 Homogenize Normalized device coordinates vwvw Window coordinates Viewport transformation Primitive operations Primitive assembly

CS248 Lecture 9Kurt Akeley, Fall 2007 Coordinates systems are convenient Object coordinates n Defined by modeler Eye coordinates Eye is at the origin, looking down the -z axis, +x to the right n Convenient for lighting calculations Clip coordinates n Unit cube (+/- 1) centered at the origin n Convenient for clipping calculations (plane equations are trivial) Normalized device coordinates n Homogenized clip coordinates n Convenient for rasterization and frame buffer arithmetic Window coordinates n Pixels are unit squares, origin at lower-left corner of window Z values fill available depth-buffer range

CS248 Lecture 9Kurt Akeley, Fall 2007 Orthographic Projection (the complete sequence)

CS248 Lecture 9Kurt Akeley, Fall 2007 Viewing transformation Puts eye at origin looking down the -z axis, +x to the right Transformation is rigid, one rotation and one translation n GLU helper routine is available (next slide) x y z

CS248 Lecture 9Kurt Akeley, Fall 2007 gluLookAt gluLookAt(double ex, double ey, double ez, // eye double cx, double cy, double cz, // center double ux, double uy, double uz); // up

CS248 Lecture 9Kurt Akeley, Fall 2007 Light positions Specified position is transformed by the modelview matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(ex,ey,ez,cx,cy,cz,ux,uy,uz); // now in world coordinates Float vec[4] = {px, py, pz, pw}; glLightfv(GL_POSITION, vec, 4); // specify in world coordinates … glMultMatrixf(…); glLightfv(GL_POSITION, vec, 4); // specify in object coordinates

CS248 Lecture 9Kurt Akeley, Fall 2007 Orthographic projection Only scaling is required But the interface supports scaling and translation: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(l,r,b,t,n,f); n and f are signed distances, not coordinates

CS248 Lecture 9Kurt Akeley, Fall 2007 The orthographic view volume xexe yeye zeze

CS248 Lecture 9Kurt Akeley, Fall 2007 Clip testing v c is within the unit cube centered at the origin if: Assuming w c is positive, this is equivalent to: xcxc ycyc zczc

CS248 Lecture 9Kurt Akeley, Fall 2007 Clipping arithmetic Points outside the unit cube are discarded Lines (or edges) that straddle a face of the unit cube are clipped n A new vertex is location is computed at the intersection n Appropriate attribute values are assigned to this vertex p1p1 p2p2 p

CS248 Lecture 9Kurt Akeley, Fall 2007 Clipping details The calculation of p must be invariant to the order of p 1 and p 2 n An edge shared by two triangles must not “crack” n Easiest implementation is canonical: Sort the vertexes into canonical order, then compute p Line clipping never generates more than two vertexes Triangle clipping can generate a vertex for each clipping plane n E.g., Sutherland-Hodgman n Later in this lecture n SGI paid royalties on this

CS248 Lecture 9Kurt Akeley, Fall 2007 Homogenization Divide by w c : Discard w d :

CS248 Lecture 9Kurt Akeley, Fall 2007 Viewport transformation Transform the [-1,1] range device coordinates to window coordinates: glViewport(int l, int b, int w, int h); glDepthRange(double n, double f); glViewport(0, 0, 10, 6); glDepthRange(0.0, 1.0); One pixel

CS248 Lecture 9Kurt Akeley, Fall 2007 The vertex pipeline Vertex assembly Primitive assembly Rasterization Fragment operations Display Vertex operations Application Primitive operations struct { float x,y,z,w; float nx,ny,nz; float r,g,b,a; } vertex; Framebuffer struct { float x,y,z,w; float r,g,b,a; } clipvertex; struct { float x,y,z; float r,g,b,a; } winvertex; struct { winvertex v0,v1,v2 } triangle;

CS248 Lecture 9Kurt Akeley, Fall 2007 Window coordinates Window coordinates are: n Continuous, not discrete n Not homogeneous n Can be used directly for rasterization n 3-D, not 2-D n Projection did not reduce 3-D to 2-D n 3-D homogeneous was reduced to 3-D non-homogeneous –But this was done by homogenization, not by the projection transformation Where did the parallel “projection” happen?

CS248 Lecture 9Kurt Akeley, Fall 2007 Oblique projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(l,r,b,t,n,f); float s = 0.5; // Cabinet float m[16] = {1,0,0,0, 0,1,0,0, -s,-s,1,0, 0,0,0,1}; glMultMatrixf(m);

CS248 Lecture 9Kurt Akeley, Fall 2007 Perspective Projection

CS248 Lecture 9Kurt Akeley, Fall 2007 Change only the projection matrix Vertex operations Transform v e by P Object coordinates Eye coordinates (lighting calculations) Clip coordinates (clip to unit cube) vovo veve vcvc nono nene Model-view transformation Projection transformation vdvd Divide by w c Map to Window Transform v o by M Transform n o by M -1 Homogenize Normalized device coordinates vwvw Window coordinates Viewport transformation Primitive operations Primitive assembly

CS248 Lecture 9Kurt Akeley, Fall 2007 Orthographic projection Only scaling is required But the interface supports scaling and translation: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(l,r,b,t,n,f);

CS248 Lecture 9Kurt Akeley, Fall 2007 Perspective projection Specify a frustum: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(l,r,b,t,n,f); n and f are distances, not coordinates. Both must be positive.

CS248 Lecture 9Kurt Akeley, Fall 2007 The frustum xexe yeye zeze

CS248 Lecture 9Kurt Akeley, Fall 2007 Where does projection happen? There are two ways to think about this: n In the projection transformation n “Thinking homogeneously” Setting w c = –z e warps the eye-coordinate system –From a frustum in eye coordinates –To the unit cube in clip coordinates n Homogenization doesn’t really change anything further n Hence “projection transformation” During homogenization and the discarding of the w d n “Thinking geometrically” Dividing by –z e causes the projection n This is where coordinates are reduced from 4D to 3D

CS248 Lecture 9Kurt Akeley, Fall 2007 Remaining topics Perspective-correct attribute parameterization Sutherland-Hodgman clipping Near-plane clipping The “direction” of a projection Wide field-of-view projection (planar doesn’t work well)

CS248 Lecture 9Kurt Akeley, Fall 2007 Rasterization revisited Vertex assembly Primitive assembly Rasterization Fragment operations Display Vertex operations Application Primitive operations struct { float x,y,z,w; float nx,ny,nz; float r,g,b,a; } vertex; Framebuffer struct { float x,y,z,w; float r,g,b,a; } clipvertex; struct { float x,y,z; float r,g,b,a; } winvertex; struct { winvertex v0,v1,v2 } triangle;

CS248 Lecture 9Kurt Akeley, Fall 2007 Planar geometric projection Straight lines project to straight lines n Only vertexes need to be transformed n That’s why we’re interested in lines and polygons But distances and parameterizations are warped:

CS248 Lecture 9Kurt Akeley, Fall 2007 Incorrect attribute interpolation f2f2 f1f1 f f2f2 f1f1 F f Linear interpolation

CS248 Lecture 9Kurt Akeley, Fall 2007 Linear (barycentric) attribute evaluation (x 0, y 0, f 0 ) (x 1, y 1, f 1 ) (x 2, y 2, f 2 ) (x, y, f ) a2a2 a1a1 a0a0

CS248 Lecture 9Kurt Akeley, Fall 2007 Perspective-correct attribute evaluation (x 0, y 0, w 0, f 0 ) (x 1, y 1, w 1, f 1 ) (x 2, y 2, w 2, f 2 ) (x, y, f ) a2a2 a1a1 a0a0 Requires a division for each fragment All w ’s are w c ’s

CS248 Lecture 9Kurt Akeley, Fall 2007 Rasterization requires access to w c Vertex assembly Primitive assembly Rasterization Fragment operations Display Vertex operations Application Primitive operations struct { float x,y,z,w; float nx,ny,nz; float r,g,b,a; } vertex; Framebuffer struct { float x,y,z,w; float r,g,b,a; } clipvertex; struct { float x,y,z,w_c; float r,g,b,a; } winvertex; struct { winvertex v0,v1,v2 } triangle;

CS248 Lecture 9Kurt Akeley, Fall 2007 OpenGL coordinate systems Vertex operations Transform v e by P Object coordinates Eye coordinates (lighting calculations) Clip coordinates (clip to unit cube) vovo veve vcvc nono nene Model-view transformation Projection transformation v d, w c Divide by w c Map to Window Transform v o by M Transform n o by M -1 Homogenize Normalized device coordinates v w, w c Window coordinates Viewport transformation Primitive operations Primitive assembly

CS248 Lecture 9Kurt Akeley, Fall 2007 Sutherland-Hodgman clipping Approach: clip against each plane in sequence Simplified example clips a triangle to a square, 2-D frustum:

CS248 Lecture 9Kurt Akeley, Fall 2007 Near-plane clipping Is required … To limit z w values to the range of the depth buffer To avoid division by w c = 0 n To avoid rendering objects behind the viewpoint But clipping assuming w c > 0 accomplishes this too

CS248 Lecture 9Kurt Akeley, Fall 2007 The “direction” of a projection Yes, we spoke of a view direction in eye coordinates Specifically, down the –z e axis, +x e to the right And yes, the plane of projection is perpendicular to the –z e axis by convention But, once the projection has been specified, it is not valid to treat it as implying a true viewing direction (the orientation of the eye): n Parallel projections have a meaningful direction that is distinct from the normal to the plane of projection, but this direction is not the view direction. n Perspective projections have no meaningful direction at all. Once specified, they are fully characterized by a center of projection and a plane of projection. The normal to the plane of projection has no meaning. Bottom line: once a projection has been specified, it implies nothing about the orientation of the viewer’s eye. Only the location of the eye’s optical center is specified (the center of projection).

CS248 Lecture 9Kurt Akeley, Fall 2007 Projection does not imply viewing direction!

CS248 Lecture 9Kurt Akeley, Fall 2007 Wide field-of-view display Assume equal-size pixels Problem: n Center-field pixels are most important (foveal gaze) n But wide-field pixels have much greater “resolution”

CS248 Lecture 9Kurt Akeley, Fall 2007 Ratio of perceived pixel sizes Field of view (degrees) Ratio of perceived size of center pixel to edge pixel

CS248 Lecture 9Kurt Akeley, Fall 2007 Piece-wise linear projection Note: there is one view direction, but three planes of projection

CS248 Lecture 9Kurt Akeley, Fall 2007 Summary Perspective projection can be understood two different ways: n Warping of eye coordinates by the projection transformation n Consistent with orthographic transformation n Consistent with 3-D result n Consistent with name “projection transformation” Division by - z e and discarding of w d n Consistent with attribute evaluation Perspective projection warps distances and attribute evaluation n Must interpolate only “projected” values n Requires division for attributes of each fragment Projections do not specify the true orientation of the viewer’s eye n Perspective projections don’t really have a direction n Parallel projections do, but it’s not the viewing direction

CS248 Lecture 9Kurt Akeley, Fall 2007 Assignments Reading assignment for Thursday’s class n FvD 17.4 n OpenGL chapter 9 n Optional: Heckbert, P., A Survey of Texture Mapping, IEEE Computer Graphics, 6:11, pp , Project 2: n Due tonight at midnight Midterm n Monday 7 pm to 9 pm, Gates B01

CS248 Lecture 9Kurt Akeley, Fall 2007 End