Page 148 - Computer Graphics Handout
P. 148

perspective projections of the building shown in Figure 4.10. Any corner of the building includes the three principal directions. In
          the most general case— the three-point perspective—parallel lines in each of the three principal directions converges to a finite
          vanishing point (Figure 4.10(a)). If we allow one of the principal directions to become parallel to the projection plane, we have a
          two-point projection (Figure 4.10(b)), in which lines in only two of the principal directions converge.
          Finally, in the one-point perspective (Figure 4.10I), two of the principal directions are parallel to the projection plane, and we have
          only a single vanishing point. As with parallel viewing, it should be apparent from the programmer’s point of view that
          the three situations are merely special cases of general perspective viewing, which we implement in Section 4.4.



          4.2 VIEWING WITH A COMPUTER


          We can now return to three-dimensional graphics from a computer perspective. Because viewing in computer graphics is based on
          the synthetic-camera model, we should be able to construct any of the classical views. However, there is a fundamental difference.
          All the classical views are based on a particular relationship among the objects, the viewer, and the projectors. In computer graphics,
          we stress the independence of the object specifications and camera parameters. Hence, to create one of the classical views, the
          application program must use information about the objects to create and place the proper camera.
          Using OpenGL, we will have many options on how and where we carry out viewing. All our approaches will use the powerful
          transformation capabilities of the GPU. Because every transformation is equivalent to a change of frames, we can develop viewing
          in terms of the frames and coordinate systems we introduced in Chapter 3. In particular, we will work with object coordinates,
          camera coordinates, and clip coordinates.
          A good starting point is the output of the vertex shader. In Chapters 2 and 3, we used the fact that as long as the vertices output by
          the vertex shader were within the clipping volume, they continued onto the rasterizer. Hence, in Chapter 2 we were able to specify
          vertex positions inside the default viewing cube. In Chapter 3, we learned how to scale positions using affine transformations so
          they would be mapped inside the cube. We also relied on the fact that objects that are sent to the rasterizer are projected with a
          simple orthographic projection. Hidden-surface removal, however, occurs after the fragment shader. Consequently, although an
          object might be blocked from the camera by other objects, even with hidden-surface removal enabled, the rasterizer will still
          generate fragments for blocked objects within the clipping volume. However, we need more flexibility in both how we specify
          objects and how we view them. There are four major additions to address:
          1. We need the ability to work in the units of the application.
          2. We need to position the camera independently of the objects.
          3. We want to be able to specify a clipping volume in units related to the application.
          4. We want to be able to do either parallel or perspective projections.
          We can accomplish all these additions by careful use of transformations: the first three using affine transformations, and the last
          using a process called perspective normalization. All of these transformations must be carried out either in the application code
          or in the vertex shader. We approach all these tasks through the transformation capabilities we developed in Chapter 3. Of the
          frames that are used in OpenGL, three are important in the viewing process: the object frame, the camera frame, and the clip
          coordinate frame.
          In Chapters 2 and 3, we were able to avoid explicitly specifying the first two by using a default in which all three frames were
          identical. We either directly specified vertex positions in clip coordinates or used an affine transformation to scale objects we wanted




















                                                             148
   143   144   145   146   147   148   149   150   151   152   153