User Tools

Site Tools

Urban Games

modding:groundtextures

Ground Textures

The ground textures are used in constructions to provide a suitable ground for the models. Basically, a ground texture configuration is a mask annotation that provides the information to use the right terrain material for a certain mask value. The ground texture configuration are stored in .lua files and they are located in the res/config/ground_textures/ folder.

A ground texture configuration looks like this:

function data()
return {
  texture = tu.makeMaterialIndexTexture("res/textures/terrain/....tga", "CLAMP_TO_EDGE", "CLAMP_TO_EDGE"),
  texSize = { 50, 110 },
  materialIndexMap = {
    [1] = "dirt.lua",
    [2] = "shared/asphalt_02.lua",
    [3] = "shared/asphalt_03.lua",
    [4] = "shared/gravel_03.lua",
    [5] = "shared/asphalt_04.lua",
  },
  priority = 14,
}


ground texture map (increased contrast)


result in game

The texture property contains a material definition. Usually it is generated by the texutil.lua that can be found in the res/scripts/ folder. It provides several functions with different parameters. Relevant parameters for ground textures are:

  • fileName is the path to the grayscale mask texture. Be aware that it is relative to the game installation path!
  • wrapS and wrapS are the wrapping behaviours in both dimensions. The two common possibilities are either “REPEAT” for tiled textures or “CLAMP_TO_EDGE” for textures, that should be scaled to fit the area of the construction that needs to be covered.

The basic size of the ground texture pattern is set in texSize property.

To assign the mask information to a material, the materialIndexMap contains pairs with keys and terrain material references. Each index refers to the brightness value in the mask texture starting with [1] for almost black and [255] for white. Values that can't be found in the table are skipped, resulting in transparent areas (where the default terrain texture is visible below). The references are relative to res/config/terrain_materials/.

If several ground textures overlap, it depends on the priority property which one is considered as on top of the others and finally is displayed in the game.

Instead of a texture mask it is possible to add a indices block with two properties:

  • data is a lua vector in form of a string, where each digit stands for a pixel of information.
  • size is the resolution of the data vector.


modding/groundtextures.txt · Last modified: 2020/06/22 22:29 by yoshi