DGUnreal Tips-UT 3 Digital Models for Terrain

 

Unreal Tournament III Tips and Information
This information is provided by DGUnreal.  Please do not copy this and post it elsewhere.

Utilizing Digital Elevation Models for Terrain

Unreal Engine 2, 2.5 and 3 used for creating titles such as Unreal 2, UT2004, UT3 and other games have specific limitations on the Terrain system.

Tutorial Topics:

- DEM Limitations
- 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.

Insert tut-terrainmodify-expg16.gif here

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.

tut-terrainmodify-expalpha.gif

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.

Insert tut-terrainmodify-impg16.gif here

Insert tut-terrainmodify-impg16b.gif here

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.

Insert tut-terrainmodify-impalpha.gif here

Insert tut-terrainmodify-impalpha2.gif here

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.

Insert tut-terrainmodify-smaller1.gif here

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 256×256 down to 128×128, 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 2×2 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.

Insert tut-terrainmodify-smaller2.gif here

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.

Insert tut-terrainmodify-smaller3.gif here

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 2×2 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.

Insert tut-terrainmodify-larger1.gif here

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 128×128 up to 256×256, 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 2×2 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.

tut-terrainmodify-larger2.gif

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

Insert tut-terrainmodify-larger3.gif here

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.

Insert tut-terrainmodify-larger1.gif here

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.

Insert tut-terrainmodify-extend2.gif

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 256×256 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 128×128 with TerrainScale.X/Y of 256 but found that the terrain lost too much of its detail.
An equivalent 192×192 terrain would probably work perfectly, however, UnrealEd does not support 192×192 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.

Insert tut-terrainmodify-smaller1.gif here

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 256×256 being too dense and 128×128 being too little detail, we would then resample the TIF and TGAs to 192×192.
In most cases you will want Anti-alias on in this instance.

Insert tut-terrainmodify-resample2.gif here

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, 256×256.
Alternately, if we didn’t require the entire large terrain area that 256×256 provided, we could Crop the image from 192×192 down to 128×128, keeping only the center portion of the Heightmap.

Insert tut-terrainmodify-resample3.gif here

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 256×256 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 128×128, in which case we lost area around the terrain perimeter.

With permission, I am hosting this information for the UT 3 editor.  A big thanks to DGUnreal for allowing this useful information to live on.  I duplicated the tutorials as they were given to me.  There may be information that was going to be added by DGUnreal. But take this information on this page as completed.

© 2010 Odedge Level Design Suffusion theme by Sayontan Sinha