1 / 9

COMPUTER GRAPHICS

COMPUTER GRAPHICS. CS 482 – FALL 2014. SEPTEMBER 15, 2014. VIRTUAL CAMERAS. CLIPPING PERSPECTIVE PROJECTION ORTHOGRAPHIC PROJECTION. CLIPPING. VIEW FRUSTUM.

gamma
Télécharger la présentation

COMPUTER GRAPHICS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMPUTER GRAPHICS CS 482 – FALL 2014 SEPTEMBER 15, 2014 VIRTUAL CAMERAS • CLIPPING • PERSPECTIVE PROJECTION • ORTHOGRAPHIC PROJECTION

  2. CLIPPING VIEW FRUSTUM The actual “view volume” of a scene is limited by near and far clipping planes, as well as limitations on the horizontal and vertical viewing angles. All objects (or partial objects) that fall outside of the “truncated pyramid” of the view frustum should not be rendered, if it’s possible to inexpensively “clip” them from the scene. CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 90

  3. CLIPPING NEAR AND FAR CLIPPING Near and far clip planes must be chosen carefully. Far clip planes are extremely useful in reducing the number of polygons that must be processed during rendering... Near clip planes eliminate objects that might obstruct the viewer’s desired view... …But the image may be damaged if the far clip plane is too close. …but unwanted views of a graphical object’s internal geometry may result if the near clip plane is pushed back too far. CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 91

  4. PERSPECTIVE PROJECTION CONVERTING 3D TO 2D When 3-D objects are rendered in a 2-D environment, some form of projection is used to eliminate the “extra” dimension. The two primary types of projections are: • Orthographic (or parallel), in which one dimension is merely deleted • Perspective, in which a formal mapping is performed to provide some degree of foreshortening to the rendered image. While parallel projections are computationally inexpensive and provide a good notion of actual distances (at least with respect to the remaining dimensions), perspective projections provide better realism. With either type of projection, we require a 4x4 matrix that will map 3-D points (in homogeneous coordinates) to 2-D points on the viewscreen. CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 92

  5. PERSPECTIVE PROJECTION VANISHING POINTS To make distant objects appear smaller, perspective projections are used. Now there are vanishing points in the distant left and right, as well as far overhead. One vanishing point, straight ahead of the viewer. A second vanishing point is added, at far left. Perspective Projection Matrix for one vanishing point on the z-axis, with a center of projection at (xc, yc, zc) (Additional vanishing points may be produced by then applying rotations around the appropriate axes.) CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 93

  6. PERSPECTIVE PROJECTION LOCATING VANISHING POINTS Where are the vanishing points in this scene from “BioShock Infinite”? CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 94

  7. PERSPECTIVE PROJECTION PROJECTION SHADOWS When casting shadows from a directional light source onto planar surfaces, a simplistic implementation combines translations and perspective projections. And finally, translate back by the light’s position Second, project to the shadow plane (in this case, the x-z plane) First, translate by the negative of the light’s position For every vertex on the 3d object being “shadowed” CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 95

  8. PERSPECTIVE PROJECTION ASPECT RATIO In order to preserve the relative shapes and sizes of objects when the viewing window is resized, the perspective projection is adjusted to ensure a constant aspect ratio. voidResizeWindow(GLsizeiw, GLsizeih) { currWindowSize[0] = w; currWindowSize[1] = h; if( h == 0 ) h= 1; if( ASPECT_RATIO > w/h ) { currViewportSize[0] = w; currViewportSize[1] = int(w / ASPECT_RATIO); } else { currViewportSize[0] = int(h * ASPECT_RATIO); currViewportSize[1] = h; } // Center the image within the resized window. glViewport((w - currViewportSize[0]) / 2, 0, currViewportSize[0], currViewportSize[1]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(FIELD_OF_VIEW_ANGLE, ASPECT_RATIO, NEAR_CLIP_DISTANCE, FAR_CLIP_DISTANCE); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return; } CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 96

  9. ORTHOGRAPHIC PROJECTION PARALLEL PROJECTION Useful for drafting and design specifications, parallel projections do not tend to provide realistic views of 3-D objects. Orthographic Projection Matrix (to x-y plane) CS 482 – FALL 2014 SEPTEMBER 15, 2014: VIRTUAL CAMERAS PAGE 97

More Related