Scenery:Texmapper.cfg File

From Silent Wings Wiki
Jump to: navigation, search

This is the main configuration file for the texture map generator. It is very similar to the terrain config file and some of the parameters are the same.

Example

#----------------
# Common section
#----------------
tile_size_n = 3648
tile_size_e = 3648
start_n = 45.0974
start_e = 7.26291
ref_lat = 50
num_tiles_n = 32
num_tiles_e = 32

#------------------------
# Texture mapper section
#------------------------

# Texture resolution (tile_size/tex_size = Approx 3.5m/pixel)
tex_size = 1024

# Image format (DXT1/gzip compressed)
out_pixel_fmt = DXT1
out_file_ext = .dds.gz

# Work cache sizes (in Mb)
shd_cache_sz = 200
img_cache_sz = 200

#-------
# Flags
#-------
# Generate mipmaps yes/no (recommended)
mipmaps = true

# Generate shadows (Only if you have elevation data)
shadows = false

#---------------
# Input section
#---------------
#Input images
image_dir {
  path = /data/geodata/images/aerial/
  recursive = true
  ext  = .tif
  pri  = 2
  coosys = +proj=utm +zone=30 +datum=WGS84
}

image_dir {
  path = /data/geodata/images/lores/
  recursive = true
  ext  = .tif
  pri  = 1
}

# Elevation data for shading

dem_dir {
  path   = /data/geodata/srtm
  ext    = .tif
  pri    = 1
}

dem_dir {
  path   = /data/geodata/srtm30
  ext    = .DEM.gz
  pri    = 0
}

Common section

This is where we define the area of the world covered by this scenery block. You need to either specify the number of tiles, a tile size and a start point, or alternatively the start/end points of the area. In this example we have chosen tile size and start point.

The tile size is given in meters in north- and east direction.

tile_size_n = 3648
tile_size_e = 3648

Now, since the tiles are parallell with the longitude lines, the width varies over the tile. This means that the tile_size_e parameter is only correct at the given reference latiude, ref_lat. If no reference latitude is given, we use the equator (0 degrees).

ref_lat = 50

In this case, the tile width is correct at 50 degrees latitude. Further north, the tile will be narrower, further south the tile will be wider.

The tile start location (south west corner) is given by:

start_n = 45.0974
start_e = 7.26291

And the number of tiles:

num_tiles_n = 32
num_tiles_e = 32

The number of tiles should always be the same in north- and east-direction, and it should always be a power of 2, i.e 2, 4, 8, 16, 32, 64, etc.

For performance, we recommend keeping the tile size around 4km.

Another way to specify the tiling, is to specify the start coordinates (SW corner) and end coordinates (NE corner) and number of tiles. The tile size is then determined by these parameters and should not be specified. For example

start_n = 60
start_e = 10
end_n = 62
end_e = 14
num_tiles_n = 32
num_tiles_e = 32

This would make a scenery block of 2x4 degrees with a tile size of about 3.5km. Here we have not given any reference latitude, so in this case at 60 degrees north, the longitudes are half the distance apart relative to the latitude lines and we have made the block twice the size in EW-direction to compensate.

Texture mapper section

This section contains parameters relevant to the generation of the image files. The most important parameter is the texture size

tex_size = 1024

This size must be a power of 2, and a size that is usable on most graphics cards, i.e not higher than 2048. The texture resolution will be tile_size/tex_size, so in our example it will be approximately 3.5m/pixel.

You can also control some memory cache parameters here:

shd_cache_sz = 200
img_cache_sz = 200

These are given in megabytes and controls how much imagery you can hold in memory at a time when producing the textures. Set this as high as you can to avoid having to reload imagery all the time. The shd_cache_sz controls the amount of elevation data kept in memory for shading, and img_cache_sz is the amount of imagery for the actual texture maps.

Flags

This section controls some on/off features of the texture mapper. One important feature is the mipmap generation. If you enable this, each texture file will contained downscaled versions of itself to use as mipmaps.

mipmaps = true

This should normally be left on. It will produce slightly bigger files, but if you don't enable it, you will get frame rate stuttering on certain graphics cards since these mipmaps must be calculated at run-time.

The next parameter is shadows. If you generate textures from synthetic imagery, you may want to add some shading to the textures. This is done by doing a simple raytrace of a terrain model to add shadows. If you enable this feature, you must also add some elevation data in the data input section. Also remember to set the dem_resolution parameter (see below)

shadows = false

This parameter can be disabled if you are using aerial imagery containing real shadows in them.

Input data section

In this section you can add the various input data sets you have available. You can add several data sets with different priority so that if you have higher resolution data for a smaller area, you can use this data set with higher priority than the coarser base data. In our example we have two input data sets in two different directories:

image_dir {
  path = /data/geodata/images/aerial/
  recursive = true
  ext  = .tif
  pri  = 2
  coosys = +proj=utm +zone=30 +datum=WGS84
}

image_dir {
  path = /data/geodata/images/lores/
  recursive = true
  ext  = .tif
  pri  = 1
}

The first block is the highest priority (pri = 2) and will be used whenever possible. If this data set is not available, or the pixel data is 0,0,0 (black), a lower priority data set is used. The data set is read from the directory /data/geodata/images/aerial and all its subdirectories (recursive = true), and only files with the extension .tif are considered.

Projections

In addition, the first block contains a projection defintion:

 coosys = +proj=utm +zone=30 +datum=WGS84

In this case, we have a UTM image in zone 30. This parameter is only needed if the projection is not given by the image file itself. GeoTIFF for example will usually store the projection data, and you will not need to specify this. If the data is given in geographical coordinates you will not need this either.

Some data are given as regular .tif or .jpg files with a so called "world" file, with the extension .tfw or .jgw. In this case, the projection is not given, and if you use these types of files, and the coordinate system is not lat/lon, you will need to specify the coosys.

The format of the coosys parameter is the same as for the PROJ.4 tool, see http://trac.osgeo.org/proj/ for further info.

DEM data

If you have enabled the shadow generator (see above) you will also need some elevation data. These are specified in similar blocks as the "image_dir" blocks, only they are called "dem_dir". The format of the block is as described above.

In addition you need to specify the dem_resolution parameter. This controls the grid resolution of the elevation model used for the shadow generator. It should normally be set to something near the actual resolution of the input DEM data. Typically 90m for SRTM data.

dem_resolution = 90
dem_dir {
  path   = /data/geodata/srtm
  ext    = .tif
  pri    = 1
}

dem_dir {
  path   = /data/geodata/srtm30
  ext    = .DEM.gz
  pri    = 0
}

In this example we have a high resolution SRTM data set at 90m resolution and a lower priority SRTM30 data set which is 1km grid.