Shadows and Occlusion
Setting up shadows takes just as much time and attention as setting up lights. You can think of all of your illumination as one half of your lighting design, and shadows as the other, equally important half. Shadows can add richness to the tones and shading of your image, tie elements together, and improve your composition. Besides their artistic importance, rendering shadows is a key technical area to master. Making the best choices of shadow-casting algorithms, building up a bag of tricks to cheat and manipulate your shadows, and knowing how to optimize your shadows for the best possible rendering speeds are essential skills for any 3D artist. This chapter will explore both the visual and the technical sides of shadows and occlusion in 3D graphics.
The Visual Functions of Shadows
People commonly think of shadows as obscuring and limiting vision. But shadows can often reveal things that otherwise would not have been seen. Here are some of the visual functions that shadows serve in cinematic images and computer graphics.
Defining Spatial Relationships
When objects cast shadows onto each other, the spatial relationships between the objects are revealed. For example, compare the scene in Figure 3.1 before and after shadows are added. Without shadows, you can't tell exactly where each ball is located. On the right side of the figure, the added shadows reveal how close some of the balls are to the back wall, when a ball is on the ground, and when two balls are near each other.
Figure 3.1 On the left side, you cannot tell how close the large upper ball is to the back wall. The most basic use of shadows is to show spatial relationships between objects, as in the right side of this figure.
The way shadows visually indicate spatial relationships is both a blessing and a curse. When a scene is rendered with shadows, the shadows can reveal mistakes and inaccuracies in your animation, such as if a character's feet are floating above the ground instead of planted firmly on it. Animation that was created and approved without shadows may need to be fixed once it has been test-rendered with shadows and any flaws are made visible.
If you are reading this book indoors, look around the room at all the places where furniture meets the floor. At a glance, you can probably tell whether each piece is directly touching the floor or is held above the floor by wheels or casters, just by looking at the shadows each piece of furniture is casting. As you look around the room, your eye interprets small differences in the shadows almost instantly, determining the spatial relationship between the furniture and the floor.
Revealing Alternate Angles
In addition to spatial relationships, a well-placed shadow can also disclose new angles on a subject that otherwise might not be visible. In Figure 3.2, the woman's profile is brought out by a shadow, without which we would see only the front of her face.
Figure 3.2 The shadow reveals a character's profile, which otherwise would not be seen in the rendering.
You can think of the light casting shadows as something like a second camera, with its own angle of view and perspective on the character. Most 3D programs enable you to view the scene from a light's point-of-view, as an aid to positioning and aiming the light. The outline of what you see—the profile of the subject from the light's point-of-view—shows you the shape that will be rendered as the shadow.
Be careful that no part of the character is much closer to the point-source or spotlight, lest it become disproportionately enlarged in the shadow. Also, be sure that any cheats that the animator has created don't look strange from the shadow's perspective. For example, if the animator has stretched a character's arm to an extra long length in order to bring the hand into the foreground, that cheated pose might look believable from the point of view of the camera, but look strange where the character's shadow is visible on the side wall. To fix this, you may need to change the angle of your shadows, or might even have to use a second version of the character without the cheat as a shadow object (shadow objects are discussed below).
Shadows can play an important role in the composition of your image. A shadow can lead the viewer's eye to a desired part of the rendering, or create a new design element to balance your composition. Figure 3.3 shows how a well-placed slash or other shadow can "break up" a space, adding variety to what otherwise would be a monotonous rear wall.
Figure 3.3 A slash breaks up the space and adds to the composition, making the image on the right a more attractive rendering.
Figure 3.3 also shows how a shadow can add contrast between two elements that might otherwise appear similar in tone. In the right frame, the shadow behind the vase adds depth and definition to the rendering by increasing the contrast between the vase and the similarly colored wall behind it. The vase now pops out much more clearly from the frame, so that people will clearly notice its shape, even in a briefer shot.
Indicating Off-Screen Space
A shadow can also indicate the presence of off-screen objects. The sense of "off-screen space" is especially important when you are telling a story or trying to set a mood for a small scene. A shadow that appears to have been cast by objects not visible on the screen indicates that there is more to the world you are representing beyond what's directly visible in the shot. The shadows in Figure 3.4 suggest a great deal about the other elements that might be in the off-screen environment. Sometimes you can just project an image, mapped to the color or intensity of the light, to simulate shadows from off-screen objects.
Figure 3.4 The shadow indicates what might exist in off-screen space.
By cementing the relationship between objects, shadows can also create a kind of integration between the elements in a scene. In the fanciful or implausible scenes often created in computer graphics, realistic shadows may be the only threads of reality available to tie together and sell the whole image. Even the commuting hippo in the subway car in Figure 3.5 looks more natural and present in the scene with shadows underneath him. Building a solid sense of contact between 3D sets and characters, between human actors and digital creatures, or even between 3D characters and real environments, is perhaps the most essential function of shadows. Without this contact, many scenes would fall apart into an apparent collage of disjointed images.
Figure 3.5 Shadows help integrate otherwise incongruous elements.