Shadows in Maya

table of contents

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 nonshadow-casting light still are shaded by it, but won't cast shadows. 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 9.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 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 the 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 cannot cast soft shadows and they don't respect transparency in materials (all objects cast full shadows regardless of the transparency of their material).

Depth map shadows work in a unique way for Point, Ambient, and Area lights: Because a square bitmap is required to create 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 typesthat is, six shadows are cast for the six sides of a cube. This process requires six times the RAM, however, 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 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 8, "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 will be produced as a 1024x1024 pixel image. 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 9.14), 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 9.14. This depth map shadow has a very low Dmap Resolution setting, giving the shadow a jagged edge.

    graphics/09fig14.gif

  • 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 9.15 for a comparison of different settings.

    Figure 9.15. 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 still 128, but increasing the Dmap Filter Size to 3 smoothes the shadow's edges.

    graphics/09fig15.gif

  • Dmap Bias When depth map shadowcasting 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 casting shadows for objects that are not opaque . To make raytraced shadows appear in your renderings, you must go to the Render Globals 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. NonPoint light sources create soft shadows (known as penumbral shadows) because a variable amount of the nonPoint 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 will have uniform intensity; refractive effects on light (known as caustics ) are not accounted for.

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 will enable penumbral (soft) shadows, which can take much longer to render.

  • Shadow Rays Controls the sampling of the soft shadows. If you use a low number, the shadows will appear 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 reduces the shadow's graininess. Unlike the Dmap Filter size, the Shadow Rays setting increases render time as you raise it, so limit the value to the bare minimum you need to get an acceptably smooth shadow (see Figure 9.16).

    Figure 9.16. 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 10 reduces the graininess.

    graphics/09fig16.gif

  • 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 here.

  1. First turn the spotLight1 light on by selecting it in the Outliner and switching the Visibility to on in the Channel Box. In the Attribute Editor for spotLight1, expand the shadows section. Under Depth Map Shadow Attributes, select the Use Depth Map Shadows check box.

    graphics/ch09m_icon.gif graphics/ch09l_icon.gif
  2. Render the RenderCamera view to see the shadows you created (see Figure 9.17).

    Figure 9.17. Depth map shadows have been enabled for the Spot light in the scene.

    graphics/09fig17.gif

    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.

  3. 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. 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.

  4. Change the Dmap Filter Size to 3 . The shadows cast by the objects are now softened to have no visible "steps."

    Next, you'll explore raytraced shadows.

  5. 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.

  6. 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 Globals 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 some control over how much information is calculated for raytracing. This applies not only to shadows, but also light refractions and reflections.

  7. Close the Render Globals 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 will 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.

  8. 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.

  9. Change the Light Radius 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.

  10. Next, you'll fix the grainy edge on the shadow. Just under the Light Radius in the Attribute Editor, you will see Shadow Rays. Change the value to 10 . Render your scene once more, 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.

    graphics/ch09o_icon.gif


Maya 4. 5 Fundamentals
Maya 4.5 Fundamentals
ISBN: 0735713278
EAN: 2147483647
Year: 2005
Pages: 201

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net