Howto:Editing tile textures and materials
The FlightGear scenery is displayed on the screen by rendering each of the triangles that makes up the surface with a texture, and placing random trees and objects on the surface. This Howto describes how to change the appearance of the scenery by modifying the texture, and configuring the objects that appear.
Each triangle has a defined "material", the landclass assigned to it by the scenery building process. The mapping of that material to a set of textures and objects is defined in the materials.xml file, found under the Materials directory.
Currently there are two sets of materials you can use - the default set (defined in Materials/default/materials.xml), and a DDS set that takes advantage of pre-generated mipmaps of the dds texture format (defined in Materials/dds/materials.xml). Both of these make used of fragments of xml found under Materials/base/.
Definitions of the various XML tags can be found in Docs/README.materials.
Creating Object Masks
Object masks allow you to define where on the surface of the material random vegetation and buildings should be placed, relative to the texture itself. The object mask works by using the 3 colors (red, blue and green) to define whether a tree or building may be placed at a given location, and the rotation of the building. The colors are used as follows: - Red defines the Rotation of a building - Blue defines whether a random building can be placed at the location - Green defines whether random vegetation can be placed at the location.
The process to create an object mask and configure materials.xml to use it is straightforward.
- First, we need to identify the texture you want to edit.
- Open the materials.xml files using a text editor.
- Search for the material type you want to change by the <name> tag.
- Look for the <texture> tag to identify the textures used for the material. In complicated cases, there may be a <texture-set> defines for shader effects. In this case, look for the first <texture> listed inside that tag.
- Next we need to create the object mask itself.
- Open the texture for which you wish to create an object mask
- Resize the texture to 256x256. This is because the object mask doesn't need to be very large.
- Save the texture to a new file, so you don't risk over-writing your existing texture.
- Create a new Black layer on top of the texture, then adjust the opacity of the layer so you can see the texture underneath.
- Edit the green channel. This will mean you'll only paint green colour to add forests.
- Using a brush colour in all the areas where you want trees to be placed in green. It may be useful to have another copy of the original texture open so you can easily tell which areas need to be coloured in.
- Now edit the blue channel (for Buildings).
- Using a brush pain in all the places you want buildings to be placed.
- Finally edit the red channel (for building rotation)
- Using different densities of red, colour over the buildings to indicate the rotation you want them to have (relative to North). This is the trickiest part, as you will need to work out the angle you want to have your buildings rotate by, for which having another copy of the original texture open helps enormously. The diagram below will help you convert from degrees to the appropriate red colour.
- Once you've finished, increase the opacity of the layer to 100%. The texture underneath should disappear, and all the areas that shouldn't have buildings or trees will turn black.
- Save the object mask as a png. The filename convention is <texture>.mask.png.
- Now we need to change materials.xml to use it.
- Edit your materials.xml in a text editor. You may want to create a copy of an existing one yourself.
- For each of the object masks you've created, add an <object-mask> tag containing the name of the object mask. This should be added underneath the material tag (rather than the <texture> or <texture-set> tag), and should be entered in the same order as the <texture-set> or <texture> entries if there is more than one.
- Now change the <heading> for any random objects to "mask". This will cause the random object generator to use the object mask to determine the heading of the object rather than using a random heading.
- You may want to increase the object density or random tree density by _reducing_ the <coverage-m2> or <wood-coverage> values.
- Save the file
- Start FG and enjoy!