Varcade Dev Blog

Generating Terrain with a Shadow Map

by on Mar.17, 2011, under Games, Graphics

A good bit of time was spent finding a technique to generate original levels / playfields.  I hope to be able to create a variety of different levels, some with a single enemy path, some with multiple paths, in a range of environments.  I ended up using Terrgen Classic to generate a terrain. The tricky part was figuring out how to ‘carve’ a custom paths into that terrain, but I think the results are pretty good.  By rendering a near overhead view, I was able to get the perspective to match that of my game units. Here is the results of the first test level.


Here is how the camera was setup in Terragen for an overhead shot:

The terrain itself is created using a gray scale height map. This can be generated in Terragen, or imported from a 3rd party app.  I started by first generating a random terrain in Terragen, exporting that to a paint program, and creating the paths ( roads ) by darkening  ( lowering ) them.

terragen landscape settings

Once you have a terrain created or imported, you will want to color it.  This is done with the surface map controls in the same dialog above.  The surface maps allow you to define color based on Altitude and Slope.


terragen surface layer controls


I was able to create a road by telling the surface below 280 meters and relatively flat to be gray.  A 2nd surface was created for the walls of my cannon roads, by coloring only terrain at a similar altitude, but with a much steeper slope .


Lastly, by rendering another version of the terrain without color, and high exposure, I was able to catch only the shadows and create a shadow map.

terragen shadowmap

This can be rendered using transparency in the XNA Sprite Batch after any ground units ( enemies ) so they appear to move into and out of shadows cast by the landscape.  Performance on the XBox doing a full screen overlay was fine.  It even worked well on a WP7 Phone.


terragen level, enemies, and shadowmap

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...