Howto:Regional texturing: Difference between revisions

Jump to navigation Jump to search
m
Updates: 1). Tips: update ctrl+alt+click, add reloading materials/scenery/textures. 2). Add info on object types, bird flocks. 3). Add paragraph with a high-level overview of what people have to do (edit text files) showing that it's simple, so people are motivated and can see where the article is going.
m (cleanup)
m (Updates: 1). Tips: update ctrl+alt+click, add reloading materials/scenery/textures. 2). Add info on object types, bird flocks. 3). Add paragraph with a high-level overview of what people have to do (edit text files) showing that it's simple, so people are motivated and can see where the article is going.)
Line 7: Line 7:
Internally, the terrain is a dense mesh of triangles which determine the elevation at each given point. However, the mesh also encodes what a patch of terrain is supposed to represent by assigning a so-called <b>landclass</b> to a triangle. Landclasses are a concept that is directly inherited from geo databases like CORINE. For instance, the database may tell that a certain patch of terrain is 'Shrubcover'. This information is stored with the terrain mesh.
Internally, the terrain is a dense mesh of triangles which determine the elevation at each given point. However, the mesh also encodes what a patch of terrain is supposed to represent by assigning a so-called <b>landclass</b> to a triangle. Landclasses are a concept that is directly inherited from geo databases like CORINE. For instance, the database may tell that a certain patch of terrain is 'Shrubcover'. This information is stored with the terrain mesh.


Flightgear then uses it in-sim in several ways: First, the landclass of a triangle determines how it appears, i.e. what texture and/or effect are assigned. Second, it also determines FDM-relevant properties, for instance whether it will yield when you try to land on it (for instance water), whether you can roll across it, how bumpy rolling will be, and so on. The Advanced Weather system uses the landclass to determine the likelihood of convective cloud formation when the sun heats the terrain. Finally, also the distribution of random overlay objects (such as the density of lights at night or the number of trees or buildings appearing) is also determined by the landclass.
Flightgear then uses it in-sim in several ways: First, the landclass of a triangle determines how it appears - and how it changes appearance with season or environment conditions, i.e. what texture and/or effect are assigned. Second, it also determines FDM-relevant properties, for instance whether it will yield when you try to land on it (for instance water), whether you can roll across it, how bumpy rolling will be, and so on. The [[Weather#Advanced Weather|Advanced Weather]] system uses the landclass to determine the likelihood of convective cloud formation when the sun heats the terrain. Finally, also the distribution of random overlay objects (such as the density of lights at night, or the number of trees or buildings appearing, or the random placement of icebergs, ships, or bird flocks) is also determined by the landclass.


A separate layer for the terrain are static objects which are placed on definite positions onto the mesh by other means - for their placement, no landclass information is used and while they can be placed 'onto' the mesh automatically, they can also be placed to absolute altitudes.
A separate layer for the terrain are static objects which are placed on definite positions onto the mesh by other means - for their placement, no landclass information is used and while they can be placed 'onto' the mesh automatically, they can also be placed to absolute altitudes.


Regional texturing specifically changes the appearance of a landclass and also the placement of overlay objects - it is not a technique capable of altering the outlines of landclasses in the mesh. In other words, using the technique you can make an existing patch of shrubland look more realistic, but you can not change part of a lake that has the wrong shape to be shrubland.
Regional texturing specifically changes the appearance of a landclass and also the placement of overlay objects - it is not a technique capable of altering the outlines of landclasses in the mesh. In other words, using the technique you can make an existing patch of shrubland look more realistic, but you can not change part of a lake that has the wrong shape to be shrubland.
What do you actually have to do to change the appearance in a region? The way you define appearance of landclass(es) is just by using a text file to set the properties. The properties are just things like the name of a terrain effect - e.g. 'Agriculture' or 'Rock', the names of a few texture files usually from the data/textures/Terrain [https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Textures/Terrain/] folder, and numbers which are values you can tweak for each effect until they look right - these values are called parameters. The idea is to find out how a landclass looks in a region by looking at some photo references, sites like instanstreetview, or from experience - then tweak some values and pick some existing textures or create a few new textures. You can start by copying an existing definition from another region that looks close. You can also add or tweak some numbers which set how auto-generated objects like trees or buildings appear. Very simple.


=== Control files ===
=== Control files ===


The central file responsible for the assignment of textures etc. to landclasses is <b>/Materials/regions/materials.xml</b> (for historical reasons, there are two alternative schemes under <b>/Materials/default/materials.xml</b> and <b>/Materials/dds/materials.xml</b> which are not supposed to be modified by regional definitions). They can be selected in-sim in the rendering dialog.
The central file responsible for the assignment of textures etc. to landclasses is <b>/Materials/regions/materials.xml</b> [https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Materials/regions/materials.xml] (for historical reasons, there are two alternative schemes under <b>/Materials/default/materials.xml</b> and <b>/Materials/dds/materials.xml</b> which are not supposed to be modified by regional definitions). They can be selected in-sim in the rendering dialog.


<b>materials.xml</b> largely serves as an index to include the actual regional definitions. However, hierarchy is important and needs to be considered: Later valid definitions always override earlier definitions. So for instance in texturing Honolulu, Hawaii, first <b>global-summer.xml</b> is considered (which is the world-wide default for summer textures), then the content of <b>hawaii.xml</b> overwrites the global definitions and finally the content of <b>oahu.xml</b> overwrites part of the Hawaii-specific definitions. The wrong order of files can lead to definitions not being used.
<b>materials.xml</b> largely serves as an index to include the actual regional definitions. However, hierarchy is important and needs to be considered: Later valid definitions always override earlier definitions. So for instance in texturing Honolulu, Hawaii, first <b>global-summer.xml</b> is considered (which is the world-wide default for summer textures), then the content of <b>hawaii.xml</b> overwrites the global definitions and finally the content of <b>oahu.xml</b> overwrites part of the Hawaii-specific definitions. The wrong order of files can lead to definitions not being used.
Line 76: Line 78:
The first tags are <b>name</b> - they contain a list of landclasses the material refers to (remember that the landclass is stored with the terrain mesh, i.e. the mesh contains the information that a certain triangle is 'Rock').
The first tags are <b>name</b> - they contain a list of landclasses the material refers to (remember that the landclass is stored with the terrain mesh, i.e. the mesh contains the information that a certain triangle is 'Rock').


The next block is the texture set assigned to the landclass - it contains the name of the files to be used for the visuals (to make use of [[Procedural Texturing]] techniques, usually multiple textures are assigned). The <b>parameters</b> block allows to configure procedural techniques by passing control parameters to the Shader generating the composite texture.
The next block is the texture set assigned to the landclass - it contains the name of the files to be used for the visuals (to make use of [[Procedural Texturing]] techniques, usually multiple textures are assigned). The <b>parameters</b> block allows to configure procedural techniques by passing control parameters to the Shader generating the composite texture. These parameters are just numbers - often 1 or 0 for turning things on/off, integers, or floating point numbers.  


<b><xsize</b> and <b>ysize</b> are important because they determine how large a patch the base texture file is supposed to cover (in the above example, 1000 m x 1000 m is covered by one texture sheet, if the sheet is 1024x1024 pixels, the base resolution is about 1 m).  
<b><xsize></b> and <b><ysize></b> are important because they determine how large a patch the base texture file is supposed to cover (in the above example, 1000 m x 1000 m is covered by one texture sheet, if the sheet is 1024x1024 pixels, the base resolution is about 1 m). Terrain effects often use additional overlay textures on smaller scales, and these use a magnification factor to the base resolution you set.  


The final set of parameters is passed to the FDM for ground interactions - we learn that 'Dirt' and 'Rock' are to be treated as solid surfaces and what their rolling friction and bumpiness is supposed to be. Using blocks like this, every landclass as stored in the terrain mesh is assigned characteristics that determine how it looks and behaves in FG when the scenery tile is loaded.
The final set of parameters is passed to the FDM for ground interactions - we learn that 'Dirt' and 'Rock' are to be treated as solid surfaces and what their rolling friction and bumpiness is supposed to be. Using blocks like this, every landclass as stored in the terrain mesh is assigned characteristics that determine how it looks and behaves in FG when the scenery tile is loaded.
Line 183: Line 185:


=== Objects ===
=== Objects ===
==== Random or non-random placement ====
The object placement can be made non-random by specifying an <b>object mask</b> (i.e. an additional texture that tells how objects are placed). This allows to place trees on a specific part of the base layer texture if that part shows trees. The green channel mask is used for random vegetation placement, the blue channel for buildings and lights. and the red channel controls the rotation of buildings (0.0 is North, 0.5is South). Fractional colour values can be used to give a probability of placement.
The object placement can be made non-random by specifying an <b>object mask</b> (i.e. an additional texture that tells how objects are placed). This allows to place trees on a specific part of the base layer texture if that part shows trees. The green channel mask is used for random vegetation placement, the blue channel for buildings and lights. and the red channel controls the rotation of buildings (0.0 is North, 0.5is South). Fractional colour values can be used to give a probability of placement.


Line 188: Line 192:


Also note that the appearance of a large number of buildings does not need to be created by random building placement but can be alternatively done by the urban relief effect.
Also note that the appearance of a large number of buildings does not need to be created by random building placement but can be alternatively done by the urban relief effect.
==== Object types ====
Object mask can be used for things like silos or farm buildings in agricultural landclasses. Random objects can be used for things like occasional wood cottages in forests, or for occasional ships/boats or icebergs over water landclasses (see globalsummer.xml [https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Materials/regions/global-summer.xml]) of different types.
==== Birds ====
There is an animated '[[:File:Birds02.jpg|bird flock]]' object. As of May 2021, it is in Models/Effects/Birds/birdswarm.xml [https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Models/Effects/Birds/birdswarm.xml] for a seagull type bird and consists of 4 swarms.
Defining a new object-group [https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Docs/README.materials] for birdswarm objects in a regional definition - see Caribbean.xml, bermuda.xml, or southern-europe.xml for examples [https://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Materials/regions/]:<syntaxhighlight lang="xml">
    <object-group>
      <object>
        <path>Models/Effects/Birds/birdswarm.xml</path>
        <coverage-m2>1500000</coverage-m2>
        <heading-type>random</heading-type>
      </object>
    </object-group>
</syntaxhighlight>[[File:Birds02.jpg|alt=Bird flock in FlightGear|frameless]]
You can place bird objects over suitable landclasses. The default seagull texture is Models/Effects/Birds/birds_in_flight.png , and new textures can be integrated into specific effects when created.


=== Assigning effects ===
=== Assigning effects ===
Line 255: Line 278:
You'll probably frequently end up in a situation in which your changes don't have any visual effect. The following tricks have proven useful:
You'll probably frequently end up in a situation in which your changes don't have any visual effect. The following tricks have proven useful:


* check the landclass you're editing in-sim - with the ufo, {{Key press|Ctrl||Alt|click}} on a triangle dumps the material definition briefly on-screen and into the console
* check the landclass you're editing in-sim - with the [[UFO from the 'White Project' of the UNESCO|ufo]], {{Key press|Ctrl||Alt|click}} on a triangle dumps the name of the landclass file containing the material definition (as of May 2020 nightly builds), material definition, and elevation briefly on-screen and into the console. This is extremely useful to find which file the regional definition you're seeing actually comes from.


* make sure you have the signs of latitude and longitude in your <area> tags correct: 30 degrees western longitude should appear as -30.0 - also make sure that really the smaller number is assigned to <lon1> or <lat1> and the larger number as <lon2> and <lat2>, keeping in mind that -10 is larger than -20.
* make sure you have the signs of latitude and longitude in your <area> tags correct: 30 degrees western longitude should appear as -30.0 - also make sure that really the smaller number is assigned to <lon1> or <lat1> and the larger number as <lon2> and <lat2>, keeping in mind that -10 is larger than -20.
Line 261: Line 284:
* check whether any later definition overrides the file you're editing - this is why it's important to have <i>a clear hierarchy of definitions rather than a mess of overlapping definitions which partially override each other</i>
* check whether any later definition overrides the file you're editing - this is why it's important to have <i>a clear hierarchy of definitions rather than a mess of overlapping definitions which partially override each other</i>


* to check hierarchies, you can gradually comment later definitins in materials.xml and see whether you observe changes
* to check hierarchies, you can gradually comment later definitions in materials.xml and see whether you observe changes


* to check whether you're editing the right file/region, do something obvious, like assign a rock texture to a lake. Change to subtle only once you're sure you're editing the right file.
* to check whether you're editing the right file/region, do something obvious, like assign a rock texture to a lake. Change to subtle only once you're sure you're editing the right file.
== TipsTips ==
* Reloading: <code>Menu inside the simulator > Debug > Configure development extensions > press reload Materials and then reload Scenery</code> to reload all material files without needing to close and restart FlightGear. This is extremely useful to tweak values and see the changes. To see subtle differences clearly: Pause the sim, and save before and after screenshots.
* To reload changed textures without needing to restart the sim - e.g. when making textures in [[GIMP]] and tweaking various effect/filter parameters:
** a) <code>Menu inside the simulator > View > Rendering > change from regional texturing to global texturing, pres ok, then change back from global texturing to regional texturing</code>
** b) Change the name of the file, reload materials and scenery, and change the name of the file a
** c) Export a new texture in gimp with a slightly different filename e.g. change MyTexture.png to  MyTexture.2.png. Reload scenery. This is the fastest way when tweaking textures in GIMP.
* QUickly creating albums of screenshots during review: These days you can simply drag and drop screenshots to online image hosts like imgur. It's also possible to paste image in the the clipboard (e.g. from GIMP) directly into the imgur file dialog by pressing ctrl+v (at least in Windows).
* See related content below, including creating textures.


== Related content ==
== Related content ==
1,746

edits

Navigation menu