CAP 203 - Computer Animation III
Chapter 4: Lighting and Shadows
This lesson covers material from chapter 4 of the text.
Objectives important to this lesson:
- Lighting basics
- Exterior basics
- Sunlight in a room
- Mental ray lighting
- Ray trace vs. shadow map
- Why shadows disappear
This chapter has lots of exercises, so we will hit several.
Before we begin the first exercise, there are some basic things about light that the text does not mention. A review from CAP 201 may be useful:
There are three major types of lights in 3DS Max, and lots of subtypes.
- standard lights - these are like real movie lights, and they come in several sub-types:
- omnidirectional (omni) - think of a small star or a bare light bulb that shines in all directions
- spotlight - light starts at a point and grows into a cone shape. In this case, the cone is really two cones that can be set with the same dimensions. The cones are called the hotspot and the falloff. The hotspot is the brightest part of the light, the falloff is the outer cone that is larger and dimmer than the hotspot at most focal settings. When the hotspot and the falloff have the same value in 3DS Max, the light is a sharp spot like you see in a live theater. When the falloff has a larger value, the light from the spot has two regions, and a more gradual change between them. To see the effect in real life, get a MagLite (or other focusing flashlight) and change the focus in a dark room. Unlike a MagLite, you can change the shape of a spotlight.
Spots come in two sub-types:
- target - like a target camera, a target spot can be linked to a location in the scene. It will stay pointing at the location if the light is moved (animated).
- free - free spots can and must be pointed manually at the objects you want them to light
- direct -the text describes the light from a direct light as coming through a cylinder instead of a cone; the light does not spread out like the cone of a spotlight. It is more like a laser beam that maintains its shape without spreading. Like spots, these lights also come as target or free lights.
- skylight - simulates outdoor lighting
- mr Area Omni and mr Area Spot - variations on the omnidirectional and spot lights that are used with the mental ray renderer, a rendering engine that traces rays of light in a scene to realistically portray reflections
- photometric lights - complex lights that can represent real-world lighting
- systems - simulated sunlight, with lots of parameters to set
There is another kind of light that appears naturally in scenes, the default light. Remember that the default light is removed from a scene when you create lights in it.
In various lessons the author uses the Light Lister dialog box to quickly change parameters for several lights at once. This is handy when trying to adjust a light problem that must be changed mathematically, but whose result must be judged visually. Look for the Light Lister on the Tools menu.
Here is another thing that will help you with this text, in case you have not worked this out yet. The author continues to provide map files for the scenes that are named incorrectly. Apparently, this version of 3DS Max cares about capitalization in file names. Good lord, why? We must accept that it does. We must also accept that the author has supplied files whose names are different from the ones she used to build the scene in other ways, such as spaces in one name, underscores in another. Method to correct the problem:
- Open one of her scenes.
- When the Missing External Files screen appears, as it often does, move the screen a bit so you will be able to read it while you do the next several steps. Moving it to the upper left corner of your monitor may be good.
- Click the Browse button. The Configure External File Paths dialog box will appear. Drag it back toward the center of the monitor so you can easily read the Missing External Files screen. Click the Add button on the Configure External File Paths dialog box.
- Navigate to the folder where you have saved your copies of the map files for this scene. Find a file whose name is similar to the first one on the list. It is important that this is the right file.
- Select the file whose name is similar to the first one in the list, right click it,and select Rename. Change the name of the file so that it matches the name in the Missing External Files window exactly. The entire name must match, including the file extension. (If your computer is configured not to show file extensions, that must be corrected or this procedure will not work.)
When the filename is identical, press Enter to save the name change.
- Select the file whose name you just changed, and click the Use Path button.
- Repeat this process for each file named in the Missing External Files list. When you have processed all the files, click the OK button on the Configure External File Paths screen. The list of files on the Missing External Files screen should disappear. If file names remain, you have more corrections to make.
As we have observed in class, it is also possible that the scene is looking for a file that is not even used in the scene, such as a map for a sample slot that is configured but unused. If this is the case, select that sample slot and click the Reset Material button to clear it. Save the scene again, and that particular error will stop being an issue for the scene.
The first lesson we will consider in the chapter is 1-2-3 Lighting on page 104. The author is illustrating the classic three-point lighting scheme, which you will recall can use more than three lights, and more than three points.
- Open the start file for this lesson. Take a deep breath before starting the exercise, since the author sets a new standard for arranging sequential steps on a page. Overview: read page 104 first. Then look at page 105: step 1 is at 1 o'clock, step 2 is at 9 o'clock, step 3 is at 6 o'clock, and step 4 is at 11 o'clock. I hope she doesn't draw comic books.
I get it, she is trying to diagram the scene. She already did that on page 104. We'll use her innovation as the inspiration for part of this assignment.
In step 1, she states that the key light should be the brightest light in the scene. That is one definition of a key light. The location in which you place a key light will not always be the same. In the author's example, the key light may be telling us that it is about ten in the morning on a sunny day. Follow her advice: set up a direct or spot light as she indicates.
- Note that she is using omni lights for the other three lights in this scene. In step 2, she is adding an omni light that is a fill light. It should logically be placed on a side of the scene away from the key light. One way to think of it is that the fill light reduces harsh shadows cast by the key light. If the key light is shining from the southeast, the fill light may need to be on the southwest, as indicated, or even the northwest if necessary. Place a fill light in the scene as she indicates.
- She adds an omni light under the ground level of the scene, to simulate ambient light bouncing off the ground. Note that this should work, since we have not told the new light to make shadows. (See the tip on page 83 about turning on the Shadow checkbox for a light.) Add a light like this, without shadows, and adjust the intensity level as needed.
- Experiment with her fourth light, the rim light, adding a little light to the top of objects in the scene.
- New step: see if you can make an animation out of this lesson. I would like to see the lights and their effects added to the scene, one by one. Include some movement of the lights to show the difference in different placements.
- Save your file. Render an animation of it, and show it to me.
This exercise is on pages 106 and 107. This time the author uses only three lights in her three-point scheme to simulate an outdoor scene.
- In step 1 add a direct light to stand for the sun, as indicated by her instructions. Note that she set her key light multiplier to 1.5. See if this is a reasonable setting.
- Add an omni light for a fill light. Note that her setting for the fill light multiplier is only a third as bright as the key light multiplier.
- She refers to her underground, ambient light as a dim light. Remember that you will want to balance that multipliers of the three lights to reflect whatever actual weather, location, and latitude you are trying to simulate.
- Put a camera in the scene, and fly it around to show off the lighting.
- Save your file. Render an animation of it, and show it to me.
This exercise is on pages 108 and 109. The author indirectly makes a point in this lesson that we have been able to fudge a bit in the outdoor scenes. Indoors, the placement of lights needs to be a bit more deliberate, since the light is meant to be coming from light fixtures that we will be able to see in the scene. As such, the placement of our scene lights should often coincide with the placement of the prop or stage dressing lights.
- Load the scene file, and note the locations of the four major lights. Ignore the windows for this exercise, but think about what you would do if you were not to ignore them.
Add a spot light at one chandelier and at one entryway light as indicated in the text, and enable them to cast shadows.
- Clone the two lights above so that you get instances of those lights on the right side of the scene. The author's point is that instancing these lights will allow you to adjust both entryway lights (and both chandeliers) at once. That is a problem, however, if you want them to be different from each other.
- Add omni lights for fill lights and for ambient light.
- Save your file. Render a representative frame, and show it to me.
Bright sunshiny day
"I can see clearly now"? This exercise is on pages 110 and 111. The exercise uses the scanline renderer, but includes some features to make the light a little better.
- Another in a series of short exercises. Open the start file. This time begin with a direct light, like the outdoor scene. Follow the instructions in step 1 to set the shadow type for this light to ray traced shadows.
- The author placed some omni lights in the scene to simulate ambient light caused by the sunlight entering through the window. She turned on shadow casting for these lights, which works because the lights are in the middle of the room, but no props are in this location. Only a few shadows will be cast, by objects close to the walls. Configure the shadows for these lights as indicated in the text.
- Now for something completely different. She wants the window pane to glow with a render effect, to simulate a much brighter environment on the other side of the window.
Open the Material Editor and select the window pane material as shown on the bottom of page 111.
Change the Material ID Channel for this material to a new channel (not 0).
Follow the directions to create a Glow Effect, and configure its Material ID to the same number you used for the window pane material. The text says to adjust the Intensity and Size parameters for the effect to fine tune it. You may want to know that since this is a Render effect, you must view it in a render window to see it.
- As before, render a frame, save it to a file and show it to me for grading.
Mental Ray lighting
This exercise is on pages 114 and 115. The introduction to the exercise tells you how to switch from the scanline renderer to the mental ray renderer.
- The external scene already has all the changes in it that the author describes. You can load the scene and experiment with variations in her settings. The results of each change will be difficult to see. I suggest that you save each frame you render with some notation about the change you made, so you can examine the frames side by side in Photoshop to look for changes that produce differences.
- In step 2, the author has changed the ballroom scene to use Mental Ray. This scene displays the advantage of Mental Ray reflections much better. It also displays the difference in rendering time required by the Mental Ray renderer. Open the Light Lister, check her settings, and try some variations that occur to you.
- Steps 3 through 6 concern the same scene. Once again, open the scene and compare the original that you have seen before to this version.
As the chapter continues, the author provides a good illustration of shadows being used in a scene for two purposes: to establish the location of the light source, and to establish a location of the floor/ground in a scene. On pages 122 and 123, compare the three rendered images of the same scene. In the top left image, no shadows are being cast by any objects. The scene is fine as far as it goes, but it feels flat compared to the second and third images.
- In the second image, objects cast soft diffused shadows. In the third image, they cast sharply defined dark shadows.
- The streetlight and the mailbox cast shadows on the brick walkway. The author is illustrating the idea that an object with no shadow looks like it is floating in the scene. An appropriate shadow below the object defines its location in the space of the scene. The shadow also defines the location of the scene's light source(s) as much as the reflections from the surface of the object.
Pick your shadows
In the lesson on page 122, the author shows the differences between no shadows, soft shadows, and hard shadows in the same scene.
- Open the MailboxLit scene file. Add a material to the plane on the floor of the scene. The plane will now be able to show a shadow. Now consider the lesson.
The idea of no shadow at all is not likely to be useful, unless this is a scene that has no light in it. That is not the case in the author's example, so the scene looks unnatural. The effect was caused by unchecking the box for Shadows for the main light in the scene. Try this to see what the mailbox looks like with no shadow.
- Turn Shadows back on for the light in the scene. Consider the illustration for step 2 on page 123. The intent in this case is to show soft, fuzzy shadows, indicating that there is one main light source, and secondary light sources as well that wash out the shadows a great deal. Create fuzzy shadows by selecting Shadow Map from the dropdown below Shadows on the light source's General Parameters rollout. The settings to adjust are now available on the Shadow Map Params rollout. Make the Size value smaller, and the Sample Range value bigger until you are satisfied with a good soft shadow.
- As the author states in the text, it is easy to get sharp shadows if you select Ray Traced Shadows on the Shadows dropdown. Switch to that setting. You can use a map instead, but the point of the lesson is to do this the easy way. Make the change, and make sure to save an electronic copy of the render for each part of this lesson.
This lesson is on pages 124 and 125. The author's tip is to use two versions of an object in a scene, a complex one to see, and a simpler version of it to cast a simple shadow. Why? Casting a complex shadow takes up more rendering time.
- In the illustration, she shows us a tree with many branches and leaves. It looks nice on the camera, but she turns off its Cast Shadows property.
- She places a simpler geometric form in the scene to stand for a the tree: a tapered cylinder for the trunk and a sphere with a noise modifier for the leaves and branches. These are allowed to cast shadows, but they have their Visible to Camera properties turned off.
- Since there is no scene for this one, learn the idea and use it in a scene of your own. Another use of this technique is to make an object seem to cast a shadow that does not match the object.
Where's the shadow?
This lesson is on pages 126 and 127. The author runs through several things that would keep a shadow from appearing in a scene.
- For each light in the scene that is supposed to cast shadows, turn on the Shadows property.
For each object that is supposed to have a shadow, turn on its Cast Shadows property.
For each object that a shadow is supposed to be cast upon, turn on the object's Receive Shadows property. Each of these should be on by default, but they could be turned off.
- Shadows can be washed out by bright lights in the scene. Two ideas: make sure that the shadow casting light is the brightest one in the scene, and try to keep the total of all light multipliers in the scene below 3.
- An object that is completely self-illuminated will not receive shadows. Don't allow an object to be too self-illuminated.
- If light will not shine through a window, check the window's Cast Shadows property. Try turning it off. If it casts no shadow, light passes through it.
- Light sources that are too close to the ground in the scene will not cast a good shadow. Move the light source higher to get a better shadow.
- Pick one of the problems above, and apply it to a scene. A randomly selected student will be assigned to check your scene and correct the problem. It must be correctable by one of the methods above, or neither of you get credit.
What else can go wrong with shadows? This exercise is on pages 128 and 129.
- Shadow maps that are chunky, as illustrated on page 128, have too small a Sample Range. Increase the value of Sample Range.
- The illustration in this case is not clear, because we have no clear expectation of what the shadow map should look like. The tip is to adjust a shadow map's Size parameter if it looks wrong.
- This one is much easier to see. A shadow should appear connected to the object casting the shadow. If the shadow appears disconnected, change the Bias setting. A smaller value should place the shadow closer to the bottom of the object.
- This example bears some thought. If you look quickly at the images at the bottom of page 128, you may not notice the small difference between them. However, it is likely that the scene on the left would begin to feel wrong the longer you looked at it. The problem is that this is an outdoor, sunlit scene. The shadows of the two objects are not parallel. The reason they are not is explained in the text: Spot and Omni lights do not cast parallel shadows. Direct lights do cast parallel shadows. We could correct the problem by using individual spot lights for each object, casting a shadow only for that object. It would be better to use a Direct light instead to simulate the distant light of the sun.
- The lesson ends with some advice that you are probably not seeing shadows in your viewports, but you probably can choose to see them. The text tells you to click the Shading label in a viewport. This is the label to the right of the name of the viewport. Choose Lighting and Shadows, Enable Hardware Shading to see if this works with your video card.