Introduction
- Creating a Soft Shadow
|
Soft shadows can simulate a diffuse light source.
To accomplish the effect of area lights, soft shadows become "softer" they
more they recede from the base of an object. MTOR can be used to control
how soft and how detailed the shadow is.
Soft shadows take longer to generate than ordinary
shadows for two reasons. To create soft shadows multiple shadow maps are
generated, between four and eight, and then these maps must be averaged
together. Soft shadows provide an excellent, but expensive, solution for
cases where shading with area lights is desired.
For more information about soft shadows see Application Note #26.
|
1 - Import Map Generator
|
- (Use scene ladder2.ma, or use the completed scene from
the last lesson, and turn the shadows off.)
-
In the last tutorial, the shadow map was generated with the
light shader. In this tutorial, another method will be used to generate
shadow maps, through the use of a Map
Generator.
-
Map generators can be attached in addition to any other
a types of shaders. They are used to generate arbitrary maps from
lights, objects, cameras, and coordinate systems. These maps can then be
referenced by other shaders.
-
In this example, we'll use a map generator that creates maps
for soft shadows. To create a map generator:
-
File-> Create Appearance-> MapGen-> Soft Shadow
-
Your palette should look now contain a Soft
Shadow Map Generator, like the one on the right.
|
-

-
The palette with a Map Generator
|
2 - Setting up the Map Generator
|
First, attach the Soft Shadow map generator to the
key light.
Now open the map generator in the appearance editor,
by double-clicking on its icon in the palette.
To enable soft shadows do the following:
1) Make sure Frequency is set to "Every Frame"
2) Open the Soft Shadow Controls, (by double-clicking
on the multi-colored box) and set Softsize to "4," and this
will control how much the shadow blurs as it recedes from the base of an
object.
(There's more info about Map
Generators, in the Shader Concepts
section.)
|
Soft Shadow Map Generator
|
1 - Setting up the light shader
|
-
Make sure the keyLight shader is attached to the Maya
key light. (Note: Both the light shader and the map generator can (and
should) be attached to the Maya light at the same time.)
Open the keyLight shader in the appearance editor. To
generate soft shadows, three things must be done:
1) The light shader's shadowname parameter must be set
to refer to the soft shadow maps. To do this click on the shadowname's
texture button (the blue, yellow, purple, and green button) and a pull-down
menu will appear, select: Refer to-> softshadow
This text will appear in the field:
[shdmap $OBJNAME soft]
"$OBJNAME" tells the shader to use the soft shadow maps
that have named after the object the light shader is attached to, which,
in this case, are the maps generated by our map generator.
2) Soft Shadows must be enabled, by clicking on the box.
3) The Soft Shadow Size setting in the keyLight should
match the softsize parameter in the map generator.
Notice that since the light shader will be using the shadow
maps created by the map generator, the light shader itself doesn't need
to create a shadow map. Its Frequency setting can be set
to "Never."
|
The Key Light Shader
|
4 - Render the soft shadows
|
RenderMan-> Render
Soft shadows should appear.
The job will take a little longer to render with soft shadows.
To see the job progress, open up the Alfred Job Window for this render
(like
we did in tutorial 2). In the job window there should be four shadow
maps generating. In the image on the right, we can see that the first two
shadow maps are complete, and the third map is halfway done.
When the final images renders, the shadows should
falloff, like the shadows in the image on the right.
|
The Alfred Job window shows
four shadow maps being generated.
Close-up of the soft shadow
|
Tips and tricks for working with soft
shadows.
Note A - Viewing the Soft Shadow Maps
|
Now try taking a look at the shadow maps using the techniques
from tutorial 2.
In the shadow maps on the right it is more obvious how
the camera actually pivots to generate multiple shadow maps.
Important: Note that when setting up soft shadows
in your own scenes, make sure that the light's manipulator is near the
base of the object(s) casting soft shadows. The light manipulator serves
as the pivot point for the soft shadow generation. So when the light manipulator
is far away from the base of the objects, the pivot will be incorrect and
the shadows behave poorly, like not appearing. The moral is to keep the
light manipulator near the base of shadow casting objects.
(To show a light manipulator, select the Maya light and
press "T".)
|
The soft shadow maps
|
|
|