Procedural texturing: Difference between revisions

m
Johan G moved page Procedural Texturing to Procedural texturing: Non camel case title
m (Johan G moved page Procedural Texturing to Procedural texturing: Non camel case title)
(6 intermediate revisions by 3 users not shown)
Line 489: Line 489:
(i.e. setting a parameter to 100 means that the texture sheet is supposed to represent a 100 m x 100 m patch of runway). This is different from the way the default renderer treats dirt runways by stretching the assigned texture over the whole runway (i.e. texture magnification depends on runway size). The strength of the grain overlay can be controlled by
(i.e. setting a parameter to 100 means that the texture sheet is supposed to represent a 100 m x 100 m patch of runway). This is different from the way the default renderer treats dirt runways by stretching the assigned texture over the whole runway (i.e. texture magnification depends on runway size). The strength of the grain overlay can be controlled by


<syntaxhighlight lang="xml">
       <grain_strength>0.3</grain_strength>   
       <grain_strength>0.3</grain_strength>   
</syntaxhighlight>


where a value of zero implies no grain texture and a value of 1 the full grain effect as on the texture.
where a value of zero implies no grain texture and a value of 1 the full grain effect as on the texture.
Line 518: Line 520:
If
If


<syntaxhighlight lang="xml">
       <bias_center>1</bias_center>
       <bias_center>1</bias_center>
 
</syntaxhighlight> 
 
is set to 1, the noise distribution will tend to favor the base layer in the center of the runway. <b>This requires a specific uv-mapping and will not work for custom-generated runways.</b> The strength of that bias is set by
is set to 1, the noise distribution will tend to favor the base layer in the center of the runway. <b>This requires a specific uv-mapping and will not work for custom-generated runways.</b> The strength of that bias is set by


<syntaxhighlight lang="xml">
     <bias_center_strength>0.6</bias_center_strength>
     <bias_center_strength>0.6</bias_center_strength>
</syntaxhighlight>


which is between 0 (no bias) and 1 (don't draw overlay layer in runway center no matter what).
which is between 0 (no bias) and 1 (don't draw overlay layer in runway center no matter what).
Line 528: Line 534:
In addition, the effect uses a normal map (since it is used in a non-standard way, touch at your own risk) - the visual 'bumpiness' of the runway can be adjusted using  
In addition, the effect uses a normal map (since it is used in a non-standard way, touch at your own risk) - the visual 'bumpiness' of the runway can be adjusted using  


<syntaxhighlight lang="xml">
       <relief_strength>0.35</relief_strength>
       <relief_strength>0.35</relief_strength>
</syntaxhighlight>


Using different mixtures of textures and parameters, a wide variety of visuals can be achieved, a few examples in the following.
Using different mixtures of textures and parameters, a wide variety of visuals can be achieved, a few examples in the following.
Line 534: Line 542:
A lakebed texture overlaid with sand gives proper visuals for e.g. the Rogers Dry Lake runways at Edwards AFB:
A lakebed texture overlaid with sand gives proper visuals for e.g. the Rogers Dry Lake runways at Edwards AFB:


<syntaxhighlight lang="xml">
     <texture-set>
     <texture-set>
       <texture>Runway/lakebed_taxiway.png</texture>
       <texture>Runway/lakebed_taxiway.png</texture>
Line 555: Line 564:
       <grain_strength>0.3</grain_strength>
       <grain_strength>0.3</grain_strength>
     </parameters>
     </parameters>
</syntaxhighlight>






 
[[File:Dirt rwy01.jpg|500px|center|Dirt runway example 1]]
|[[File:Dirt rwy01.jpg|500px|Dirt runway example 1]]


Using a largely grass-textured surface and allowing some gravel to show in the runway center gives the appearance of a worn grass runway:
Using a largely grass-textured surface and allowing some gravel to show in the runway center gives the appearance of a worn grass runway:


 
<syntaxhighlight lang="xml">
   <texture-set>
   <texture-set>
       <texture>Runway/dirt_rwy.png</texture>
       <texture>Runway/dirt_rwy.png</texture>
Line 585: Line 594:
       <grain_strength>0.8</grain_strength>
       <grain_strength>0.8</grain_strength>
     </parameters>
     </parameters>
</syntaxhighlight>


|[[File:Dirt rwy02.jpg|500px|Dirt runway example 2]]
[[File:Dirt rwy02.jpg|500px|center|Dirt runway example 2]]


Using the effect 'as is', i.e. without any additional parameters, reproduces the old appearance of the dirt runway effect in ALS:
Using the effect 'as is', i.e. without any additional parameters, reproduces the old appearance of the dirt runway effect in ALS:


|[[File:Dirt rwy03.jpg|500px|Dirt runway example 3]]
[[File:Dirt rwy03.jpg|500px|center|Dirt runway example 3]]


With the original dirt runway texture mapped to a small size and framed by less structured dirt, also a compelling result can be achieved:
With the original dirt runway texture mapped to a small size and framed by less structured dirt, also a compelling result can be achieved:


<syntaxhighlight lang="xml">
     <texture-set>
     <texture-set>
       <texture>Runway/dirt_rwy.png</texture>
       <texture>Runway/dirt_rwy.png</texture>
Line 615: Line 626:
       <grain_strength>0.4</grain_strength>
       <grain_strength>0.4</grain_strength>
     </parameters>
     </parameters>
</syntaxhighlight>


|[[File:Dirt rwy04.jpg|500px|Dirt runway example 4]]
[[File:Dirt rwy04.jpg|500px|center|Dirt runway example 4]]


Using grass as the overlay material blends the runway outline nicely into the airport keep:
Using grass as the overlay material blends the runway outline nicely into the airport keep:


 
<syntaxhighlight lang="xml">
     <texture-set>
     <texture-set>
       <texture>Runway/dirt_rwy.png</texture>
       <texture>Runway/dirt_rwy.png</texture>
Line 642: Line 654:
       <grain_strength>0.6</grain_strength>
       <grain_strength>0.6</grain_strength>
     </parameters>
     </parameters>
</syntaxhighlight>


|[[File:Dirt rwy05.jpg|500px|Dirt runway example 5]]
[[File:Dirt rwy05.jpg|500px|center|Dirt runway example 5]]


Finally an example of diffuse sand patches blended into each other by low frequency noise and a large value of the transition in the filter:
Finally an example of diffuse sand patches blended into each other by low frequency noise and a large value of the transition in the filter:


<syntaxhighlight lang="xml">
     <texture-set>
     <texture-set>
       <texture>Runway/dirt_rwy.png</texture>
       <texture>Runway/dirt_rwy.png</texture>
Line 668: Line 682:
       <grain_strength>0.2</grain_strength>
       <grain_strength>0.2</grain_strength>
     </parameters>
     </parameters>
</syntaxhighlight>


|[[File:Dirt rwy06.jpg|500px|Dirt runway example 6]]
[[File:Dirt rwy06.jpg|500px|center|Dirt runway example 6]]


=== Overlay layers ===
=== Overlay layers ===


The ALS rendering framework also supports rendering a low layer with a '3D' structure which is created dynamically by a geometry shader - this can be used for undergrowth or rocks - see below for an example of undergrowth in northern boreal forest:
[[File:Overlay01.jpg|500px|center|Overlay layer used as undergrowth]]
The overlay layer is created by extruding a number of 'shells' from the base ground surface (with a LOD system controlling how many shells are extruded) and texturing the part of the shell which intersects with the 3d structure of the object to be rendered. This looks fairly compelling from above, but of course for shallow viewing angles the nature of the illusion is readily apparent, and once the view direction is parallel to the shells, the 3D structure vanishes because one is looking right between shells. It's therefore a good idea to keep the overlay layer low (< 1 m) and supplement it with other elements such as random vegetation.
The overlay layer needs to be both enabled in user preferences and requested by the landclass definition to be shown. In the materials file, the corresponding effect needs to be set as
<syntaxhighlight lang="xml">
      <effect>Effects/terrain-overlay</effect>
</syntaxhighlight>
to enable the layer. If the overlay is not selected in the ALS quality levels, the effect will automatically fall back to terrain-default (the same will happen if ALS is not selected as renderer).
In the materials file, a number of parameters govern the appearance of the overlay layer. The following example is from Hawaii texturing (here (...) means that these declarations for the layer need to be done in addition to other procedural texturing described above).
<syntaxhighlight lang="xml">
        <texture-set>
          (...)
  <texture n="20">Terrain/dry_pasture4.png</texture>
  <texture n="21">Terrain/dry_pasture4.png</texture>
</texture-set>
<parameters>
          (...)
  <max_overlay_height>1.0</max_overlay_height>
  <overlay_hardness>0.0</overlay_hardness>
  <overlay_density>0.6</overlay_density>
  <overlay_scale>2.0</overlay_scale>
  <overlay_autumn_flag>0</overlay_autumn_flag>
  <overlay_brightness_top>0.8</overlay_brightness_top>
  <overlay_brightness_bottom>0.4</overlay_brightness_bottom>
  <overlay_secondary_flag>1</overlay_secondary_flag>
  <overlay_secondary_hardness>0.0</overlay_secondary_hardness>
  <overlay_secondary_density>1.0</overlay_secondary_density>
        </parameters>
</syntaxhighlight>
Let's go through these entries.
First, the overlay layer can support two different structures with different textures (for instance undergrowth and rock). The number 20 defines the texture for the primary layer, the number 21 for the secondary layer. The code makes an assumption that the secondary layer is smaller in height than the primary layer, so plan accordingly.
The first four parameters determine the apparent geometry of the overlay objects. All 'objects' (which really are painted on the shells only, remember) are based on Perlin noise to give them a pseudo-random appearance. <b><max_overlay_height></b> is the maximal distance the upper layer will be extruded from the ground - the largest of the random structures will reach to this level. As mentioned above, it's generally a good idea to keep this < 1 m (although the effect will run for higher numbers). The <b><overlay_hardness></b> is a number between 0 and 1 and determines how blurry the edges of the structures will be - generally for vegetation one wants a low hardness, for rock (see below) a high hardness to get the illusion of a well-defined surface).
[[File:Overlay03.jpg|500px|center|Overlay layer used as rock]]
The <b><overlay_density></b> determines how much overlay objects there will be (technically, it's a bias for the Perlin noise) - a high density will give a nearly closed layer, a low density instead only a few objects far and between. Finally, the <b><overlay_scale></b> is a parameter used to stretch the noise pattern horizontally. By default, the pattern is around 1-2 m scale, setting the parameter e.g. to 5 will stretch this horizontally to 5-10 m (while leaving the vertical height constant).
The overlay layer is fully interfaced with pixel-post-processing (see below). It is automatically submerged in snow based on altitude information and the simulated snow level, but the shader can not know whether a structure is supposed to be rock or vegetation, thus to participate in autumn coloring, the <b><overlay_autumn_flag></b> needs to be set.
A nice shading effect bringing out the 3d structure better (a cheap version of ambient occlusion basically) can be achieved by setting <b><overlay_brightness_top></b> and <b><overlay_brightness_bottom></b> to different values (these are multiplies for the base texture color). What the best values should be really depends on the texture that is used.


The secondary layer shares most properties with the primary layer. It needs to be activated using <b><overlay_secondary_flag></b> and it is possible to give it a different apparent hardness and density using <b><overlay_secondary_hardness></b> and <b><overlay_secondary_density></b>. Since the secondary layer utilizes <i> the same</i> Perlin noise generated for the primary layer, the two layers can not generate overlapping structures by constructions (thus, no 'bush' and merge with a 'rock'). That also means that a secondary layer with texture and parameters identical to the primary layer can be declared to generate an extra-dense layer. Generally though secondary layers should be used with care.


=== Pixel color postprocessing ===
=== Pixel color postprocessing ===
Line 755: Line 823:
* [[Atmospheric light scattering]]
* [[Atmospheric light scattering]]
* [[ALS technical notes]]
* [[ALS technical notes]]
* [[Howto:Regional texturing]]


== Further reading ==
== Further reading ==