Displacement Map Basics
The foundation of each track you make is a displacement map.
Question #1: What is a displacement map?
Answer: It's a greyscale image that you create by painting in a paint program like Photoshop. A greyscale image contains pixels that range from white to black with all shades of grey in between. The shades of grey in the image relate to the height of points on the terrain. The dark values are low points in the terrain and the bright values are the high points in the terrain.
A short discussion about color space might be in order. The most popular color space used in paint programs today is the R-G-B color space model. In this model each primary color value (red, green and blue) is represented by a numeric value ranging from 0 - 255, where 0 is completely dark and 255 is completely bright. Some examples are: 255,0,0 = bright red, 0,255,0 = bright green, 0,0,127 = blue at 50% brightness, 255,255,0 = yellow (by combining red and green).
Whenever the RGB values are all the same (such as 64,64,64 or 157,157,157) what you get is a grey pixel. So in a greyscale displacement map, all the color values have equal red, green and blue values.
Important: In Photoshop, your image needs to be "mode type" RGB, not greyscale. Even though the image you are painting is grey scale, make the image mode type RGB and save it as a 24-bit image.
![]()
Interesting Side bar: Traditional artists that paint on canvas are probably freaking out right about now because everything I've just explained goes against the way you mix paint to create colors. The difference between our analog world, and the digital computer is this: In the real world, we see subtractively where everything looks white until the surface properties of objects absorb certain spectrums of light. Everything an object doesn't absorb bounces back to our eye and we see as color. In the computer, everything works additively where you start with RGB 0,0,0 (black) and begin adding hues and luminance to create color. If our computer monitors were pure white when we turned them off, then the computer would function pretty much like real life. So the simple version is: real life subtracts color from pure white to create color, whereas the computer adds light to black to create color. Kinda cool huh?
Displacement Map Details
- The color depth, resolution and image format you paint the displacement map in is not
particularly important. Most of the maps created at Rainbow were painted in Photoshop as a
multi-layer Photoshop document, or .PSD file.
- The aspect of the source image should be square.
- We recommend painting your image at a resolution of about 512x512 or 1024x1024, but this
is for your visual convenience only.
- After saving your source displacement map, you should resize the image down to EXACTLY
257x257 pixels and then "Save a copy...." as a 24-bit targa file. It's
critically important that your image be precisely 257x257 pixels and that is a 24-bit
targa file, not 16-bit and not 32-bit with alpha channel
- Painting the displacement map at higher resolution is easier to see on the monitor as
you paint, resampling the image down to 257x257 helps smooth the surface of the map. Bumpy
terrain is not at all fun to ride on in the game.
- The edges of the displacement map MUST all be exactly the same color. This creates a
flat edge all the way around the perimeter of the track and facilitates each section of
terrain connecting seamless with it's neighbor.
Here is a sample displacement map from Motocross Madness. This image is the displacement map that became the Nationals track known as "Custer's Last Stand". Note: the sample images on these pages are compressed .jpg files, so things like all the edge pixels being the same value (as outlined above) might not be true due to the fact that JPG is a lossy compression. You shouldn't use these actual images to do any production work with. Use the images in the provided sample tracks downloads.

Question #2: How do I know how the greyscale values in my displacement map translate into height values in 3D world space?
Answer: The black values in your displacement map equate to 0.0 feet high in 3-space, and pure white values (RGB 255,255,255) equate to a height value you specify. The way you specify the scale differs depending on the method you use to convert your .tga file to an .asc file. The following section answers this question in greater detail for each method.
Question #3: How much actual land area will this displacement cover in 3D world space?
Answer: In the game, a 1x1 chunk of terrain covers 768 by 768 feet. An entire 7x7 stunt quarry is then 5376 x 5376 feet across.
Making ASC Files From Your Displacement Map
Once you have finished painting your displacement map at high resolution and saved a scaled copy of the image as a 257x257 24-bit targa file, there are two ways you create your .asc file.
Method 1 - Using the Tga2Asc.exe command line utility
The purpose of the Tga2Asc utility is to convert a 2D image such as your 257x257 targa file into a 3D terrain model in the popular .asc file format.
To use this utility, you need to open an MS-DOS command prompt session. You can do this by clicking on the "Start" menu on your task bar, choosing "Run..." and then typing "command" and pressing enter. This will open what is commonly known as a DOS box, or command prompt.
If you place the tga2asc.exe in your "path" you will be able to access it from any directory by simply typing the name of the program (tga2asc), otherwise you will have to have a copy of the utility in the same directory as the targa file you want to convert.
You can see all the command line arguments available simply by running Tga2Asc.exe with no command line parameters.
The command line parameters for Tga2Asc.exe are:
Tga2Asc InputTarga.tga HorzGridSpacing MaxHeight > YourNew.asc
For example: Lets say you have a 257x257 targa file named SILLY.TGA and you want to convert it to an .asc file named MYNEW.ASC where the brightest values in SILLY.TGA will become 15 feet tall peaks in the .asc file. You would use the following command line:
TGA2ASC SILLY.TGA 1 15 >MYNEW.ASC
In the above command line:
TGA2ASC is the name of the utility
- SILLY.TGA is your source 257x257 24-bit targa file displacement map
- 1 is the horizontal spacing between the points of your grid. (This should always be 1)
- 15 is the height that you want brightest (RGB 255,255,255) values in the .tga to
translate into feet in the .asc file so an RGB of 127,127,127 would yield a height value
of 7.5 feet.
- >MYNEW.ASC will send the output of Tga2Asc to a new .asc file named MYNEW.ASC
Note: The ">" character that precedes the MYNEW.ASC is an old MS-Dos symbol called re-direction. By default, Tga2Asc will just dump its output to the screen, which isn't must good. Using the re-direction symbol ">" followed by a valid filename will cause MS-DOS to re-direct a programs output to a file. So you always have to put the ">" right before the name of the output .asc file to get it to work correctly. The ">" is NOT part of the filename!
Method 2 - Using 3D Studio Max
Using 3D Studio Max is slightly more difficult then using Tga2Asc, but has a number of advantages. The most significant advantage is that once you've setup the grid and applied the displacement map to your grid object, you can then use this geometry to light and texture your track. This then allows you to easily create the high resolution texture map that drapes over the terrain in the game, complete with ray traced shadows.
Note: In order to complete these instructions, you must already have the Charityware Grid Plug-in installed in your copy of Max.
- Make sure your scale units is set to 1.0 units = 1.0 feet
- Launch Max and start with a new project
- Create a new Charityware Grid object
- Adjust the grid object so it is 256 length segments by 256 width segments
- Adjust the length and width parameters to 256 by 256 as well
- Center the grid object at 0,0,0 so it spans from -128 to +128
- Add a Displace modifier to the grid object
- Set the Strength to 15.0
- Assign your 257x257 version of your displacement .tga to the bitmap
- Set the blur strength to between 0.2 and 0.3
You should see the Grid object take the shape of your track. From the top view, it should
still appear as a perfectly uniform grid. But from the perspective view you can see the
shape of the peaks and valleys.
The last step is to output the object as an .asc file.
- Activate the Toolbar panel and choose ".ASC Output" utility.
- Click the "Pick Object" button and then click on the grid object.
Relevant Additional Knowledge About Displacements
Question: Why do I make grid that is 256x256 feet in my 3D program, when the same terrain covers 768 x768 in the actual game.
Answer: The reason is due to the fact that as we were coding the game, we didn't know for sure exactly how big we wanted a track to be. A lot depended on the outcome of the physics model which was concurrently under development. But we had to start modelling track before the physics model was final. We decided early on to model everything at 256 feet square, then scale everything up by an adjustable amount until the size of the terrain worked will with performance of the physics model. As it turned out, a scale of 3.0 works really well. This means that everything you model in Studio Max gets scaled by a factor of 3 by when you run the terrain builder.
This is important: Not only does the land area get scaled up from 256 ft. sq. to 768 ft. sq., but your hills that were up to 15 feet tall in 3D Studio, will be up to 45 feet tall in the game.
Of all the parameters that we've been carving in your brain as "in stone",
using a strength of 15 in your displacement is not one of them. All of the more planar, or
flat, tracks we made used the standard "maximum height" value of 15. Bela's
Bluegrass was the last track we made, and the first track to be based on the concept of a
track being built on a hilly piece of terrain. Brian used a displacement strength of 30 in
3D Studio, so the hills in Bela's Bluegrass are as much as 90 feet tall. Now that you know
this, * PLEASE * don't get carried away with making the world's tallest track. Remember,
the steeper the terrain, the less the engine can optimize polygons to keep the frame frame
high. Bela's Bluegrass is really pushing it as is!
Question: How well does the terrain engine handle extremely jagged
surfaces?
Answer: The engine can handle rendering jagged terrain fine, but it will drive the
polygon count through the roof and your frame rate will go in the toilet. This is bad.
Don't make jagged terrain! The general flow of your terrain should be smooth and flowing.
Abrupt changes in the terrain reduce the terrain engine's effectiveness at managing
polygons and will drive the polygon count up by the thousands.
Question: I want to have perfectly vertical cliff walls in my terrain. How do I do that?
Answer: You can't. Our terrain engine does not handle angles greater than 89.9999999
degrees steep. That means no perfectly vertical cliff walls and no cave-like structures.
Another good reason why NOT to have extremely steep surfaces is due to the way the ground
texture image is mapped onto the terrain. The terrain texture is planar mapped directly
from the top, surfaces that are too steep will tend to have only one or two pixels
representing them in the texture map and will therefore stretch real bad across those
steep faces and generally look unacceptable.
Question: What is "overdraw" and why do I care about lots of deep canyons?
Answer: Overdraw is an issue that can also kill the frame rate of a 3D game. In order to construct a complete picture on the screen, the 3D card in your computer may have to render each individual pixel on the screen more than once. For example, lets say you have a simple image where the camera is looking at the terrain in the foreground and there is a single bike and rider sitting there in clear view. The 3d card has no idea what actually covers up what in the 3d scene on each frame as it renders images. There's this thing called that Z-buffer that automatically manages how objects get laid on top of one another in a 3D scene. So the terrain engine renders the terrain, and on this frame the terrain happens to fill the entire screen. But then it has to render the bike and rider on top of the already rendered terrain. So the 3d card is now rendering over top of pixels it already rendered once for this image. Everywhere the 3D card is rendering pixels two or more times is called "Overdraw".
In the above example, the amount of overdraw introduced by a single bike and rider sitting on top of the terrain is completely trivial. They may occupy about 5% of the total pixels on the screen. A little bit of overdraw is always a factor in real-time 3d rendering.
Overdraw becomes a serious performance issue when you start making terrain filled with lots of canyons. An excellent example of some tracks with bad overdraw issues are Airborne Delivery and Dirt Devil. Both of these tracks have canyon after canyon within them with very high walls. Anytime the you are near the edge of the track, looking out across the rest of the track, all the canyon walls facing the camera, all the way to the edge of the track in the distance are getting rendered on top of one another. If there are 5 deep canyons across the track, you might be experiencing up to a 5.0 times overdraw factor. That means the 3d card has to render the entire screen 5 times to get one complete image on the screen. You can imagine what that does to the performance of the game.
Question: Do I really have to make all the edges of my displacement map the same color all the way around?
Answer: Absolutely! In order to take a 1x1 chunk of terrain and make it connect with additional copies of itself that are displaced at lower elevations, the edges must be flat. Sorry, but that's the way its designed.
For those of you who have the screwed up track named "Augusta's Evile Twin", the reason the terrain is screwed up around the edges is because the edges of the displacement don't match up. That also makes the podium appear underground...not to cool.
Note: The Evil Twin itself is really cool. The effect was achieved by simply adding a Wave Noise modifier to the original grid in Max. It twisted the whole terrain in a totally cool way, making the track a really fun challenge to ride. You could fix the edges by writing a max script to look edges of the terrain and force them all the the same elevation, then feather this adjustment in a few points from the edge to smooth out the correction.