Using procedural generators to create content for real-time 3D applications: Part 2. Valley Benchmark

    Benchmark valley


    This is the second and final part of the article on procedural methods for producing content for 3D applications. You can find the first part here .

    In this part, as well as in the previous one, there are links to download the source materials that we created, which you can freely use (with or without changes) in your projects, but not sell / distribute in pure form and / or as a part of any or libraries.

    We remind you that all these source files were not subjected to any special preparation, processing or optimization, so as not to embellish the real situation (quite often in the process of work you have to sacrifice the versatility / convenience of the created solutions in favor of the saved time).

    This time we will talk about what tools and techniques we used to create the Valley benchmark in order to produce a large amount of photorealistic content as soon as possible.

    You can evaluate what we did here by downloading the benchmark for free or simply by watching the video:



    So, when working on this project, we were faced with the task of creating the most realistic Siberian mountain valley measuring 8 by 8 kilometers with a wide spread in the scale of the created objects (from the mountain to the flower in the meadow) and a high level of detail.

    Before proceeding directly to production, we broke all the necessary content according to the principles of the approach to its creation:
    1. meshes and textures of stones, trees, grass, flowers, etc.
    2. landscape (and masks of the distribution of various objects on it)
    3. textures for specific effects, some natural phenomena and objects

    If the content specified in the first paragraph is created in most cases by any conventional 3D modeling and texturing tools, then the items listed in paragraphs 2 and 3 require special approaches in which the procedural generation tools were used.

    For example, the World Machine program was used as a specialized tool for generating landscapes and distribution masks of objects, and the Filter Forge program was used to create:


    The clouds

    Billboard clouds at Valley benchmark


    The Unigine engine has tools for simulating both physically correct dynamically changing clouds (physically-based volumetric clouds) and creating static clouds of the desired shape in the required places (billboard clouds).

    The tool for creating billboard clouds allows you to create an array of billboards (a billboard is a polygon that is always facing the camera) randomly, filling them with the original bound mesh according to specified parameters (for example, such as quantity, base size, size spread) , and further manipulate all the parameters up to changing the position of any individual billboard.

    Setting Billboard Object Parameters in Unigine Engine


    To turn the resulting array of polygons into clouds, a special material is assigned to it, taking into account illumination from a global light source (sun), as well as light scattering. This material assigns a diffuse texture consisting of several separate translucent cloud fragments that are randomly assigned to each individual billboard.

    The diffuse texture of the cloud fragments was created by the procedural tools of the Filter Forge editor.

    A mesh volume in which billboard clouds are generated (above) and a diffuse cloud texture (below)




    Download clouds_variation.ffxml


    Moss on the stones

    Moss on the rocks in the Valley benchmark


    To create moss on stones, Unigine uses a special material that allows you to combine 2 materials, one of which is projected onto the second in the mask in world space.

    Moss Material Parameters


    The convenience of this material is difficult to overestimate, because if we just bake moss in the texture of the stones, we immediately lose the ability to freely rotate (along all three axes) and position these stones on the landscape (I want the moss to lie only on top of the stones), and we also lose the necessary randomness of the simulated natural object, which will immediately catch the eye and generally will badly affect the realism of the resulting image.

    The shape of the moss fragments is determined by two textures - a rough mask, which is unique for the entire surface of the landscape, and a detailed but repeating (due to tiling) alpha channel of the diffuse texture. These two initial transparency values ​​are multiplied, and the result is a detailed, unique moss pattern at each point on the surface.

    All textures (including the normal map) and mask for this natural object were generated in Filter Forge.

    Diffuse (top), normal (middle), irregularity (bottom) moss texture






    Download moss.ffxml

    Using this material, it is also easy to simulate rust, corrosion or mold on objects.


    Lens Flares Dirt

    Lens Flares Dirt Effect in Action


    The Unigine engine has an effect that simulates the illumination of the lenses of a camera lens with bright light sources. Since in reality there are no perfectly clean and even lenses, and the presence of even tiny dust particles on them causes quite characteristic visual artifacts during illumination, for greater realism we added the ability to use the lens contamination texture, which appears only in its very illuminated areas.

    The necessary texture for this effect was easier and more convenient to implement using Filter Forge, which was done.

    Texture used to create a dirty lens effect


    Download lens_dirt.ffxml


    Landscape

    Creating large outdoor scenes is a rather difficult task both in terms of rendering the landscape and many objects on it in real time, and in terms of creating content for such scenes.
    Unigine has many tools for these purposes that allow you to:
    • create landscapes of arbitrarily large sizes suitable for real-time rendering (in addition to the tools, such capabilities are provided by the asynchronous data loading implemented in the engine)
    • procedurally distribute arrays of objects on the landscape by mask
    • form clouds, stars, rain, ocean, adjust atmospheric light scattering, etc.

    Before creating content for large open spaces, it is recommended that you collect as many reference materials with photographs of the area that you want to implement. Both ground images and aerial photography will come in handy. Analyzing the collected reference materials, it is necessary to understand the processes involved in the formation of the earth's surface - work in procedural landscape generators requires an understanding of such things in order to achieve the best result.

    The landscape in the Unigine engine is an object that dynamically changes the level of detail of its grid and textures depending on the degree of remoteness of the camera for optimal performance with a long range of visibility (more than 40 kilometers).

    Dynamically Modified Terrain Feature


    To create a landscape in the Unigine engine, you must have the following source textures:
    • height map - a 16-bit grayscale texture that describes the terrain (the height of each terrain point)
    • diffuse map - a texture that defines the base color
    • material mask - a texture that defines the areas of detail for a particular material (see below)

    A normal map is not required, because it is automatically created by the engine tools on the height map.

    To detail the landscape, additional materials are used, the textures of which are tiled over its entire surface, and the degree of mixing (blending) of these materials is set by the mask. In this way, the required surface character is conveyed in the right places, whether it is grass, sand, stones or any other types of surfaces.

    To create the above source textures, there are specialized terrain generator programs. One such program is World Machine.


    World machine

    This program, like any other, is not without flaws, but we have chosen among others (see the list at the end of the article) for a number of reasons, including the quality of the result, node architecture and a rich set of functions that we need. Separately, it is worth noting the ability to selectively calculate small sections of landscape textures (to save computation time), due to which it is possible to quickly iterate when working on details, which is always a huge plus, due to which the quality of the created content is noticeably improved.

    The process of creating landscape textures is divided into three stages:

    For each stage, a graph is created in World Machine, and each next stage uses the results of the previous calculations. Of course, World Machine is a rather smart program, and when changing the parameters of nodes, unlike Filter Forge, it recalculates only the branch of the graph that these changes affected, however, when the file is opened again, this calculation is carried out completely from the very beginning. And since, for example, calculating the results of erosion is rather complicated, then by dividing into different stages, in addition to the convenience of work, we also get time saved.


    Creating basic terrain textures


    The graph in World Machine, which forms all the basic textures of the landscape


    Download terrain_height.tmd

    At the very base of the graph that forms the landscape are three noise generators with different scales, the calculation results of which are combined to form, respectively, large, medium and small elements of the base surface: Closer to the depressions, the hilly surface character prevails, which is recreated by the expansion of areas around the mountains with a filter (and in World Machine terminology - with a device) Expander: Next, small detailed rocks are added to the hills obtained - the remains of mountains after erosion: Terrace device is added stupid, then noisy to eliminate the regularity of the effect and are limited by height and angle of the surface:











    Erosion is added. This is the most significant device in the World Machine, which is designed to simulate the processes of destruction and displacement of soil under the influence of water, wind and temperature. Without it, the entire landscape would have remained just a set of mixed procedural noises far from reality. Wavy ground displacements are added. Under the influence of gravity and erosion processes, the soil tends to slide from inclined surfaces to the lowlands, but due to the large number of tree and plant roots located in it, this creep occurs in whole massifs, which is visually manifested through folds on the surface of the earth. The ability to perform the calculation of the result of only the specified part of the landscape (through the installation of the necessary Extents) helps to form and work out this effect in more detail in World Machine:





    Snow is added to the tops of the mountains. This is mainly done by the Snow device, which allows you to simulate the effect of snow accumulation taking into account parameters such as intensity, quantity, wind direction, etc. The results obtained at this stage are rasterized by World Machine and saved to files. The result is a height map, an erosion map, and a snow cover thickness map.




    Map of heights (above), map of erosion (in the middle), map of snow cover thickness (below)







    Creating landscape detail masks


    In the Valley benchmark, 4 materials that transmit the following types of surfaces were used to detail the landscape:

    Masks that determine the visibility of the materials of these surfaces on the landscape are also created in World Machine from the textures obtained in the previous step.

    Count in World Machine, which forms all the necessary masks


    Download terrain_masks.tmd

    Snow mask


    Mask of snow cover on the surface of the landscape


    The snow mask is formed in such a way that the intensity of the initial map of the thickness of the snow cover determines the size and number of pieces of snow (the darker the pixel of the original texture - the smaller the number of pieces and their size).

    Mask of stones


    Mask of the spread of stones on the surface of the landscape


    The erosion map shows how streams of eroded soil are flowing down. To obtain a mask of stones, places with a large slope of the landscape surface are removed from it (as a rule, stones on such surfaces do not linger) and areas with a small slope at low altitudes are removed (fine sedimentary rock, soil and soil dominate in these places).

    Grass mask


    Mask spread of grass on the surface of the landscape


    For this mask, heights from which snow cover is already starting are excluded.

    In nature, grass grows on soil, which in turn does not linger on rocky and steep surfaces - respectively, places with a large slope are excluded from the height map.

    From the erosion map, information is obtained on the places where sedimentary rock slides. At certain heights, where this rock is more active (rolling and sliding boulders), the grass grows less actively. All this is also taken into account when forming a mask of grass distribution.

    Mask of rocks


    Rocky face mask on the landscape


    A rock map is obtained by excluding all other masks.


    Creating object distribution masks


    Tree masks


    Mask of distribution of fir trees on the surface of the landscape


    Tree masks are created from a grass mask, a height map and several procedurally generated noises so that the spruce trees are located at high altitudes (but where the grass still grows), pine trees are at medium height, and birch trees are in depressions and plains.

    All tree masks are mutually exclusive, so that there is a clear separation of forest zones. Small intersections are found only in adjacent areas.

    As a result, we get masks that can be used to arrange 4 types of trees: spruce, spruce dead, pine, birch.

    Masks of flowers


    Masks for the distribution of daisies (above) and fireweed (below) over the landscape




    Camomile masks and blooming sally masks are obtained by simply adding procedural noise to the grass mask.

    Shrub masks


    Shrub distribution mask on the landscape


    The mask of shrubs (bush mask) is also created from the mask of grass, but with the help of the mask of erosion, it takes into account places where it is most likely that more water accumulates, and the zone where the stones are located is cut off.

    Stones


    An existing mask of stones will be used to arrange stones, cobblestones and boulders.


    Creating a diffuse landscape texture


    Count in World Machine, which forms a diffuse landscape texture


    Download terrain_color.tmd The

    color texture is created by combining the masks obtained in the previous steps. Various colors are mixed, noises are added.

    So, for example, two types of grass are added - green and dry. Green grass prevails in the lowlands, dry - on the tops of the hills. In order to make the landscape visually darker under the forest, a mask of trees is superimposed on it.

    If necessary, necessary color adjustments are made in Photoshop or GIMP.

    The resulting diffuse landscape texture



    Arrangement of objects by masks

    Configure MeshClutter Object Parameters


    After all the necessary textures and masks are received, the landscape is generated, all the necessary materials are set up, it remains only to distribute all the prepared objects (trees, stones, grass, flowers and shrubs) through it.

    It’s hard to imagine how long it would take to arrange such a huge number of small (compared to the landscape) objects manually. Therefore, to save time and optimize rendering, a special MeshClutter object was created in the Unigine engine, which makes it possible to pseudorandomly distribute objects on the landscape along the original mask and, for example, such parameters as density, random spread of the rotation angles of objects, their scale, which as a result allows you to achieve the desired effect of heterogeneity.

    It is especially worth paying attention to the fact that the distribution of objects in this case is pseudo-random - that is, with the same parameter values ​​(and the same seed value) for two different generators, the objects they create will always be located in the same places. Thus, the determinism of the result is also achieved.


    conclusions


    World machine


    Advantages

    • Caching calculation results. When the graph changes, the nodes are not recalculated, which these changes did not affect. This is very convenient and greatly saves time creating new content.
    • The presence of an output node, which allows you to output to files any number of calculated textures from anywhere in the graph and re-save them at the click of a button.
    • Возможность тайлового просчёта больших текстур (tiled build). При этом текстуры рендерятся фрагментами, благодаря чему появляется возможность распараллеливать рендеринг (задействуется многоядерность) и оптимально использовать занимаемую память. Однако не стоит забывать о том, что алгоритм эрозии в этом случае просчитывается симуляцией отдельно для каждого тайла, а не для всей поверхности ландшафта, и склеивание получившихся тайлов текстуры эрозии осуществляется перекрытием их смежных областей.
    • Достаточный набор устройств (базовых блоков которыми создаётся алгоритм по которому формируется ландшафт), для реализации практически любых алгоритмов построения ландшафта.
    • Есть возможность группировки частей графа для создания новых устройств с целью их дальнейшего переиспользования, но, к сожалению, отсутствует инстансинг — вставленные таким образом устройства будут являться копиями.
    • Возможность точного расчета только заданного фрагмента ландшафта. Сильно экономит время при работе над детализацией выбранных участков.

    Недостатки

    • Огромное количество проблем при работе с большими объёмами исходных данных (как векторных, так и растровых) и ландшафтами больших размеров. Например, при открытии вектора с данными береговой линии (в несколько тысяч точек) — FPS в редакторе стремится к нулю.
    • Поведение алгоритма эрозии (блока Erosion Device) зависит от финального разрешения ландшафта.
    • Отсутствие инструментов для создания горных рек. Вырезание ландшафта по сплайнам под реку без применения эрозии даёт нереалистичный результат. Если же применять эрозию, то в некоторых местах реку может засыпать поперёк.
    • Отсутствие возможности изменить или отключить интерполяцию исходных текстур.
    • Некоторые мелкие, но очень неприятные недоработки редактора. Например, такие как невозможность задания цифровых значений цвета в устройстве Colorizer (это можно сделать только визуально), использование int вместо float для некоторых параметров и непонятные ограничения в диапазонах значений параметров.

    In addition to the World Machine, you can also look at Quad Software Grome Editor , Planetside Software Terragen , or add an open (AGPL license) GPU-driven landscape generator Litosphere to suit your needs .


    Procedural Generators


    The main idea of ​​the development of all procedural generators should ideally be blurring the line between 2D and 3D, because 2D is only a special case of 3D.

    At the moment, there is not a single procedural generator that would allow:
    1. create algorithms for the formation of three-dimensional objects (voxels)
    2. create your own texture baking algorithms and easily rebuild them to fit your needs

    That is, it is not possible to use any information in the procedural generator with a low-poly, high-poly or algorithmically generated voxel 3D model to create, for example, a generator of seamless stone textures or rust flow patterns for any source model.

    In programs such as 3DS MAX or Substance Designer, it is possible to bake some cards from models, but all of them are rendered by algorithms sewn into the program that cannot be changed in any way, and there is no way to create new ones. The recent introduction of AngelSript in 3D-Coat gives hope, but it is not yet clear what its author wants to lead to.

    Also, there has long been a problem that could be solved already at the current level of development of procedural texture generators: these editors have learned how to remove seams along the edges of a texture rectangle being formed (for example, by offset or splat methods), but so far none of them can remove these seams on the texture at the points of tearing of the UV coordinates of the model.

    If all these missing features were realized, they could be used to create libraries with automatic texture generators (for example, metal surfaces with weather, dust and mud factors affecting them), the initial data, for which there would be only a three-dimensional model and settings material.


    useful links


    Andrey Kushner plu1on , Vyacheslav Sedovich slice3d (technical artists Unigine Corp.)

    Also popular now: