Casting Shadows
There are four types of shadows that the scanline renderer can project from 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.
-
Area shadows simulate shadows that are cast from an illuminated area or volume. They use anti-aliasing to produce soft, atmospheric shadows and they support opacity and transparency mapping (see Chapter 14, "Maps," for more information) (Figure 11.37).
-
Ray-traced shadows are calculated by tracing a ray from source to object. Sharper and more precise than shadow-map shadows, ray-traced shadows are usually slower to render. Ray-traced shadows are perfect for architectural shadow studies, which is why they are the default shadow type for sunlight systems. Like area shadows, ray-traced shadows support opacity and transparency mapping, but they do not support soft shadows (Figure 11.38).
-
Advanced ray-traced shadows are a variation of ray-traced shadows that use less RAM for rendering. They can use anti-aliasing to produce soft edges (Figure 11.39).
Shadow maps are the default shadow type for most lights (Figure 11.36).
The fifth type of shadow, the mental ray shadow map, can only be used with the mental ray renderer. If mental ray shadow maps are used with the scanline renderer, no shadows will be rendered.
Figure 11.36 Shadow map shadows have soft edges.
Figure 11.37 Area shadows produce soft, atmospheric shadows.
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 see what the shadows look like (Figure 11.40).
-
Select the spotlight.
-
Open the Modify panel.
-
In the General Parameters rollout, choose a shadow type from the drop-down list (Figure 11.41).
-
Render the scene to see the result (Figure 11.42).
TIP
n 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.
Figure 11.40 The practice scene has soft shadow mapped shadows.
Figure 11.41 Changing the shadow type to Ray Traced Shadows.
Figure 11.42 The ray-traced shadows are more crisp and precise.
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):
-
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).
-
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 (Figure 11.45).
-
Save the scene.
Figure 11.43 Before and after adjusting a shadow map.
Figure 11.44 The Shadow Map Params rollout provides the means to correct shadow maps.
Figure 11.45 Increasing the map size and sample range focuses the shadow. Adjusting the map bias brings the shadow bank into alignment. To make the gap between the teapot and its lid disappear, check 2 Sided Shadows.
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 6 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).
-
Open the Modify panel.
-
Open the Ray Traced Shadow Params menu (Figure 11.47).
-
Increase the Max Quadtree depth.
-
Render the scene. The scene renders faster.
Figure 11.46 This sunlit scene has ray-traced shadows that are slow to render.
Figure 11.47 Ray Traced shadows have few parameters. For faster rendering, increase Max Quadtree Depth.
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).
-
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).
-
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.
Figure 11.48 The Adv. Ray Traced Params rollout allows you to set options for anti-aliasing and adding noise to ray-traced shadows.
Figure 11.49 The anti-aliased shadows have softer edges.
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).
-
Open the Modify panel.
-
Open the Shadow Parameters rollout.
-
Click the Color swatch (Figure 11.51).
-
Choose a color in the Color Selector: Shadow Color dialog box (Figure 11.52).
-
Render the scene. The shadow changes color (Figure 11.53).
Figure 11.50 The object casts a black shadow.
Figure 11.51 Click the color swatch.
Figure 11.52 Choosing a light-blue color.
Figure 11.53 The shadow changes to light-blue.
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).
-
Open the Modify panel.
-
Open the Shadow Parameters rollout.
-
Set the Density value of the shadow (Figure 11.55).
-
Render the scene. The shadow becomes darker or lighter (Figure 11.56).
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.
Figure 11.54 The object casts a shadow of Density = 1.0.
Figure 11.55 Decreasing the density of the shadow.
Figure 11.56 The shadow lightens.
Shadow casting is an arrangement between three parties: a light and an object that cast shadows, and an object that receives them.
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).
-
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).
-
Click OK.
-
Render the scene to see the results (Figure 11.59).
TIP
To prevent any shadows from falling across an object, uncheck Receive Shadows in its Object Properties dialog box (Figure 11.60).
Figure 11.57 In this scene, the teapot overshadows the tube.
Figure 11.58 Turning off cast shadows for a teapot.
Figure 11.59 After turning off the teapot's shadow, the tube stands out.
Figure 11.60 The tube stands within the teapot's shadow but is not shaded by it.