This site hosted by Free.ProHosting.com
Google
main page
News Import/Export Rendering Links
Taelon's gmax Tutorials

Tutorial 6


Animation and Projected Shadows, Part One.

Tutorial 6 image

 

Other On Site Tutorials

Animation & Projected Shadows, Part One

gmax lacks rendering capabilities beyond what is shown in the Viewports, simply because it's intended use is for creating models for game pack supported games which can then be rendered using the in-game engine. However, sometimes we just want to model something for fun, or to show friends and family, post on a webpage, etc. But without a built-in renderer to project shadows, objects in our scenes can often look as if they are floating. Shadows help to "ground" an object and make the scene look more realistic.

Tutorial 4 shows a way to create fake viewport shadows using Vertex Colors, this tutorial will demonstrate an entirely different technique.

Here we will create a simple shadow map mask in a paint program, then create an animation for an object and it's shadow to demonstrate that realistic animated shadows aren't beyond the reach of the gmax viewport. Then in Part 2, we will expand the scene by adding constraints and controllers which opens the door to a near infinite number of possibilities for viewport scene animation.

 

Step 1) Create the Shadow Map

First we need to create our fake shadow. Probably the easiest way to do this is to create a mask that will be transparent everywhere except where we want the shadow to be, and opaque where we need the shadow. Since gmax allows us to use a separate "Opacity Map" when creating a Material there are a number ways we could create the mask. Some image file formats even support internal alpha channels, but to keep this easy and to show you a method that anyone with access to a simple paint program can use, we will create a separate image to use as the mask as the "Opacity Map" in gmax.
  1. Open your paint program and create a New Grayscale Image 128 x 128 pixels.
  2. Since we want the background to be completely transparent, it needs to be pure black (R,G,B = 0,0,0).
  3. Next create a circle in pure white (R,G,B = 255, 255, 255) that nearly fills the entire image.
  4. Depending on the paint program you are using you can blur the image, or use anti-aliasing to get rid of the stepped edges.
  5. Save the Image where you can easily find it from gmax for example in the \GMAX\Maps folder as "Ball_Shadow.bmp"
Note: You can Rt. click and "Save As" the first tutorial image if you're too lazy to create your own ;)

Step 2) Create a Sphere

Start gmax or select "File" > "Reset" to start a new scene.
  1. In the Create tab of the Command Panel,
  2. Select the "Geometry" button, make sure "Standard Primitives" is selected from the drop-down list.
  3. Select Object type "Sphere".
  4. Open the Keyboard Entry rollout.
  5. Set location X=0, Y=0, Z=0.5
  6. Radius=0.5
  7. Optional, change the name to "Ball" and adjust the color by clicking on the color swatch.
  8. Be sure to select "Generate Mapping Coords".
Step 3) Create a Plane

  1. Create > Geometry > Standard Primitives
  2. Select Object type "Plane"
  3. Open the Keyboard Entry rollout.
  4. Set Length=1.0, Width=1.0
  5. Length Segs=1, Width Segs=1
  6. Optional, change the name and adjust the color by clicking on the color swatch.
  7. Be sure to select "Generate Mapping Coords".
Rt. click anywhere in the active viewport to get out of Create mode.

Step 1 shadow map

Step 2 sphere Step 3 plane
(Note: Creating New Materials and Assigning Maps was illustrated in greater detail in Tutorials 1 and 4.)

Step 4) Create the Ball Material
  1. Click on the "Ball" to select it.
  2. Open the Material Editor
  3. Create a New "Standard" Material
  4. Press the button next to the Diffuse color swatch

    The Material Navigator window opens
  5. Double click the Checker Material in the Material Navigator.
  6. The Material Editor should now show a checker material on the Material Sphere, with Name: Map #1
  7. Change the U and V Tiling values to 3
  8. Making sure that the "Ball" is selected in the Viewport press the "Apply" button
  9. Press the "Show Map in Viewport" button.
The "Ball" in the viewport should now show the Checker pattern and resemble a black and white beach ball.

Step 5) Create the Plane Material
  1. Select the Plane in the viewport.
  2. In the Material Editor press the "New" button
  3. Create a New "Standard" Material
  4. Click on the Diffuse color swatch

    The Diffuse Color Selector window opens
  5. Move the "Whiteness" slider to the top so that all the values equal 0 (pure black), then press the close button.
The Material Editor sphere should now look black.

  1. Change the Name to "Ball_Shadow" and press the "Apply" button.
The plane should turn black in the viewport.

  1. Next, in the Material Editor open the Maps rollout and press the button labeled "None" next to "Opacity".

    The Material Navigator window opens
  2. Double Click "Bitmap" in the Material Navigator.
  3. Navigate to the folder where you earlier saved "Ball_Shadow.bmp" highlight it, and click the "Open" button.
  4. In the Material Editor, Press the "Goto Parent" button.
  5. Press the "Show Map in Viewport" button.
You should now see the round shadow shape on the plane underneath the ball.

Step 4 checker Step 5 shadow
Using the Opacity Map as a Shadow Map

To understand what you're seeing, click on the Diffuse Color swatch and adjust the color.

The color of the shadow will change as you make adjustments, this corresponds to the White (Opaque area) of the "Opacity Map".

However since the Black area of the opacity map applies a full transparency to the material it doesn't matter what color we assign to the Diffuse color slot, those areas will remain transparent.

Return the diffuse color to Black or near Black since this is going to represent the Shadow of our ball, and close the Material Editor.
Tute 6 shadow map
Animation Basics

Nearly anything you can create in gmax can be animated. Objects, sub-objects, modifiers, lights, cameras, material map coordinates, etc. can all be manipulated and animated.

Step 6) Time Configuration
  1. Click the Time Configuration button OR Rt. click on any of the buttons in the time control panel
  2. In the Time Configuration window change the Frame Rate to "Custom"
  3. Change FPS=20
  4. Change the Animation End Time to 159 then click "OK"
Since the gmax default start time is always 0, this gives us 160 frames total, or 8 seconds for our animation at 20 Frames per Second.

  1. Press the "Animate" button, it turns red and a red border surrounds the active window to show that we are in animate mode.
Step 7) Animate the Ball
  1. Select the Ball
  2. Enter "Select and Move" mode by pressing the button on the Main Toolbar
  3. Move the animation slider bar to frame 10.
  4. Type in Z=5.5 in the coordinate display.
The ball may have moved up and out of your Viewports (if so, zoom your view out or press the zoom extents button) you should also notice blue bars appeared in the Track Bar at frame 10 and another at frame 0.

The blue bars represent our "Key Frames" and are required any time we want to significantly alter a transform (direction, rotation, scale, etc.) in the animation. We don't need to animate every single frame like traditional hand-drawn animation was done, instead we designate key frames and the movement between them is automatically calculated and generated by the software.

Step 8) Copy Key frame 0
  1. Press and hold the shift key on your keyboard,
  2. Select the blue bar at key frame 0
    (it will turn green when selected)
  3. Keep the mouse button held and drag the key to frame 20, then release.
    (This copied the data in frame 0 to frame 20.)
Move the time slider back and forth between 0 and 20, the ball should look like it's bouncing.
Step 6 time cp

Step 6 time config

Step 7 select

Step 7 slider

Step 7 animate
Step 9) The Track View Window

  1. Rt. Click over the ball and select "Track View Selected"
This opens up the Track View window which allows editing of animation keys and parameters far beyond what can be accomplished from the Track Bar.
Step 9 TV select
Step 9) The Track View Window (cont.)

  1. In the left pane of the track view window, Rt. Click the Ball and select "Expand Tracks"
    a whole bunch of items will cascade showing the transform functions, object and even Material and Map parameters.
  2. Select "Position" (it should highlight)
    (Notice the dots in the right window, they correspond to the position keys that were set in Steps 7 & 8.)
  3. Press the "Parameter Curve Out-of-Range Types" button.

Step 9 Track View
Step 9) The Track View Window (cont.)

In the "Parameter Curve Out-of-Range Types" window
  1. Select "Loop" then press "OK".
  2. Close the Track View window.
Put simply, this will take the animation defined in frames 0 to 20 and will cause it to "Loop" for the entire 160 frames of the animation, saving us from having to copy the key frames multiple times.

To verify it, press the "Play" button and watch the ball, it should bounce 8 times before the time slider returns to 0 to repeat.

Step 9 TV loop
Step 10) Animate the Opacity Map

Now that we have the animation of a bouncing ball we'll animate the fake shadow map. In this case we will assume that the scene is set outdoors around noon, or in a large room with a bright overhead light.

The main points to consider when faking a shadow are the direction, distance and intensity of the light source in relation to the object and the direction and distance to the surface where the shadow is being projected.
  1. Open the Material Navigator.
  2. Be sure that "Browse from Entire Scene" is selected
  3. Double click on the "Opacity Map" of the Plane01 Material.

    The Material Editor window opens showing the Map parameters of the Opacity Map.
  4. Close the Material Navigator window to get it out of the way.
  5. Move the time slider to frame 10 and be sure the Animate button is on
  6. In the Material Editor window set U and V Tiling to 5
  7. Uncheck both U and V "Tile" to turn off wrapping the tiled image.
This creates a new key at frame 10 and also gmax automatically created a key at frame 0.

You should see that the opaque (white) area of the opacity map is now very small, this corresponds to a small shadow in our display when the ball is at the top of it's bounce (the furthest point from the "floor" where the shadow is projected).
  1. Now move the time slider to frame 20,
  2. Change Tiling for U and V to 1 to complete the cycle.
  3. Close the Material Editor window.
Now if you scrub the time slider back and forth from frame 0 to 20 you should see the shadow map shrink and grow in-sync with the position of the ball in the air.
Step 10 Opac map Step 10 UVW tile
Step 11) Loop it
  1. Select the Plane01 in any viewport and Rt. Click over it,
  2. Select "Track View Selected" (as shown in Step 9)a )
Similar to when we looked at the track view for the ball earlier, we can see parameters for the Plane01 object, the assigned maps, etc.
  1. In the left pane of the Track View Window, look under Maps > Coordinates
  2. Hold the shift key and click on both "U Tiling" and "V Tiling".
  3. With both items highlighted click on the "Parameter Curve Out-of-Range Types" button,
  4. Select "Loop" (as shown in Step 9)e ) and press "OK".
  5. Close the Track View window.
Press the play button, you should see the shadow animation loop in-sync with the ball bouncing animation through all 160 frames.
  1. Turn off the Animate button and Save the Scene.
How about that, with only 6 key frames we've created a 160 frame animation!

You could easily expand this technique by simply taking a screen capture of any model, then in a paint program use White to paint over the model, and use Black to fill-in the background. Apply the image to a plane in the Opacity Map Channel as we did above and Voila! you have a "fake projected shadow" for anything that you can model. Think of the possibilities, and don't be afraid to experiment!

Step 11 loop it
Step 12) Dummy Helper

A Dummy helper object is a wireframe cube with a pivot point at its geometric center. It has a name but no parameters, you can't modify it. Its only real feature is its pivot, used as a center for transforms. A dummy is most often used to animate the motion of linked objects, lights and cameras in a scene.

  1. In the Create tab of the Command Panel,
  2. Select the "Helpers" button, be sure "Standard" is selected in the drop-down list.
  3. Select Object Type "Dummy".
  4. In the top viewport click near the center of the ball and drag until the dummy object is approx. the same size as the ball.
  5. Rt. click in the active viewport to end create mode
Step 12 Dummy
Step 13) Align the Dummy

Aligning one object to another is often required when modeling, and is critical to properly apply transformations across a hierarchy during animation. Although it's possible to align objects manually, it's far easier and more accurate to use the built-in "Align" tool.
  1. Make sure the Dummy01 object is selected,
    Select the "Align" tool from the Main Menu

    Notice that the mouse cursor changes shape to indicate you are in "Align" mode
  2. Hover the mouse over "Plane01" in the viewport
  3. When the name "Plane01" appears, click it
    The "Align Selection" window opens
  1. Set Current Object (Dummy01) and
    Target Object (Plane01) to Center
  2. Select X, Y and Z position.
    Notice that the Dummy object moves slightly as each axis is selected, eliminating any misalignment.
  3. Press the Apply button to lock in the changes, then press OK
Step 13 Align Tool Step 13 Align Plane Step 13 Align Selection
Step 14) Linking

Links are used to build a hierarchy of a parent and one or more child objects. Once objects are linked, any transformations applied to the parent are also applied to its children.

Here we will link both the ball and it's shadow to the dummy, then animate the dummy's position. The ball and shadow will then play their animations independently as they follow the dummy in the scene.

  1. Press the "Select by Name" button in the Main Menu

    In the "Select Objects" window
  2. Select the "Ball" object from the list, then Press and Hold the Ctrl key on your keyboard and select the "Plane01" object from the list.
  3. With both objects highlighted, press the Select button, the window closes.
  4. Press the "Select and Link" button in the Main Menu

    The "Select Parent" window opens
  5. Select "Dummy01" then press the Link button, the window closes.
Verify the objects were linked properly
  1. Press the "Select by Name" button in the Main Menu

  2. Select "Display Subtree" in the Select Objects window

    Notice that Dummy01 is listed first since it is the "Parent" object, below it and indented are the the Ball and Plane objects which are the "child" objects of Dummy01.
  3. Click on the Dummy01 object in the list to highlight it.
  4. Press the Select button, the window closes.
  5. Save your Scene as "ball_bounce01" or similar.
Move the Dummy object around the screen, the child objects should follow.
Step 14 Main Menu Step 14 Select Objects Step 14 Select Parent
Step 15) Test the Animation

Create a simple animation to see it in action.

    The dummy object should be selected and you should be in "Select and Move" mode
  1. Move the time slider to 80,
  2. Zoom out your view in the top viewport
  3. Press the Animate button
  4. Move the Dummy across the viewport
  5. Key frames should be automatically created at frame 80 and 0
  6. Press and hold the shift key and slide the key at 0 to time 160
  7. Turn off the Animate button and press play
You should see the ball and plane follow the dummy across the screen and back to the start point while independently playing the bounce animation we created earlier.

Feel free to experiment with the animation of the Dummy, but DO NOT save your scene over the "ball_bounce01" file.

We will be using the "ball_bounce01" scene saved in Step 14 in part two of the tutorial.

This concludes Part 1 of this tutorial.

In Part Two, we will use an Array to create a spiral staircase, then add a helix shape and use a path constraint to move the bouncing ball along the helix to animate the ball bouncing down the stairs.
ball bounce

This is a screencap of frame 19 of this animation tutorial.

I used the "Show Ghosting" display option found in the Main Menu > Views > Show Ghosting

Then in the Main Menu > Customize > Preferences > Viewports Tab, under "Ghosting" set;

Ghosting Frames = 10, Display Nth Frame = 2,
Ghost before and after current frame, Ghost in Wireframe


 

If you find any errors or have difficulty following this tutorial,
please post in the forum or contact me at the Email address below. Thanks!


top of page



 

Tutorial created on 8-Aug-2003
All content is Copyright © Taelon 2003, unless otherwise noted.
Page updated on 18-Aug-2003