Casting Shadows
There are four types of shadows that you can assign to a light:
-
Shadow maps are bitmaps that are projected from a light. They are created by the scanline renderer during a pre- rendering pass of the scene and applied during rendering. Shadow maps give shadows a soft edge, as if they are being diffused by the atmosphere (Figure 11.36).
Figure
11.36 Shadow-map shadows have soft edges.
-
Area shadows simulate shadows that are cast from an illuminated area or volume. They use anti-aliasing to produce soft, atmospheric shadows (Figure 11.37).
Figure
11.37 Area shadows produce soft, atmospheric shadows.
-
Ray-traced shadows are more precise and sharp-edged than shadow-map shadows. They are calculated by tracing a ray from source to object. Use ray-traced shadows whenever you need to precisely locate shadows, such as in shadow studies for architectural siting (Figure 11.38).
-
Advanced ray-traced shadows are a variation of ray-traced shadows that also use anti-aliasing to produce soft edges (Figure 11.39).
Shadow maps are the default shadow type for most lights.
Ray-traced shadows are the default type for sunlight systems.
Figure 11.38 Ray-traced shadows have hard edges.Figure 11.39 Advanced ray-traced shadows use anti-aliasing to produce soft edges.
Once you select a shadow type, you can adjust its color, density, and position, plus other qualities specific to that type. The adjustments that you make to a shadow determine the speed at which it will render.
To change shadow type:
-
Open Practice02.max.
-
Render the scene to get an accurate idea of what the shadows currently look like (Figure 11.40).
Figure
11.40 The practice scene has soft shadow mapped shadows.
-
Select a light that casts shadows.
-
Open the Modify panel.
-
In the General Parameters rollout, choose a shadow type from the drop-down list (Figure 11.41).
Figure
11.41 Changing the shadow type to ray-traced shadows.
-
Render the scene to see the result (Figure 11.42).
Figure
11.42 The ray-traced shadows are more crisp and precise.
TIP
Ray-traced shadows render more slowly when you use them with omni lights. If possible, use ray-traced shadows with spotlights or directional lights instead. If you still need the effect of an omni or directional light, check Overshoot so the shadows will only be calculated within the cone.
Shadow maps sometimes appear blurry, faint, or detached from the objects that cast them. Shadow-map parameters help you fix these problems (Figure 11.43):
Figure 11.43 Before and after adjusting a shadow map.-
BiasOffsets shadows from the object that casts them. Lowering the Bias value moves shadows closer to the object.
-
SizeControls the resolution of a shadow by setting the size of the bitmap that generates the shadow. Increasing this parameter sharpens shadow edges and increases rendering time.
-
Sample RangeControls the sharpness of shadows by averaging different sized areas of the shadow map. If a shadow smudges, streaks, or creates moiré patterns, the Sample Range setting is probably too high. A Sample Range setting that is too low creates jagged shadows.
-
Absolute Map BiasDetermines how the map bias is computed in relation to the rest of the scene. Use this option to end flickering shadows in an animation.
-
2-Sided ShadowsCauses surfaces to cast shadows as if they were double sided.
To get the most accurate feedback, render the scene after you change each parameter.
To adjust a shadow map:
-
Select a light that has a problematic shadow map, such as the spotlight in Practice02.max.
-
Open the Modify panel.
-
Open the Shadow Map Params rollout (Figure 11.44).
Figure
11.44 The Shadow Map Params rollout provides the means to correct shadow
maps.
-
Increase the Size and the Sample Range to improve the resolution of the shadow. Then decrease the Bias until the shadows touch the objects that cast them. To make the gap between the teapot and its lid disappear, check 2 Sided Shadows (Figure 11.45).
Figure
11.45 Increasing the map size and sample range focuses the shadow. Adjusting
the map bias brings the shadow bank into alignment.
-
Save the scene.
Ray-Traced shadows produce hard-edged shadows that rarely need correcting. Like shadow map shadows, they allow you to adjust the shadow bias and render 2-sided shadows. In addition, the Max Quadtree Depth setting controls the rendering speed of ray-traced shadows by setting the maximum size of the data structure that generates them.
Advanced Ray-Traced shadows allow you to add anti-aliased edges and control their smoothness. You can also add noise to the shadows to offset shadow artifacts.
For more information on shadow parameters for each of the shadow types, open the 3ds max 5 User Reference and go to Contents > Lights and Cameras > Lights > Rollouts for Specific Shadow Types.
To speed up rendering of ray-traced shadows:
-
Open Practice05.max. Then select Sun01 (Figure 11.46).
Figure
11.46 This sunlit scene has ray-traced shadows that are slow to render.
-
Open the Modify panel.
-
Open the Ray Traced Shadow Params menu.
-
Increase the Max Quadtree depth (Figure 11.47).
-
Render the scene.
Figure 11.47 Increase the Max Quadtree Depth if you have plenty of RAM.
The scene renders faster.
To anti-alias ray-traced shadows:
-
In the General Parameters rollout, convert the shadows of the Sun01 object to advanced ray-traced shadows.
-
Open the Adv. Ray Traced rollout (Figure 11.48).
Figure
11.48 The Adv. Ray Traced Params rollout allows you to set options for anti-aliasing
and adding noise to ray-traced shadows.
-
Increase the Shadow Integrity to 5 and the Shadow Quality to 10. Then increase the Shadow Spread to 4.
-
Render the scene (Figure 11.49).
Figure
11.49 The anti-aliased shadows have softer edges.
-
Continue to play with the parameters until you get the effect that you like. Be sure to try increasing the Jitter Amount to see what it looks like when you add noise to the shadow.
You can set shadow color for all types of shadows independently of the color of the light. Use this feature to simulate reflected color from nearby objects or from secondary light sources such as the sky.
To set shadow color:
-
Select a light that casts shadows (Figure 11.50).
Figure
11.50 The object casts a black shadow.
-
Open the Modify panel.
-
Open the Shadow Parameters rollout.
-
Click the Color swatch (Figure 11.51).
Figure
11.51 Click the color swatch.
-
Choose a color in the Color Selector: Shadow Color dialog box (Figure 11.52).
Figure
11.52 Choosing a light-blue color.
-
Render the scene.
The shadow changes color (Figure 11.53).
Figure 11.53 The object now casts a light-blue shadow.The Density parameter sets the value, or darkness, of the shadows without affecting their hue and saturation. Use this feature to fill in shadows or to make them more transparent.
To set shadow density:
-
Select a light that casts shadows (Figure 11.54).
Figure
11.54 The object casts a shadow of Density = 1.0.
-
Open the Modify panel.
-
Open the Shadow Parameters rollout.
-
Set the Density value of the shadow (Figure 11.55).
Figure
11.55 Decreasing the density of the shadow.
-
Render the scene.
The shadow becomes darker or lighter (Figure 11.56).
Figure 11.56 The shadow lightens.TIP
To mix the color of the light with the shadow color, check Light Affects Shadow Color in the Shadow Parameters rollout.
To project a map into a shadow, check Map, click the None button, and choose a map.
Shadow casting is an arrangement between two parties: Both the light and the object have to be set to cast shadows before shadows will be rendered. If you turn off the shadow-casting property of an object, it will not cast shadows for any light.
To turn off shadow casting for an object:
-
Open a scene that is illuminated by a light (Figure 11.57).
Figure
11.57 In this scene, the teapot overshadows the tube.
-
Select an object that is casting a shadow.
-
Right-click on the object, and choose Properties from the Transform quad menu.
-
In the Object Properties dialog box, uncheck Cast Shadows (Figure 11.58).
Figure
11.58 After turning off the teapot's shadow, the tube stands out.
-
Click OK.
-
Render the scene to see the results (Figure 11.59).
Figure
11.59 Turning off Cast Shadows for the teapot.
TIP
To prevent any shadows from falling across an object, uncheck Receive Shadows in its Object Properties dialog box (Figure 11.60).
Figure 11.60 The tube stands within the teapot's shadow but is not shaded by it.