Shadows in Maya can be turned on or off. The default setting for lights is to have the shadow set to off. Surfaces illuminated by the non-shadow casting light are still shaded by it, but won't cast shadows onto other surfaces. That means the part of an object that's exposed to light is illuminated, and the object's opposite side fades to a darker tone. It also means that the light passes through all objects, illuminating objects that are blocked by other objects. An object's shadow can identify its size, position, and orientation in space, so by adding shadows to your scene, you can more clearly define the spatial relationships between objects. Without shadows in a scene, the render looks flat and lacks depth. Shadows add depth and realism to the scene, especially indoor scenes. Look back at Figure 10.8, and you can see that it's hard to say whether the objects are on the ground or are floating in the air between the camera and the ground. The norm is to use only a few shadow-casting lights and many dimmer "fill" lights. Shadows require rendering time, particularly Area lights and raytraced shadows, so this guideline is partly to minimize computation. More important, however, shadows tend to wash each other out as you add more shadow-casting lights that illuminate the same area. With Maya, you have a lot of control over the way shadows are cast in a scene, which can help you reduce render times, add contrast to your renderings, and create a better-looking overall result. There are two types of shadows in Maya: depth map and raytraced shadows. Depth Map Shadows Depth map shadows are produced through an image map (a file with information about depth from the light's point of view). The depth map is calculated immediately before the actual render takes place. Using calculations for the distance of light to a specific point on an object, depth information is stored in the map and then passed on to the rendering engine to produce a "simulated" shadow effect. The depth map tells the rendering engine which areas of the scene are illuminated by light and which aren't by specifying how far light rays will reach, stopping them as they reach points calculated from information in the depth map. Depth map shadows usually give good results without having to worry about a huge increase in render time. They are usually slightly softer, too, which is more natural than harsh-edged raytraced shadows. If you want, you can achieve almost the same level of sharpness as raytraced shadows (by increasing the Dmap Resolution attribute, described in the next section). The main drawback to depth map shadows is that they don't take materials' transparency into account. (All objects cast full shadows regardless of the transparency of their material when using depth maps.) Depth map shadows work in a unique way for Point, Ambient, and Area lights: Because a square bitmap is required to create the shadow, and these light types cast light in all directions, they must create multiple maps to cover the area. Maya uses cubic shadow maps for these light types that is, six depth maps are cast for the six sides of a cube. This process requires six times the RAM, which could be a concern for large map sizes. In general, most of your shadows should be cast from Spot or Directional lights, where you can direct where the light and shadow should fall. Depth Map Attributes For depth map shadows, you can set the following attributes: Shadow Color Applicable to both types of shadows in Maya. Changing the Shadow Color attribute changes the shadow's color seen in the render. It's often a good idea to bring shadow colors a little brighter than pure black, to add to the simulation of diffuse light reflection. You can also map an image file or a texture to the Shadow Color, just as you would map an image to a material, as discussed in Chapter 9, "Materials." Dmap Resolution Specifies the resolution (accuracy) of a depth map shadow. The maps are square, so if you set this attribute to 1024, the shadow map is produced as a 1024x1024 pixel image. When setting Dmap Resolutions, try to use values that are powers of 4, such as 128, 256, 512, and 1024. These numbers are easier for Maya to calculate with and can result in faster render times. At very large sizes (4096+), RAM consumption can become a problem. If your light is using a low-resolution Dmap, the shadow might have jagged edges, giving it a "step" effect (see Figure 10.16), but this is relative to the rendered image resolution. You can "fuzz up" a jagged low-resolution shadow by using a higher value for the Dmap Filter Size. Increasing the resolution also reduces the jagged effect, but creates a sharper shadow edge. Figure 10.16. This depth map shadow has a very low Dmap Resolution setting, giving the shadow a jagged edge. Dmap Filter Size Directly affects the edges of a depth map shadow by making them softer. This attribute, combined with the Dmap Resolution, can smoothly and gradually soften a shadow's edge. Be aware that increasing this value increases render times. Use values between 1 and 3, unless you truly need to go higher. See Figure 10.17 for a comparison of different settings. Figure 10.17. On the left, increasing the Dmap Resolution to 1024 defines the shadow's edge more sharply. In the middle, a low Dmap Resolution of 128 gives the shadow jagged edges. On the right, Dmap Resolution is set to 256, and increasing the Dmap Filter Size to 3 smoothes the shadow's edges. Dmap Bias When depth map shadow casting lights are casting long shadows, they can sometimes separate from the objects. This setting allows you to adjust the placement of the shadows, and you usually need to adjust it only for very low light angles (such as a setting sun). Raytraced Shadows Raytraced shadows are generally slower to compute, but offer the advantage of lower RAM requirements, soft shadows, and properly cast shadows for objects that have transparency, such as windows. To make raytraced shadows appear in your renderings, you must go to the Render Global Settings window and enable raytracing. Like the Area light, the Spot, Directional, Ambient, and Point lights can cast area shadows. In this case, the soft shadows are created by having the light cast from a circular source. Non Point light sources create soft shadows (known as penumbral shadows) because a variable amount of the non Point light source is blocked as an object passes in front of the light. The light "peeks" around objects to partially illuminate the area behind them, so the shadows seem to slowly transition from pure shadow to non-shadow. Transparent objects can affect shadows if the shadows are raytraced. However, the color values do not affect shadow color. To cast colored raytraced shadows, you must set or map the transparency color for the material. Also note that the shadows have uniform intensity; refractive effects on light (known as caustics) are not accounted for in Maya's default renderer. Raytraced Shadow Attributes The following list describes the attributes you'll work with when using raytraced shadows: Light Radius (Shadow Radius/Light Angle) Sets the imaginary size of the circular Area light effect. Be aware that non-zero values for the Light Radius attribute enable penumbral (soft) shadows, which can take much longer to render. Shadow Rays Controls the sampling of soft shadows. If you use a low number, the shadows look speckled, but render faster. This is similar to the way that Dmap Filter Size works with depth map shadows, in that increasing the Shadow Rays setting reduces the shadow's graininess. Similar to raising the Dmap Filter Size, the Shadow Rays setting can significantly increase render time as you raise it, so limit the value to the bare minimum you need to get an acceptably smooth shadow (see Figure 10.18). Figure 10.18. On the left, the default raytraced shadow. In the middle, increasing the Light Radius to 1.25 produces grainy shadow edges. On the right, Light Radius stays the same, but increasing Shadow Rays to 6 reduces the graininess. Ray Depth Limit This setting enables you to limit the number of times a light bounces from reflective and refractive materials. You can raise this value if you want to allow raytraced light rays to bounce around the scene before eventually creating a shadow. Area Light Shadows If you set Area lights to cast raytraced shadows, the shadows are calculated from the rectangular Area light icon, based on its size. The results are similar to circular Area lights. As with circular Area lights, more Shadow Rays soften the shadow, but result in substantially longer render times. Tutorial: Working with Shadows You can continue from the previous tutorial, or load the scene file noted next to the DVD icon. On the DVD Chapter_10\movies\ch10tut08.wmv |
In the Outliner, select spotLight1. Turn on visibility in the Channel Box. Open the Attribute Editor for spotLight1, and you'll see a section in the spotLightShape1 tab named Shadows. Open the Shadows section, and under Depth Map Shadow Attributes, select the Use Depth Map Shadows check box. On the DVD Chapter_10\ch10tut07end.mb |
Render the Camera1 view to see the shadows you created (see Figure 10.19). Figure 10.19. Depth map shadows have been enabled for the Spot light in the scene. In the Attribute Editor, change the Dmap Resolution from the default 512 to 128. Do an IPR render and marquee-select the image, and you'll notice jagged edges on the shadows. Also, increase the Intensity to 2 to brighten up the scene and define the shadows more. Keep in mind that IPR rendering won't update Dmap Resolution changes, but it will update the Dmap Filter Size changes in the next step. Change the Dmap Filter Size to 3. The shadows cast by the objects are now softened to have no visible "steps." note IPR can give you instant feedback on changes to materials and light values, but cannot respond to some changes in shadows, including resolution. If you're changing a shadow value and not getting a visible change, try IPR rendering again. Next, you'll explore raytraced shadows. With the Spot light still selected and the Attribute Editor open, under Depth Map Shadow Attributes, deselect the Use Depth Map Shadows check box. The IPR render should update to remove the shadows. Open the Raytrace Shadow Attributes section in the Attribute Editor, and select the Use Ray Trace Shadows check box to create raytraced shadows. Looking at the IPR render, you'll see that it hasn't updated for the new shadows (just like the depth map shadows). Right-click in the Render View window, and choose Options | Render Globals. Scroll down the Render Global Settings window until you see Raytracing Quality. Select the Raytracing check box to turn on rendering for all raytraced parts of the scene. Raytracing Quality gives you control over how raytracing is applied in your scene. This applies not only to shadows, but also light refractions and reflections. Close the Render Global Settings window, and check the IPR render. It still isn't updated! Click the IPR Render button again. If you look at the Help Line, you'll see this message: Error: // IPR does not support raytracing. Turn off raytracing in Render Globals and select a new region. // This explains why the IPR render doesn't work. You'll have to perform a typical render to see the raytracing in action. Click the Render button in the Render View window. The render will probably take a bit longer than when you rendered with a depth map shadow. When it's done, you can actually see the shadows! The shadows have very defined edges, but that isn't the only difference. Notice any changes in the ground and the objects? The shadows for objects with bump maps have also changed. Change the Light Radius setting to 1.25 in the Attribute Editor. Render again, and notice that the shadow seems softer at the edges. Look closely and notice that the shadow has a speckled edge. If you have a really good eye, you probably saw that the graininess increases the farther the shadow is from the object. Now, you'll fix the grainy edge on the shadow. Just under Light Radius in the Attribute Editor, change Shadow Rays to 6. Render your scene again, but prepare to wait a lot longer to get shadows without the graininess. These tutorials have shown you the basics of light and shadow setup. Next you'll look at some of the other light controls. |