Howto:Editing tile textures and materials: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
Line 51: Line 51:


[[Category:Howto]]
[[Category:Howto]]
[[Category:Scenery enhancement]]

Revision as of 18:25, 5 June 2014

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. You can determine the material definition used within a triangle in-sim by using the ufo and Ctrl+Alt clicking on the ground. This will list the landclass used from the materials.xml file.

There are currently three different sets of materials you can use:

  • The default set (Materials/default/materials.xml)
  • A set that uses different definitions for different geographical regions, so that the farmland of Hawaii looks different from that of England (Materials/regions/materials.xml)
  • A DDS set that takes advantage of pre-generated mipmaps of the dds texture format (defined in Materials/dds/materials.xml).

All of these make use of fragments of xml found under Materials/base/.

Basic configuration

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.

  1. First, we need to identify the texture you want to edit.
    1. Open the materials.xml files using a text editor.
    2. Search for the material type you want to change by the <name> tag.
    3. 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.
  2. Next we need to create the object mask itself.
    1. Open the texture for which you wish to create an object mask
    2. Resize the texture to 256x256. This is because the object mask doesn't need to be very large.
    3. Save the texture to a new file, so you don't risk over-writing your existing texture.
    4. Create a new Black layer on top of the texture, then adjust the opacity of the layer so you can see the texture underneath.
    5. Edit the green channel. This will mean you'll only paint green colour to add forests.
    6. 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.
    7. Now edit the blue channel (for Buildings).
    8. Using a brush pain in all the places you want buildings to be placed.
    9. Finally edit the red channel (for building rotation)
    10. 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.
    11. 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.
    12. Save the object mask as a png. The filename convention is <texture>.mask.png.
  3. Now we need to change materials.xml to use it.
    1. Edit your materials.xml in a text editor. You may want to create a copy of an existing one yourself.
    2. 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.
    3. 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.
    4. You may want to increase the object density or random tree density by _reducing_ the <coverage-m2> or <wood-coverage> values.
    5. Save the file
  4. Start FG and enjoy!

Mask guide.png