This is the second and final part of the article devoted to procedural methods of content production for 3D applications. You can find the first part here.
As the previous part, the current article contains download links to source materials created by us, which you can freely use (with or without any modification) in your projects, but not to sell or redistribute in a source form and/or as a part of any library.
Remember that all of the source materials were not specially prepared, processed or optimized, in order not to embellish the real situation (often we have to sacrifice flexibility/convenience of solutions in favor to saved time).
This time we will talk about the facilities and methods that we used in creation of Valley Benchmark to produce a large amount of photo-realistic content within the shortest possible time.
You can check our results here using the free benchmark downloading or just by watching the following video.
So, for this project we set ourselves a task to create an extremely realistic Siberian mountain valley of 8х8 kilometers in size with a wide spread of generated objects by size (from a mountain to a flower on a meadow) and a high level of detail.
First of all, we divided all the necessary content into 3 groups by the approaches to its creation:
- Meshes and textures of stones, trees, grass, flowers etc.
- A mesh and textures for a terrain (and also density masks for objects on it).
- Textures for special effects (e.g. lens flare dirt), some natural phenomenons and objects.
While the content specified in the first list item generally can be created by using any usual 3D modeling and texturing means, the content of the second and third items requires the special approaches. It is the procedural generation means that were used to create them.
For example, the World Machine software has been used as a dedicated tool for generating terrains and objects density masks. On the other hand, the Filter Forge software has been used for creating:
- clouds textures;
- moss textures;
- dust effect;
- glowing dust suspension effect;
- lens flares dirt effect.
CLOUDS
The UNIGINE Engine contains the simulation tools for both dynamically-changing physically-based volumetric clouds and static defined shape clouds placed in the required position (billboard clouds).Valley Benchmark billboard clouds
The billboard clouds creation tool forms an array of billboards (polygons which always face the camera) in a random way and fills the source bounding mesh with them using given parameters (such as the billboards number, basic size, scattering of sizes, etc.). It also allows user to adjust all the set parameters right up to changing the position of any individual billboard.Setting up of object Billboard parameters
A special material, considering the global light (Sun) illumination and light scattering, is assigned to the generated array of polygons to transform it to the clouds.
A diffuse texture, consisting of several separate translucent fragments of the cloud that are randomly assigned to each billboard, is assigned to this material.
The diffuse texture of cloud fragments was created using the Filter Forge tool.
MOSS
In UNIGINE, a special material is used to create moss on the stones. This material combines two materials, one of which is projected onto another in a world space using a mask.
The convenience of a such material is hard to overestimate, because if we just baked a moss in the textures of the stones, we would immediately lose an ability to rotate (around all three axes) and to position the stones on the terrain (we would like to see the moss lying only on the top of the stones). And also we would lose the required chaotic character of simulated natural object, thus reducing the reality of the output picture.
Shape of the fragments of the moss is determined by two textures – a rough but unique for the whole terrain mask (irregularity mask) and a detailed but repeated (because of tiling) alpha-channel of the diffuse texture. This source values of transparency are multiplied and we get the detailed unique pattern of the moss in each point of the surface.
All the textures (including a normal map) and mask for the moss were created in Filter Forge.
LENS FLARES DIRT
There is an effect in the UNIGINE Engine, which simulates lens flares (when the bright light strikes the camera lens). Because there is no completely clean and smooth lens in the reality, and presence of tiny particles of dust on its surface cause quite characteristic visual artifacts during the light-striking, a capability of using the dirty lens texture has been added to make a picture more cinematic.Lens flares dirt effect
The texture for such an effect was created using the Filter Forge tools, because it is easier and more convenient.
Download lens_dirt.ffxml
TERRAIN
Creating of large outdoor scenes is quite a difficult problem affecting either the real-time rendering of a terrain (with a set of the objects lying on it) and also the creation of a content for such scenes.Terrain with dynamically changing level of detail
In UNIGINE, there are a lot of tools allowing user to:
- create terrains of virtually infinite size suitable for the real-time rendering (the engine can handle them in run-time due to asynchronous loading of data);
- place objects on the terrain procedurally using masks;
- form clouds, stars, rain, ocean and adjust atmospheric effects (such a light scattering) etc.
Before you start to create content for large outdoor areas, it is recommended to collect as many as possible reference materials with photographs of the terrain which has to be implemented. Both ground-based and aerial photographs are useful.
It is necessary to understand processes involved in the earth surface forming while analyzing the collected reference materials, because working with terrain procedural generation tools requires understanding such things to achieve the best results.
Terrain in UNIGINE is an object which dynamically changes the level of detail of its mesh and textures depending on the camera distance to have an optimal performance and a high visibility range (more than 40 kilometers).
You need to have the following source textures to create a terrain by means of UNIGINE Engine:
- a height map is a 16-bit gray-scale texture that describes elevations (an altitude value of the each point of a terrain);
- a diffuse map is a texture that determines the base color;
- a material mask is a texture specifying the areas to be detailed by one or another material.
Normal map is not required. It is created automatically by the engine tools using the height map.
Additional materials are used to detail the terrain. Textures of the materials are copied across the surface of the terrain using tiling, while blending of these materials is determined by the mask. Thereby the required type of the surface is reproduced in the specified areas, be it grass, sand, stones or any other types of surfaces.
There are special programs that generate terrains and create the textures listed above. World Machine is one of them.
World Machine
This program has its own shortcomings as any other, but it was chosen by us among the others (see the whole list in the end of the article) for a number of reasons including the quality of the obtained result, node-based architecture and a large set of necessary functions. We should also mention the ability of selective calculation of small areas of the terrain textures (for saving time and calculation). It adds an ability of quick iteration while working with details, and that is a great ‘plus’ due to which the quality of the created content noticeably increases.
We divide the process of terrain textures creation into the three stages:
- creating of basic terrain textures (height map, snow depth mask, erosion flow map);
- creating of object density masks and terrain detail masks;
- creating of the terrain diffuse texture.
A separate graph is created in World Machine for each stage, and each of the following stages uses calculation results of the previous one. Of course, World Machine is quite a smart software and if you change parameters of the nodes, it recalculates only the graph branch which was affected by those changes (unlike Filter Forge), but if you reopen the file, calculations are performed right from the start. For example, the calculation of erosion results is quite complicated, and dividing the process into stages is handy and saves us plenty of time.
Creating basic terrain textures
A graph in World Machine which forms basic terrain textures
Download terrain_height.tmd
Three noise generators with a different scale underlie the landscape forming terrain graph. The results of the noise generators calculations are combined to form large, medium-sized and small elements of the basic surface.
Closer to troughs, a hilly nature of the surface is prevailed. It is reconstructed using a filter called Expander (in terms of World Machine – a device) which expands the areas around the mountains.
Then fine detailed rocks are added to the hills. Rocks are represented by remains of the mountains after erosion.
Ledges are added using Terrace device. Then noise is applied to eliminate regularity of the effect and the ledges are bounded by the height and surface angle.
Then the erosion is added using the Erosion device. It is the most important device in World Machine which is used to simulate the processes of destruction and displacement of the soil under the influence of water, wind and temperature. Without this device the whole terrain would have remained just a set of the blended procedural noises, which is far from the reality.
Wavy displacement of the ground is added. There are a lot of roots of the trees and plants in the soil. So the soil slides down by massifs to the lowland from the sloping surfaces under the influence of the gravity and erosion. This visually appears as folds on the earth surface. The effect can be formed and worked out in a more detailed way via World Machine using a capability of calculating results only for a specific area of the terrain (by setting up the necessary Extents).
Snow is placed onto the summits of mountains. Generally this is performed by the Snow device, which simulates snow accumulation effect taking into account such parameters as intensiveness, the amount of snow, a wind direction etc.
The obtained results of this stage are rasterized using World Machine tools and saved to files. So, we get the height map, the erosion map and the snow depth mask as the result.
Creating masks of terrain detail
In Valley Benchmark four detail materials are used. They represent the following types of surfaces:
- snow (a snow mask);
- boulders (a boulders mask);
- grass (a grass mask);
- rocks (a rock mask).
Masks defining a visibility of the materials of these surfaces on the terrain are also created in World Machine based on the textures of the previous stage.
Download terrain_masks.tmd
A graph in World Machine which forms all necessary masks
SNOW MASK
The snow mask is formed in such a way, that the intensiveness of the source snow depth map determines sizes and an amount of snow fragments (the darker the pixel of the source texture, the smaller a number and size of the fragments).
BOULDERS MASK
The erosion map shows how streams of the ground demolished by the erosion flow down. To get the boulders mask from the erosion map, places with a great slope of the terrain surface are removed (usually stones no longer stay on such surfaces). Also areas with a small slope on the low heights are removed (in these areas the fine sedimentary rock, ground and soil are dominated).
GRASS MASK
The heights covered with snow are excluded for the grass mask.
In the nature, grass grows on the ground which does not linger on the rocky and steep surfaces, so places with a great slope are excluded from the height map.
Information about places, where the sedimentary rock flows down, comes from the erosion map. Grass grows less active on the certain heights, where the sedimentary rock is more active (sliding and flowing down boulders). It is also taken into account while forming the grass mask.
ROCK MASK
The rock mask is created by excluding all the other masks.
Objects density masks creating
TREE MASKS
Tree masks are created using the grass mask, height map and several procedurally-generated noises to place spruces on the greater heights (but where grass still grows), pines on the average heights and birches on the hollows and plains.
All tree masks are mutually exclusive that is necessary for exact division of forest areas. Insignificant intersections occurs in adjacent areas only.
So, we get the masks to place four types of trees on them: a spruce, spruce dead, pine and birch.
BUSH MASKS
The bush mask is also formed using the grass mask. But by means of the erosion mask, the places with the most possible water accumulation are taken into account while making the bush mask. Besides, an area with stones is clipped.
STONES
The existing rock mask is used to place stones, boulders and cobbles.
Diffuse texture creating
The bush mask is formed of the grass mask. But using the erosion mask the places with the most probably water accumulation are taken into account in the bush mask. An area with stones is clipped.Bush density mask
A color texture, created by combining masks from the previous stages. Different colors are blended and noises are added.
Thus, for example, two types of grass, green and dry, are added. Green grass grows in the hollows, and dry is up the hills. To make the terrain under the forest visually darker the tree masks are applied. A color adjusting is executed via Photoshop or GIMP if necessary.Diffuse texture
PLACING OBJECTS BY MASKS
Object Mesh Clutter parameters adjusting
When all the necessary textures and masks are created, terrain is generated and all the materials are adjusted, and what is remained is to distribute prepared objects (trees, stones, grass, flowers and bushes).
It is hard to imagine, how much time would be taken for placing such a huge amount of small (comparing with terrain size) objects manually. So, in UNIGINE Engine there is a special object, Mesh Clutter, designed for saving time and rendering optimization. Mesh Clutter scatters objects across the terrain in the quasi-random way. To get such an effect, a source mask is used and such parameters as density, random spread and scale of object rotational angles are adjusted.
Another advantage is that the allocation of the objects is quasi-random. It means that objects created by two different generators using the same values of the parameters will always be placed in the same areas. In this way the determinacy of the result is achieved.
CONCLUSION
World Machine
ADVANTAGES
- Calculation results caching: nodes, that are not affected by the changes in the graph won’t be recalculated. It is handy and saves a time for new content creation.
- An output node, which allows to output to files any number of calculated textures from any place of the graph and to re-save them with the click of a button.
- Tiled building of big textures. Textures are rendered by fragments, so there is an opportunity of parallel rendering (capabilities of multi-core processors are used in full) and optimal memory usage. But do not forget that the erosion algorithm is calculated separately for each tile, not to the whole terrain surface. And bonding of the resulting erosion texture tiles is performed by overlapping the adjacent areas.
- Sufficient set of devices (basic blocks which create a terrain forming algorithm) which allow to realize almost any algorithm of terrain building.
- There is an opportunity to group parts of the graph to create new systems for the purpose of further re-usage. But unfortunately instancing is missing, so such systems are the duplicates.
- Ability of exact calculation only of the required fragment of terrain. It helps to save time while working on details of the target terrain fragments,
DISADVANTAGES
- Great number of problems while working with large input values (both vector and bitmap) and huge terrains. For example, when you open an input vector with a coastline data (which includes several thousands of points), FPS in the editor significantly drops.
- Erosion algorithm’s behavior (Erosion Device block) depends on the final resolution of the terrain.
- Lack of tools for a mountain rivers creation. Cutting of terrain by splines to place the river without using information about an erosion gives a non-realistic result. If the erosion is applied, the river in some places can be barricaded.
- Absence of ability to change or switch off the interpolation of the source textures.
- Some small, but very unpleasant editor defects. For example, it is impossible to specify digital values for color in the Colorizer device (it can be performed visually only). Also the editor uses type ‘int’ instead of ‘float’ for several parameters and obscure restrictions in ranges of the parameters values.
In addition to World Machine you can also try Quad Software Grome Editor, Planetside Software Terragen. Or you can extend GPU-driven open-source (AGPL license) terrains generator which is called Lithosphere.
Procedural generators
Ideally, an elimination of distinction between 2D and 3D should become the main development concept of all procedural generators, because 2D is just a particular case of 3D.
Currently there are no procedural generators that would allow user to:
- create algorithms of forming three dimensional objects (by voxels);
- create your own algorithms of baking textures and easy rebuild them for your needs.
So, there is no ability to use any information from a low-poly, high-poly or algorithmically formed voxel 3D-model to create, for example, a seamless stone textures generator or rust textures generator for any source model.
There is an ability to bake several maps using models in such programs as 3ds Max or Substance Designer. But these models are rendered by hard-coded algorithms, which cannot be changed. Also you cannot create the new ones. Recently launched integration of AngelScript with 3D-Coat submits a hope. But the final result is still not clear.
Also there is the problem that could be solved even on the existing level of textures procedural generators. Those editors are good in removing seams on the edges of the rectangle texture (for example, using methods “offset” or “splat”). But none of them is able to remove these seams on the texture in places where there is the gap of UV coordinates
If these insufficient capabilities were implemented, they could be applied for creation of the libraries with automated textures generators (for example, metal surfaces with influenced on them weather, dust and mud factors), where input data would be presented only by the 3D-model and material settings.
USEFUL LINKS
unigine.com/products/unigine — UNIGINE Engine used in Oil Rush game and Valley benchmark
filterforge.com — Filter Forge procedural generator
world-machine.com — World Machine procedural generator of terrains
quadsoftware.com — Quad Software Grome Editor
planetside.co.uk — Planetside Software Terragen
lithosphere.codeflow.org — Lithosphere Terrain Generator
voxelogic.com — Voxelogic Acropora procedural voxel modeler
AUTHORS
Andrey Kushner
Vyacheslav Sedovich @slice3d
(technical artists, UNIGINE Corp.)