Terrain Development Guide
Chapter 2: In Depth - Basic Terrain
Terrain Ecology Map
The Terrain Ecology Map contains the information the graphics engine needs to place textures representing land cover (forests, fields, desert, etc) onto the terrain. The ecology map, like the elevation map, uses a raster format so that every square in the terrain grid can have a texture assigned to it.

Graphics Format for Ecology Map
The terrain-texture assignments are contained within the structure of the Targa (.tga) graphics file format. See the Chapter 4 for some additional information on the file structure if you aren't familiar with it.
Specifically, the Targa (.tga) file must adhere to the following specifications:
- 256 color image
- 24-bit (RGB) Color-Indexed (mapped) palette
- 8-bit indices (data, pixels)
- Non-compressed
The format of the Terrain Ecology Map is very similar to that of the Elevation Map. However, instead of the palette values assigned to each pixel corresponding to an elevation, the values/colors assigned to pixels in the ecology map represent identification numbers that correspond to a particular land cover type (forest, field, desert, etc) that you specify in the Terrain Descriptor File.
Just like the elevation map, the format of the ecology map allows 256 different palette values; therefore, a choice of 256 unique textures can be made available at any point in the terrain. Below is a snippet from an ecology map with a few locations identified by palette number (color) and terrain type:

If each color in the palette is unique, you can use your graphics editor to paint your terrain. For example, in the figure above, palette value 198 (blue) represents Forest. Therefore, if you want to put some forests down on your terrain, simply paint those areas with that color. Same goes for Towns (green) and Fields (purple).
Hint:
Whenever painting, make sure the colour you are using has the proper palette value. The palette value should match the value used for that particular terrain type in the Terrain Descriptor File. For example, if Towns are value 15, make sure the colour you are using has palette index value 15 as well. Most graphics editors provide this information, as well as a means to edit the palette.
How the Ecology Map is Used
Application of the Ecology map is pretty simple. The terrain engine "lays" the ecology map onto the terrain grid matching the index values in the ecology map to the grid squares. From that, each polygon corresponding to that square is filled with the texture assigned to that index value, by you, in the Terrain Descriptor File.
Ecology Map Texture Scale
Texture scale can be set for each Layer in a terrain. It is controlled by the scale setting defined in the Terrain Descriptor File:
[Layer 1]
map = pngsolomons_ecosystem.tga
scale = 0.25
height = 0
blend = 1
num_textures = 20
If a value of '1' is used, then each square in the terrain grid will be filled with the entire image provided by the applicable texture file.

However, if a value of '0.25' is used (as in the example above), then the square will use only 1/16 of that image (4x4 grid squares will be needed to hold the entire image).

The ability to scale your ecology textures becomes extremely helpful when you use elevation scales that are small. A couple of reasons for this:
- If you have to repeat the same texture in each small grid square you will notice an annoying tiling pattern appears. Spreading over multiple tiles makes patterns less obvious, especially when the elevations are changing across it.
- Some terrain types simply are larger than a single grid square. If you are putting down farms, for example, they may not all fit appropriately size-wise within a single small grid square. It may only look appropriately sized when spread over several squares.
One final note. It is important that you understand how your texture relates to distance in the game-world. This is so you can correctly size any objects that may appear in your texture. Otherwise you may end up with very small/large farm fields, or very wide/narrow roads, etc. To determine what size your texture tiles will be in the game-world, simple take the Elevation Map scale and divide by the Ecology Map scale (e.g. 250 / 0.25 = 1000 m).
Hint:
Our experience at Targetware is that a scale corresponding to 1000x1000 meters provides a nice texture size. This would correspond to a scale of 0.25 when using an elevation grid of 250 meters spacing.
Detailed Example of Placing Ecology Textures
The following is a more detailed example of how texture layers are placed. This example is from the Target Rabaul mod.
Let's look at how this works. Here is a 16 pixel by 16 pixel chunk of the ecology map:

Since the Target Rabaul texture tiles are at 1000m/tile resolution, you can see that it takes a 4x4 pixel chunk of the ecology map to represent 1 texture tiles' worth of area. It would actually take a solid block of color 4x4 on the ecology map to draw a complete texture tile. As you can see from the illustration, there are 5 different texture types used in this chunk, values 29, 15, 31, 80, and 33. To demonstrate how the terrain engine assigns textures to the terrain, the pixels of the eco map have been numbered.
Here are the 4 terrain tiles needed for the top half of our map:
 Value 29, stf.tga
| Value 33, trop_rain.tga
|
Value 80, coastline.tga
| Value 15, sea_water.tga
|
Note that each has been split up into a 4x4 grid, with numbers corresponding to the pixels of the eco map. Looking at the previous illustration, we can see that in the top left sector, we are assigning sections 1,2,3,4,5,6,9,10, and 11 of stf.tga, together with sections 4,8,12,13,14,15, and 16 of trop_rain.tga. In the top right, we have a mix of coastline, sea water, and tropical rain textures.
Here is an illustration of the terrain as it might appear in-game:

It won't actually look exactly like this in game, because of blending.
About Blending
Blending is an option than can be enabled for terrain textures on a layer by layer basis. It cannot, however, be set on a texture by texture basis within a layer itself. To turn blending on for a layer, set "blend = 1" in the layer header:
[Layer 1]
map = pngsolomons_ecosystem.tga
scale = 0.25
height = 0
blend = 1
num_textures = 20
When blending is turned on, the terrain engine will attempt to smooth the sharp borders between neighboring textures. The example in the previous section demonstrates what terrain might look like with no blending turned on. Blending works by mixing the colors of adjacent texture tiles.
Note that blending is not appropriate for texture files with alpha layers, or any texture file that needs to be carefully aligned with its neighbors, such as an airfield or road overlay texture.
|