Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.

Similar presentations


Presentation on theme: "CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE."— Presentation transcript:

1 CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE

2 TRANSFORMS IN REVIEW Model and view transform are AFFINE transformations (parallel lines stay parallel) Model transform  any kind of transformation we’ve seen so far Rotation, scaling, translation, shear, etc. View transform  translation followed by rotation Centers camera at origin and orients it to look down –z axis Projection transform  depends on which we use Orthographic  affine Perspective  NOT affine  affects w component!

3 PROJECTION APPROACHES One can approach projection in one of two ways: Transform x and y, but zero out z component  flattening to a 2D plane Not invertible (can’t get z information back) Doesn’t help us if we’re using z buffers Doesn’t restrict which points in z we want (usually want to avoid points BEHIND camera) Transform camera volume into unit volume Gives us near and far planes  limits which range of z coordinates we allow Preserves z information (although it does transform it) Remember: from here on out, we are assuming that we have performed the view transform and we are already looking down the –z axis Either way, output will be normalized device coordinates

4 ORTHOGRAPHIC PROJECTION

5 INTRODUCTION Orthographic projection Parallel lines stay parallel  affine transformation Does not affect w component

6 FLATTENING TO A PLANE Simple example of flattening to a plane:

7 USING A VIEW VOLUME Define Axis-Aligned Bounding Box (AABB) with 6 values: left, right, bottom, top, near, far Goes from (l,b,n) to (r,t,f) Points to render must be inside AABB Near plane, far plane = extents of z values Transform AABB to unit cube Translation, then scale Makes clipping more efficient OpenGL  (-1,-1,-1) to (1,1,1)

8 FLIPPING Z Technically, because we’re looking down NEGATVE z axis  near > far! Often switch to LEFT-handed coordinate system by using reflection matrix before projection Looking down POSITIVE z axis Then, specify near and far values with 0 < n’ < f’ (positive z values)

9 PERSPECTIVE PROJECTION

10 INTRODUCTION Perspective projection NOT affine  parallel lines are generally NOT parallel after projection Lines may converge to a single point Matches more closely how we see things in real life (farther away = looks smaller)  more commonly used

11 FLATTENING TO A PLANE Let’s say we have a plane z = -d, d > 0 Camera is at origin We want to project a point p onto the plane z = -d, giving us a new point q = (q x, q y, -d) Using similar triangles, we can get the new x and y components:

12 FLATTENING TO A PLANE The corresponding perspective projection matrix is given by: NOTICE: The last row isn’t just (0,0,0,1) anymore!  will alter point’s w coordinate  must divide vector by w!

13 USING A VIEW VOLUME The view volume (or frustum) of a perspective projection is defined a little differently: Near and far plane (Left, bottom) and (right, top) corners of NEAR plane

14 PERSPECTIVE PROJECTION MATRIX The perspective projection matrix is given by: Example: point already at near plane:

15 FLIPPING Z Same as with the orthographic projection, z can be flipped before projection After that, use 0 < n’ < f’ OpenGL matrix with flipping:

16 FIELD OF VIEW Often can define horizontal and vertical field of view (FOV) angles Too wide  see distortion on edges (fish-eye lens effect) Too narrow  everything very “zoomed in” Can compute horizontal FOV based on w = width of monitor and d = distance from user: Asymmetric frustums = where either r != -l or t != -b  used in stereo viewing

17 EFFECTS OF FOV FOV = 109° FOV = 70° FOV = 30°

18 EFFECT ON Z VALUE With perspective projection  resulting z values do NOT vary linearly with input p z value! Placement of near and far planes  affects precision of z buffer! Example: abs(f – n) = 100, varying how close near plane is to camera:


Download ppt "CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE."

Similar presentations


Ads by Google