Random Vegetation
Random Vegetation is the system that generates trees, bushes and other vegetation on scenery. It is sometimes referred to as "Random Trees", and tree is often used as a synonym for vegetation throughout the system and documentation. For simplicity, this article will refer to "trees".
The location of trees can be defined in two ways:
- Random distribution within an area of the scenery, with distribution controlled by parameters in materials.xml
- Explicit placement defined in a tile by a TREE_LIST entry in the scenery STG file. Typically generated automatically from openstreetmap data by osm2city.
In both cases, the material definition in materials.xml file controls parameters such as the tree height, width the texture used,
The trees themselves are rendered using two (3 post 2024.1) rectangles in a cross shape.
See the README.materials file for information on the specific parameters.
Tree Texture
The tree textures (tree-texture and tree-normal-map parameters) are png files that provide an atlas of textures to use when rendering individual trees, so there is a variety of trees.
Horizontally, the texture contains a number of individual tree textures defined by the "tree-varieties" parameter. Typically 8 for tall thin trees, and 4 for broader trees.
Vertically, each tree has 4 textures to cover in four possible states:
- summer,
- snow covered in summer
- winter,
- snow covered in winter
Post 2024.X, there is an additional tree-normal-map, which is an png normal map file with the same layout used by PBR rendering.
Generating PBR Trees
Due to the need to generate a normal map, the traditional approach of just painting a texture does not work for PBR trees. Instead, we use an approach of creating a tree model in Blender and then rendering a base colour texture and a normal map texture. This approach is described well on youtube (e.g. https://www.youtube.com/watch?v=_GCy98O9S58&t=888s, https://www.youtube.com/watch?v=Ix-KT9a4PSo).
Useful notes for arborealists:
- The tree-template.blend file in fgdata provides a useful starting point, with an appropriate camera and light set up already, solid shading set to display the normalmap, and some basic material definitions. So you can easily select the color map (Viewport Shading) or normal map (solid shading).
- To render the color map, simply press F12, wait for rendering to finish, and save the result.
- To render the normal map, select Solid Shading, then the camera viewpoint (num-pad 0), then select View->Viewport Render Image
- Use Sapling Tree Gen or another add-on to create the initial trees. You can save presets, which is useful.
- There will be 3 copies of the texture rendered at different angles, so the tree texture itself can be sparse.
- The tree needs to be completely vertical. This is particularly important for conifers which come to a point.
- Each tree must have a little space at the top. Otherwise subsequent rendering results in "top hats" above trees in the distance where the trunk of the tree above in the textures sheet bleeds downwards when the mipmaps are generated.