Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins

Hierarchy and Inheritance

All of the individual materials are organized in libraries. A library is an XML file including a set of materials, which usually belongs to one specific project or a part of a project. For example, when you add a new material for an object in a virtual world, it will be saved in the material library of the world a material belongs to. Library is a way of external organization of the materials.

Inside the libraries, materials form a hierarchy. There are parent materials (in terms of Unigine, base materials) and materials, inherited from them (child materials). Unigine provides a set of base materials with the built-in shaders.

An inheritance algorithm is very flexible, as you can inherit an unlimited amount of materials from the base material and adjust their properties in the different ways. Also, if you inherit from the inherited and adjusted material, all of its properties will be saved and you would not have to re-define them.

There are some specifications you should be aware of while inheriting the materials:

  • There are some built-in materials (indirect and reflection), that can be seen in Editor as inherited from base ones, but having some properties the base materials do not have (this is a peculiarity of the Unigine built-in material system; when you will inherit from a material, all of the children will have the same properties the parents have). You can inherit from them in the same way you inherit from base materials. Remember, that if, for example, you want to create two identical materials except for one if reflecting and one is not, you cannot inherit them from one base material and simply turn reflection on or off. Instead, you will have to inherit the reflecting material from the reflecting base material and inherit the non-reflecting material from a non-reflecting one.
  • You need to maintain a proper loading order of material libraries.

How to Inherit a Material

The fastest and the safest way to create a new material is to inherit it from the base one and adjust its properties. Unigine provides the huge built-in material library to meet practically all user's demands.

To create the material by means of inheritance in Materials Editor, you need to do the following:

  1. Select the base material in the material library.
  2. Inherit this material by clicking the Inherit material button or pressing Ctrl+I.
  3. Enable the passes and options you want to apply to your material in the States tab of inherited material.
  4. Replace default textures with your prepared ones in the Textures tab of inherited material.
  5. Tweak the available parameters in the Parameters tab of inherited material.
Notice
Note, that base material states, textures and parameters cannot be changed.

Say, for example, you want to create a sand material:

  1. Inherit the appropriate material.

    A mesh_base material has all the required properties to simulate coverings, such as sand, ground etc. To inherit the material, in Materials Editor, choose the mesh_base material in the material hierarchy list and press the Inherit material button.

    In the appeared dialog window choose the library and the name for the new material.

  2. Enable states.

    A sand material is complicated, so we will need to turn it to the detail material to make it look realistic. Choose your material in the hierarchy list and set the Overlay first method of the Detail option in the States tab to enable the detail textures in the overlay mode.

  3. Replace textures.

    Prepare all required textures. In our case we used 3 textures: diffuse, normal and detail diffuse.
    Diffuse Texture
    Normal Map
    Detail Diffuse Texture

    Set paths to your textures in the Textures tab.

    Notice
    In this case we used the same normal map for both base and detail materials.
  4. Adjust parameters.

    For the detail texture to be displayed correctly, change the Detail parameter of the Transform field in the Parameters tab. For the finest result, increase the scale of the detail material normal value (Normal parameter of the Detail field). Increase the value of the Environment parameter (Ambient field) for the material to receive the environment color and look more realistic. As a sand is mat material, reduce the Glossiness parameter of the Shading field for wider highlights. To reduce the reflectance level, reduce the Fresnel bias parameter of the Shading field.

As a result we have got the intended sand material, assigned it to the mesh and put in the scene containing the water:

Last update: 2017-07-03