Presentation is loading. Please wait.

Presentation is loading. Please wait.

Similar presentations


Presentation on theme: ""— Presentation transcript:

90 COMPUTER GRAPHICS SEPTEMBER 22, 2015 CS 482 – FALL 2015
VIRTUAL CAMERAS CLIPPING PERSPECTIVE PROJECTION ORTHOGRAPHIC PROJECTION

91 SEPTEMBER 22, 2015: VIRTUAL CAMERAS
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 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 91

92 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 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 92

93 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 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 93

94 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 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 94

95 PERSPECTIVE PROJECTION
LOCATING VANISHING POINTS Where are the vanishing points in this scene from “BioShock Infinite”? CS 482 – FALL 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 95

96 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” 𝑥 𝑙 0 𝑦 𝑙 𝑧 𝑙 0 1 −1 𝑦 𝑙 − 𝑥 𝑙 0 − 𝑦 𝑙 − 𝑧 𝑙 0 1 𝑥 𝑦 𝑧 1 CS 482 – FALL 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 96

97 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. void ResizeWindow(GLsizei w, GLsizei h) { 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); return; CS 482 – FALL 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 97

98 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 2015 SEPTEMBER 22, 2015: VIRTUAL CAMERAS PAGE 98


Download ppt ""

Similar presentations


Ads by Google