shown in other instead.
Hierarchy and Inheritance
In Unigine, all of the materials are organized in libraries and form materials hierarchy.
Unigine provides a set of base materials with the built-in shaders which are always at the top of the material hierarchy. Properties of the base materials cannot be changed. So, to modify or extend one of the base materials, you should inherit a child material from it: the base material will pass its properties to the inherited material. Then these properties can be modified. You can inherit unlimited number of materials from one base material.
However, not only base materials can be used as parent ones. You can inherit a new material from any child material.
The parent of the material can be changed by clicking the Change material parent button in the Materials window.
Base mesh_base material
Child material inherited from mesh_base
The material ball on the left picture is rendered using the mesh_basebase material from the default materiallibrary. The material ball on the right picture is inherited from mesh_base and has 1 texture changed (the albedo texture). All the other properties are identical to the base material ones.
To be used in the project, materials should be organized in libraries.
The materials of the library are available only when this library is included in the .world file or in a .node file used in the world. You can add a material library in one of the following ways:
- Manually add references to the .world or .node files by editing them via a text editor.
- Add the library via the Materialswindow of UnigineEditor. In this case, the reference to this library will be added to the.world file automatically.
To open the list of all libraries included in the project via UnigineEditor, click the button in the Materials window:
By default, Unigine SDK includes a set of material libraries located in the data/core/materials/default directory.
All materials in the material library should be inherited from the base materials. If for some reason you cannot find the material to inherit or you need a special post-process, there is a way of creating a brand new material.
The proper order of materials loading is important. If one library has materials that inherit from materials in another library, the second library should be included first. The load order is set via the Materials window of UnigineEditor. For example, you have 2 libraries, custom1.mat and custom2.mat. If a material in custom2.mat (F in the picture below) inherits from a material in custom1.mat (C in the picture below), the custom1.mat library should be loaded first.
You can set the order of libraries loading, add new material libraries, save or remove them via the Materials windowof UnigineEditor:
Creating a Material Library
The material library is created with a new project automatically and is named after this project. However, you can create an additional library as follows:
- In the Materials window, click the
button. The list of material libraries will open.
- Click to add a new library. The file dialog window will open.
- Choose the directory for storing the library, specify a name for the library in the Name field and click Ok.
Now you can add new materials to this library.
Creating a New 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 inherit a material, perform the following in Materialswindow:
- Select the base material in the material library.
- Inherit this material: click the
Inherit material button or press Ctrl+I.
- Enable options you want to apply to your material in the States tab of the inherited material.
- Replace default textures with your prepared ones in the Textures tab of the inherited material.
- Tweak the available parameters in the Parameters tab of the inherited material.