Procedural texturing: Difference between revisions

Jump to navigation Jump to search
m (Small wiki markup fixes)
Line 59: Line 59:
[[File:resolution_example.jpg|300px|An example for low texture resolution]]
[[File:resolution_example.jpg|300px|An example for low texture resolution]]
[[File:procedural_resolution.jpg|300px|Procedural texturing adds details at close range]]
[[File:procedural_resolution.jpg|300px|Procedural texturing adds details at close range]]
== Building blocks of procedural texturing ==
Mathematical functions can describe quite complex structures, but in order to be rendered in real time, the function has to evaluate fast enough. This means that 'simple' textures like snow, or possibly sand or rock can be completely procedural, while more complex shapes like agriculture which shows fields, crops, access paths and drains can remain a texture with some structure added procedurally. In general, a mixture of textures and functions is used for best effect.
The most important building blocks of procedural texturing are noise functions. A noise function is a function which takes the coordinates of a pixel as input and returns a pseudo-random number between 0 and 1 as output. Noise functions aren't uniquely defined, and there are several possibilities:
=== Perlin noise ===
[http://en.wikipedia.org/wiki/Perlin_noise '''Perlin noise'''] is noise which exists at a certain scale (say 10 m). It is built by dividing the scene into a 10m x 10 m grid, creating random values at each grid point and interpolating smoothly between the grid points. The function created that way varies typically at a scale of 10 m, but not at much smaller scales and averages to 0.5 at much larger scales. Perlin noise isn't so useful at just a single scale, but noise at several scales added together can achieve a very realistic effect of roughness and structure. Finding the correct noise frequencies and amplitudes for blending Perlin noise to a realistic appearance is an art rather than a computational task.
=== Sparse dot noise ===
For sparse dot noise, the terrain is divided into a grid at certain scale, then random values at the grid edges are used to determine if a dot is placed into the cell, where into the cell it is placed and what radius it has. Based on the distance to the dot, the function returns 0 if the point probed is far from the dot and 1 at the dot position.
From the superposition of several sparse dot distributions, dense dot distributions can be created. Note that a sparse dot distribution does not average to 0.5 but, dependent on the details of the implementation, to a much lower value.
=== Terrain probing functions ===
The underlying terrain can also be used as input for functions in a different way. Commonly used functions are for instance the altitude of a terrain pixel (for instance to determine the snow line) or its slope (to place rock textures on steep slopes). Since the underlying vector geometry of the terrain mesh leads to very sharp division lines, usually terrain probing functions are mixed with some noise for a more realistic appearance.
=== Pixel color postprocessing ===
Many environmental effects can be simulated at the simple expense of post-processing the color of a terrain pixel. For instance, mixing every pixel with a constant dust color can give the terrain a dusty appearance, mixing the final pixel color with a mossy green can give it an overgrown appearance. This is similar to the way pixel color is adjusted for fog, but unlike fog effects environment pixel color postprocessing does not involve distance computations between eye and pixel, rather the color is adjusted independent of the distance (but possibly dependent on terrain gradient or altitude).
== Procedural terrain texturing in Flightgear ==
As of Flightgear 2.10+, procedural texturing of the terrain is done by a general terrain shader which is configurable from <b>materials.xml</b>. The creation of separate effects for various terrain types is not required (but still possible if so desired).
(Currently the following requires that Atmospheric Light Scattering is on!)
=== Pixel color postprocessing ===
A number of environment effects are implemented under user control in the Environment menu. Let's consider the changes to the base scene:
[[File:procedural01.jpg|500px|center|Base scenery near Grenoble]]
==== Snow ====
Using terrain elevation and gradient information, the base location of a snow layer can be determined. The actual snow cover is a white base color, mixed with Perlin noise and normal-mapped with Perlin noise of multiple frequencies. A bias factor for the mixing allows to simulate snow layer of varying thickness.
A low layer thickness creates patches of snow on the terrain through which the basic terrain textures are visible:
[[File:procedural02.jpg|500px|center|Base scenery near Grenoble]]
A high layer thickness completely covers the terrain in snow. Subtle procedural color variations of the snow and bump-mapping change the base white snow pixel color into a realistic texture:
[[File:procedural03.jpg|500px|center|Base scenery near Grenoble]]
If the snowline is placed higher, snow is only simulated on the mountain tops - note also that steep gradients tend to remain clear of snow:
[[File:procedural04.jpg|500px|center|Base scenery near Grenoble]]
==== Dust ====
The dust effect mixes all pixels of the terrain with a basic dust color. A low dust effect setting gives the terrain a dry and parched appearance, as after a long summer period without rain.
[[File:procedural05.jpg|500px|center|Base scenery near Grenoble]]
A high dust effect setting changes the appearance to desert-like terrain (which is rather unrealistic for this scenery):
[[File:procedural06.jpg|500px|center|Base scenery near Grenoble]]
==== Wetness ====
Wet terrain is rendered overall darker. In flat areas, in addition patches of high specular reflection are added, leading to the appearance of glitterin light reflections on water puddles.
[[File:procedural07.jpg|500px|center|Base scenery near Grenoble]]
==== Vegetation ====
A high setting of the vegetation cover is most appropriate for tropical settings, but it can also be used to show seasonal effects, for instance the desert a few days after rainfall. It covers the whole terrain with mossy overgrowth, which in the case of the Grenoble scenery used here blurs the boundaries of the fields and gives the appearance of abandoned agriculture.
[[File:procedural08.jpg|500px|center|Base scenery near Grenoble]]
==== Autumn colors ====
The autumn color effect is unique in the pixel color postprocessing effects in that it needs modifications to the base texture to work. Since the basic terrain texture is never transparent, the information of where vegetation changes color in autumn and where it remains unchanged is hence encoded in the terrain texture alpha channel. A value of 1 means no change of color, a value of 0.5 is appropriate for high changes to bright red-orange. In order to work with the autumn effect, all textures need to be edited manually to indicate where the effect should be computed.
In early autumn, vegetation just tends to pale a little:
[[File:procedural09.jpg|500px|center|Base scenery near Grenoble]]
Later, fields get bright golden-yellow whereas deciduous forests go to orange-red (mixed forest cover rotates locally where indicated by the alpha channel):
[[File:procedural10.jpg|500px|center|Base scenery near Grenoble]]
Finally, in late autumn all vegetation cover is turned into a dull brown:
[[File:procedural11.jpg|500px|center|Base scenery near Grenoble]]
1,360

edits

Navigation menu