5.1 The 3D Illusion
Before we embark on our journey of 3D computer graphics, a simple question remains outstanding: How do we display a 3D world with depth and volume on a flat 2D monitor screen? Fortunately for us, this problem has been well studied, as artists have been painting 3D scenes on 2D canvases for centuries. In this section, we outline several key techniques that make an image look 3D, even though it is actually drawn on a 2D plane.
Suppose that you have encountered a railroad track that doesn’t curve, but goes along a straight line for a long distance. The railroad rails always remain parallel to each other, but if you stand on the track and look down its path, you will observe that the two railroad rails seem to get closer and closer together as their distance from you increases, and eventually they appear to converge at an infinite distance. This is one observation that characterizes our human viewing system: Parallel lines of vision converge to a vanishing point, as shown in Figure 5.2.
Figure 5.2: Parallel lines converge to a vanishing point. Artists sometimes call this linear perspective.
Another simple observation of how humans see things is that the size of an object appears to diminish with depth; that is, objects near us look bigger than objects far away. For example, a house far away on a hill will look very small, while a tree near us will look very large in comparison. Figure 5.3 shows a simple scene where parallel rows of columns are placed behind each other, one after another. The columns are actually all the same size, but as their depths increase from the viewer, they appear smaller and smaller. Also notice how the columns are converging to the vanishing point at the horizon.
Figure 5.3: Here, all the columns are of the same size, but a viewer observes a diminishing in size with respect to depth phenomenon.
Object overlap is another reality we experience. Object overlap refers to the fact that opaque objects obscure parts (or all) of the objects behind them. This is important, as it tells us the depth ordering relationship of the objects in the scene. We already discussed (in Chapter 4) how Direct3D uses a depth buffer to figure out which pixels are being obscured and thus should not be drawn. However, for completeness, we reshow the situation again in Figure 5.4.
Figure 5.4: A group of objects that partially obscure each other because they overlap.
Consider Figure 5.5. On the left we have an unlit sphere, and on the right we have a lit sphere. As you can see, the sphere on the left looks rather flat — maybe it is not even a sphere at all, but just a 2D circle! Thus, lighting and shading play a very important role in depicting the solid form and volume of 3D objects.
Finally, Figure 5.6 shows a spaceship and its shadow. The shadow serves two key purposes. First, it tells us the origin of the light source in the scene. And secondly, it provides us with a rough idea of how high off the ground the spaceship is.
Figure 5.6: A spaceship and its shadow. The shadow implies the location of the light source in the scene and also gives an idea of the spaceship’s height off the ground.
The observations just discussed, no doubt, are intuitively obvious from our day-to-day experiences. Nonetheless, it is helpful to explicitly write down what we know and keep these observations in mind as we study and work on 3D computer graphics.