This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Detail Materials

Adding Detail Materials

Detail materials (up to 4 per surface), that appear across the terrain, introduce high-detail variations of the basic terrain. With detail materials it is possible to create grass, rocks, small pebbles, etc. If using only a diffuse texture, the result may appear blurry when the camera is close to the terrain surface. The visually pleasing way out is to combine the diffuse texture with the tiled material textures that grant fine resolution from close by. The mask texture controls if a detail material is rendered visible in a given location.

Notice
Materials are seen only on the Patch LODs (0-3 LODs). To bake detail materials into diffuse textures, see Grabber. The number of detail materials across the whole terrain is unlimited; however, each surface can take no more than 4.

Mask for Detail Materials

The mask can define the visibility of four materials at maximum, because each channel of the mask (red, green, blue and alpha) is mapped to the material index (the 1st, the 2nd, the 3rd and the 4th material in the list, respectively).

  • If the value of the mask channel is 1, terrain texel is colored only with a material
  • If the mask value is 0, the pure diffuse color is rendered and no material is visible at all
  • The values are in between blend material and diffuse colors together

Materials should be added in a proper order before importing a mask. However, the order of detail materials can be later changed for each surface in the Surfaces tab. When the material is removed, all the next following materials move up in the list and take locations of the deleted one when applying the mask.

Creating Detail Materials (2 Modes)

There are two possible approaches when it comes to coloring of the terrain.

Overlay materials When detail materials are rendered in Overlay mode, the colors of the surface and detail material diffuse textures are blended. For example, this mode allows to create grass or dirt with unique coloring across the terrain. Grass in each location differs as diffuse colors of the terrain contribute to the rendered result.

Overlay mode
Overlay materials (blended)
For Overlay detail materials, recommendations are as follows:
  • Colors of the terrain are specified in the base diffuse texture (surface's one). As a result, each area is unique in its color
  • Colors of detail diffuse texture should be averaged out (close to neutral gray, with desaturated colors). In any of texture editors, open Levels and adjust the midpoint to the center (overall and per color channel as well). This helps to avoid unexpected or burned out colors when they are applied, a solely terrain diffuse colors are used
    Grass Stone
    Levels for Overlay materials
    Levels: adjust the Midpoint to the center (per color channel as well).
  • Detail diffuse colors provide the following result when blended with terrain diffuse:
    1. Grey color of detail diffuse (RGB = 127) means that pure terrain diffuse color is used. Detail color does not influence the result at all
    2. White color of detail diffuse (RGB = 256) means that pure white color will be rendered on terrain.
    3. Black color of detail diffuse (RGB = 0) means that pure black color will be rendered on terrain.
  • Alpha of the detail diffuse texture specifies intensity of the specular highlights. The same approach as for colors is used:
    1. Alpha = 127 means that terrain specularity is not influenced by the detail material alpha.
    2. Alpha = 256 results in higher specularity.
    3. Alpha = 0 results in no specular hightlights.
    Notice
    Diffuse Scale scales alpha values as well. In order to use this slider to increase contrast for alpha, create a detail material texture desaturated RGB colors. This way, setting a high Diffuse Scale value will produce the necessary result.
  • Resulting colors of non-gray detail materials in Overlay mode (especially if there is more then one in one location) will be intensified, i.e. the result will be of higher contrast.
    Notice
    If you wish to avoid mixing of detail materials (which can result in unexpected colors), make sure that the mask specifies visibility of only one material. In this case, for example, RGBA values of the mask in one location should be (1,0,0,0) instead of (0.5, 0.5, 0.1, 0.3).
    From close-by From further away
    1 detail material
    2 detail materials
Blending in Overlay mode is done according to the following formula:
Source code (Shader)
resulting_color = diffuse_color + (detail_color * 2 - 1) * detail_scale
Overlap materials Overlap mode for detail materials is simply for drawing them atop of terrain (without blending). Unlike Overlay, this mode to render detail without any color alternation, for example, flowers, stones, etc.

Overlap mode
Overlap materials (non-blended, with alpha)
  • Detail materials do not change color (no color variation for them across the terrain).
  • Alpha of the detail diffuse texture indicates material visibility. The final result is achieved by multiplying the alpha value to the terrain mask value (see Value parameter to tweak mask threshold in realtime).

    Alpha and mask combined together can produce the effect of smooth fading of elements. For example, the shown material will be rendered in a different way when moving from the center to the edge of its location according to the mask. The dirt between stones will disappear first, then stones will be rendered smaller and smaller until completely disappear (see the picture above).
    Overlap material colors Overlap material alpha
    Overlap material colors
    Overlap material alpha

Detail Material Options

Each detail material is represented with two textures: diffuse and normal map. The following options are available:

Name The name of the detail material.
Detail Rendering mode for the detail material:
  • None — not rendered
  • Overlay — for blended mode
  • Overlap — for non-blended mode
Transform Coordinates transformations material textures (diffuse texture together with a normal map):
  • Scale X — tile of the textures along the X axis. For example, by the scale of 2 the texture will be twice as small (it would have two tiles instead of one).
  • Scale Y — tile of the textures along the Y axis.
  • Offset X — a textures offset along the X axis. For example, by the offset of 0.5 the texture is rendered as if its left corner is in the middle of the texture.
  • Offset Y — a textures offset along the Y axis.
Value This parameter is available only in Overlap mode. It controls the visibility of detail material according to the mask:
  • By the minimum value of 0, detail material is rendered everywhere.
  • By the maximum value of 1, no detail material is rendered.
Small Value Bigger Value
Small Value
Bigger value
Threshold This parameter is available only in Overlap mode. It controls how smooth the detail material becomes visible. For that, detail material is blended with the diffuse texture or other detail materials underneath it.
  • The higher the value, the bigger the area of blending of between detail material and terrain diffuse colors.
Zero Threshold (no blending) Higher Threshold
Threshold = 0 (no blending)
Threshold = 0.05
Diffuse Diffuse texture for the detail diffuse texture.
Diffuse Scale Diffuse Scale controls color intensity of the detail diffuse texture.
  • By the minimum of 0, the diffuse texture is not visible at all.
  • By the maximum of 1, the diffuse texture is fully appeared.
Normal Normal map for the detail diffuse texture.
Normal Scale Normal Scale controls visibility of the detail normal map, i.e. the intensity of lighting according to the normal map.
Last update: 2017-07-03
Build: ()