shown in other instead.
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:
- Select the base material in the material library.
- Inherit this material by clicking the Inherit material button or pressing Ctrl+I.
- Enable the passes and options you want to apply to your material in the States tab of inherited material.
- Replace default textures with your prepared ones in the Textures tab of inherited material.
- Tweak the available parameters in the Parameters tab of inherited material.
Say, for example, you want to create a sand material:
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.
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.
Replace textures.Prepare all required textures. In our case we used 3 textures: diffuse, normal and detail diffuse.Diffuse TextureNormal MapDetail Diffuse Texture
Set paths to your textures in the Textures tab.In this case we used the same normal map for both base and detail materials.
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: