Author Topic:   Landscape shadows
posted October 16, 1999 01:27 PM            

I have been thinking about how to do realtime shadows in a landscape
environment. If you have seen MotoCross Madness... this is exactly the
sort of thing that I would like to do.
Does anyone have any idea how this is done? Are they actually altering
the terrain texture? Is it some sort of overlay that molds to fit the
countours of the ground perfectly? Maybe vertex lighting? (but has to
be sure to be very highly tessellated to look right.)

Any ideas?


LDA Seumas
posted October 16, 1999 10:51 PM           
Rendering the shadows on the landscape is just another aspect of terrain lighting, so however you render the normal shading of terrain (light map, baked in lighting, vertex lighting), the shadows should work the same, as areas of terrain shaded to the base ambient intensity only.

The calculation of the shadowed areas shouldn't be too difficult. Just use a raycasting algorithm similar to what you might use to render a height map in software, only instead of casting rays from a camera with perspective, cast them in parallel from the direction of your infinite light source. The idea is you cast one ray down to the terrain, and then proceed to walk it forwards; if it pushes into a higher bit of terrain, you move its end point up to rest on the terrain, and declare that spot lit; if it "falls off" the terrain and steps into open air, you declare the spot of terrain directly under it to be in shadow, and step the ray forwards again, etc.

To render the shadow of the terrain onto 3D objects, I would build a Shadow Volume Height Map, which would hold the vertical height of the light rays used to choose areas of terrain as shadowed and lit. When rendering objects, you would test to see if each vertex was below the top of the shadow volume map, and if it was, light it as if it were in shadow. The shadow volume map could also be directly used to determine terrain shadowing, by comparing the two heights; if the shadow volume height is greater than the terrain height, the terrain is in shadow, but if the terrain and shadow volume heights are equal, it is in the light.

And no, I haven't done any of this in Tread Marks yet, since recalculating terrain shadows in real time after landscape modification might be a little tricky, especially with the wrapping nature of the terrain. But I'm sure it would be possible.

-- Seumas McNally, Lead Programmer, Longbow Digital Arts