Unreal Tournament 2004 Level Design -
Tutorials
Modifying Terrain Size
Unreal Engine 2/2.5 for UT2004 and other games utilizing this engine have specific
limitations on the Terrain system. This includes the fact that the Terrain G16
heightmap is limited to power-of-two values such as 16, 32, 64, 128, 256 and 512.
During development of a map, often the level designer will encounter the issue where the
originally chosen Terrain Heightmap size in UnrealEd is either too small or too large, or
the level designer may wish that the terrain edges extended further out beyond what was
originally created.
This set of tutorials will cover indepth step-by-step techniques for modifying the terrain
heightmap, including decreasing the heightmap size to the next smaller power-of-two size,
increasing the heightmap size to the next larger power-of-two size, extending the
heightmap perimeter by adding additional triangles around the edges, and finally a
combined version of this that allows for creating heightmaps that are halfway between two
heightmap power-of-two sizes.
Unreal Engine Licensees may use the HMES software by DGUnreal to perform these tasks
significantly easier.
Tutorial Topics:
- Exporting Terrain assets
- Importing Terrain assets
- Decreasing Heightmap Size
- Increasing Heightmap Size
- Extending Heightmap Edges
- Resampling Heightmap Size
Required Hardware and Software:
- A PC compatible computer with Windows 2000, XP or Vista
- A UE2/2.5 based game such as Unreal Tournament 2004, Unreal 2, Red Orchestra,
Tribes:Vengeance, etc.
- DGUG16 File Conversion Software (available as a free download on this web site)
- Adobe PhotoShop or Corel PhotoPaint (a version that supports 16-bit Grayscale TIFF-16)
Notes:
This set of tutorials assumes that you already have an existing Terrain created in your
map file, and does not cover the steps to creating a new Terrain.
It is recommended that level designers create the Terrain Heightmap and Alphamaps in the
map's "myLevel" package which is saved internally in the map. The
recommended Group names for the terrain assets are "Heightmaps" and
"Alphamaps".
Be aware that importing and overwriting an existing terrain Heightmap will reset all
Terrain Editing for "Visibility" and "Edge Turn" back to the defaults
for each quad and edge. In other words, any quads that were set invisible or any
edges that were turned, are cleared back to their normal state when the Heightmap file is
imported and overwritten.
Exporting Terrain assets
UnrealEd for most UE2.5 based games supports exporting and importing the G16 Heightmap and
TGA RGBA8 Alphamaps.
To Export the G16, use the Textures Browser dialog, locate the G16 Heightmap asset,
right-click and choose Export to File. The G16 exports as a special custom .bmp file
similar to a Windows bitmap image, but instead of containing a color or grayscale image it
contains 16-bit Heightmap altitude data. Attempting to directly modify a G16 .bmp
using standard paint software will damage the information in the file.

To export the Alphamaps, use the Textures Browser dialog, locate the RGBA8 Alphamaps
assets, right-click and choose Export to File. Do this for all Alphamaps for Layers
and Decorations for a Terrain that you are going to modify. The Alphamaps export as
standard uncompressed 32-bit TGA image files where the Alpha channel contains the alphamap
data and the RGB channels contain gray 127:127:127.

Importing Terrain assets
UnrealEd for most UE2.5 based games supports exporting and importing the G16 Heightmap and
TGA RGBA8 Alphamaps.
Note that importing the G16 will overwrite the current G16 of the same name in UnrealEd,
which is what you normally want to do.
To import a G16, use the Textures Browser dialog, locate the G16 Heightmap Group and G16
asset, on the browser File Menu choose Import and navigate your hard drive to the G16 file
to import, select it and choose the Open button.
On the import dialog, be sure to uncheck the Generate MipMaps checkbox.
Once the G16 and Alphamaps are imported, the TerrainInfo properties will have to be
changed accordingly, see the appropriate tutorial section for the type of modification you
are performing. If you are simply updating the existing assets without changing
their size, you can simply re-type in the TerrainInfo.TerrainScale.Z value to have the
UnrealEd viewport renderer update the terrain view.


Note that importing any Alphamap will overwrite the current Alphamap of the same name in
UnrealEd, which is what you normally want to do.
To import an Alphamap, use the Textures Browser dialog, locate the Alphamaps Group and
RGBA8 assets, on the browser File Menu choose Import and navigate your hard drive to the
TGA file(s) to import, select one or more and choose the Open button.
On the import dialog, be sure to uncheck the Generate MipMaps checkbox.
Once the G16 and Alphamaps are imported, the TerrainInfo properties will have to be
changed accordingly, see the appropriate tutorial section for the type of modification you
are performing. If you are simply updating the existing assets without changing
their size, you can simply re-type in the TerrainInfo.TerrainScale.Z value to have the
UnrealEd viewport renderer update the terrain view.


Decreasing Heightmap Size
Changing the Heightmap to the next smaller power-of-two size.
This is a partially destructive modification to the terrain as the altitude data
is reduced to 1/4th the amount of data. In many cases this change may not be visibly
destructive to the terrain look other than a decrease in overall terrain detail.
Often the originally chosen Heightmap size when creating a map may be too large and dense,
resulting on a large map file size and a low in-game framerate.
In UT2004, the "stat render" console command can be used to determine what the
current terrain rendered triangle count is.
1. Export the G16 Heightmap and Alphamaps as outlined above.
2. Convert the G16 .bmp file to a 16-bit grayscale TIFF image file using DGUG16.
This is accomplished simply by opening the G16 Heightmap file in DGUG16, then do a Save As
and choose TIF 16-bit grayscale format.
3. Open the TIFF-16 and TGA files in PhotoShop/PhotoPaint.

4. For each open asset, use the Resample function in the paint software to change the
image dimensions to the next smaller power-of-two value. So if you wish to resize a
terrain from 256x256 down to 128x128, choose the appropriate Resample values of 128 or
50%.
Note that if you set Anti-alias unchecked (off), the resample will simply remove every
second Heightmap altitude values in both the x and y dimensions. Whereas if you
leave Anti-alias checked (on), the resample will calculate the intermediate value between
each 2x2 block of Heightmap altitude values. In most cases you will want Anti-alias
off, especially if you have already placed staticmeshes into the map and aligned them with
the terrain. If Anti-alias is on, the altitudes of the terrain will usually be moved
more from their original location.

An example of reducing the Heightmap by a factor of two (resample to 50%).
Every second altitude value is removed.
If the Heightmap is thought of as a bitmap image, every second row and every second column
of pixels are deleted.

5. Save the modified TIFF-16 Heightmap and TGA Alphamaps back out to disk.
6. Convert the TIFF-16 back to an Unreal G16 Heightmap using DGUG16.
7. Import the G16 Heightmap and TGA Alphamaps into UnrealEd as outlined above, overwriting
the existing assets.
8. Locate and select the TerrainInfo actor, and view its Properties.
To have the terrain fill the same area, increase the TerrainInfo.TerrainScale.X/Y by the
opposite amount that you reduced the Heightmap size. So if you reduced the heightmap
to 1/2 the size, then double the TerrainScale.X/Y. In other words, if your
TerrainScale.X/Y were both 256, then change them to 512. Note that the
TerrainScale.X/Y values are the number of Unreal Units square that each Terrain quad
occupies.
Increasing Heightmap Size
Changing the Heightmap to the next larger power-of-two size.
This is a partially destructive modification to the terrain as the altitude data
is changed to a repeated 2x2 or more increase of the original data. In most cases
this change will not be visibly destructive to the terrain look since each triangle vertex
is simply doubled in each direction.
Often the originally chosen Heightmap size when creating a map may be too small and lacks
sufficient triangles to see or create a lot of terrain detail. Or the level designer
may choose to increase the entire terrain size so that it covers a larger area.
1. Export the G16 Heightmap and Alphamaps as outlined above.
2. Convert the G16 .bmp file to a 16-bit grayscale TIFF image file using DGUG16.
This is accomplished simply by opening the G16 Heightmap file in DGUG16, then do a Save As
and choose TIF 16-bit grayscale format.
3. Open the TIFF-16 and TGA files in PhotoShop/PhotoPaint.

4. For each open asset, use the Resample function in the paint software to change the
image dimensions to the next larger power-of-two value. So if you wish to resize a
terrain from 128x128 up to 256x256, choose the appropriate Resample values of 256 or 200%.
Note that if you set Anti-alias unchecked (off), the resample will simply change every
Heightmap altitude value in both the x and y dimension to an equivalent 2x2 block of the
same values. Whereas if you leave Anti-alias checked (on), the resample may smoothen
between adjacent altitude values. In most cases you will want Anti-alias off.

An example of increasing the Heightmap by a factor of two (resample to 200%).
Every altitude value is expanded into a 2x2 block of the same value.
If the Heightmap is thought of as a bitmap image, every pixel becomes a 2x2 block of
pixels.

5. Save the modified TIFF-16 Heightmap and TGA Alphamaps back out to disk.
6. Convert the TIFF-16 back to an Unreal G16 Heightmap using DGUG16.
7. Import the G16 Heightmap and TGA Alphamaps into UnrealEd as outlined above, overwriting
the existing assets.
8. Locate and select the TerrainInfo actor, and view its Properties.
To have the terrain fill the same area, decrease the TerrainInfo.TerrainScale.X/Y by the
opposite amount that you increased the Heightmap size. So if you increased the
heightmap to 2x the size, then change the TerrainScale.X/Y to half the value it currently
is. In other words, if your TerrainScale.X/Y were both 256, then change them to 128.
Note that the TerrainScale.X/Y values are the number of Unreal Units square that
each Terrain quad occupies.
Extending Heightmap Edges
Adding additional triangles around the perimeter of the Heightmap.
This is a non-destructive modification to the terrain and increases the overall area that
the terrain occupies.
Often the originally chosen Heightmap size when creating a map may be too small and
additional terrain space is required beyond the edge of that which is currently available.
1. Export the G16 Heightmap and Alphamaps as outlined above.
2. Convert the G16 .bmp file to a 16-bit grayscale TIFF image file using DGUG16.
This is accomplished simply by opening the G16 Heightmap file in DGUG16, then do a Save As
and choose TIF 16-bit grayscale format.
3. Open the TIFF-16 and TGA files in PhotoShop/PhotoPaint.

4. For each open asset, use the PaperSize function in the paint software to add additional
space around the perimeter of the image and increase its overall dimensions to the next
larger power-of-two value. Increasing papersize to the next available power-of-two
value will add 50% more terrain area on each side of the current terrain.
Normally you will want the existing terrain Heightmap area to be centered in the new
larger area. The edge fill color value is also usually best set to 127, which will
translate to 32767 in 16-bits which is the middle (sea-level) altitude.

5. Save the modified TIFF-16 Heightmap and TGA Alphamaps back out to disk.
6. Convert the TIFF-16 back to an Unreal G16 Heightmap using DGUG16.
7. Import the G16 Heightmap and TGA Alphamaps into UnrealEd as outlined above, overwriting
the existing assets.
8. Locate and select the TerrainInfo actor, and view its Properties.
Simply re-type in the same TerrainInfo.TerrainScale.Z value to have the viewport renderer
update the views. The terrain should now occupy 50% more area on each side.
Resampling Heightmap Size
Changing the Heightmap size to an intermediary value and cropping or extending the edges
to the next larger power-of-two size.
This is a destructive modification to the terrain as the altitude data is changed.
Often the originally chosen Heightmap size when creating a map may be too small or too
large, and the next smaller or next larger Heightmap size may not work appropriately
either. In this case, an intermediary value may work best.
As an example, let's say that you created a 256x256 terrain with a TerrainScale.X/Y of 128
but found that the terrain triangles were too dense and impacted the in-game framerate.
So you tried a Heightmap reduction to 128x128 with TerrainScale.X/Y of 256 but
found that the terrain lost too much of its detail.
An equivalent 192x192 terrain would probably work perfectly, however, UnrealEd does not
support 192x192 as a valid Heightmap size.
To fix this you can do the following:
1. Export the G16 Heightmap and Alphamaps as outlined above.
2. Convert the G16 .bmp file to a 16-bit grayscale TIFF image file using DGUG16.
This is accomplished simply by opening the G16 Heightmap file in DGUG16, then do a Save As
and choose TIF 16-bit grayscale format.
3. Open the TIFF-16 and TGA files in PhotoShop/PhotoPaint.

4. For each open asset, use the Resample function in the paint software to change the
image dimensions to the exact intermediate value. So in our example of 256x256 being
too dense and 128x128 being too little detail, we would then resample the TIF and TGAs to
192x192.
In most cases you will want Anti-alias on in this instance.

5. Since the G16 and Alphamaps are no longer UnrealEd supported power-of-two size, we must
then add padding around their edge to bring them up to the next available power-of-two
size, in this case, 256x256.
Alternately, if we didn't require the entire large terrain area that 256x256 provided, we
could Crop the image from 192x192 down to 128x128, keeping only the center portion of the
Heightmap.

6. Save the modified TIFF-16 Heightmap and TGA Alphamaps back out to disk.
7. Convert the TIFF-16 back to an Unreal G16 Heightmap using DGUG16.
8. Import the G16 Heightmap and TGA Alphamaps into UnrealEd as outlined above, overwriting
the existing assets.
9. Locate and select the TerrainInfo actor, and view its Properties.
Since we essentially created an intermediary terrain size, in order for the original
resampled portion of it to cover the same area as it did before and match up with any
staticmeshes we may have already placed, the TerrainInfo.TerrainScale.X/Y values will have
to be adjusted by the amount that we resampled. So in this case, since our example
original 256x256 terrain had a TerrainScale.X/Y of 128, our modified terrain will have a
TerrainScale.X/Y of 192.
The additional bonus of this technique, is that we also gain almost 20% more terrain area
on each side. Unless we chose to use the Crop down to 128x128, in which case we lost
area around the terrain perimeter.
|