This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
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.

Hierarchy and Inheritance

In Unigine, all of the materials are organized in libraries and form materials hierarchy.

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.

Notice
All inherited and non-overridden properties will be updated automatically, if they are updated in the parent material.
You need to maintain a proper loading order of material libraries while inheriting the materials.

Hierarchy of materials in the Materials window

The parent of the material can be changed by clicking the   Change material parent button in the Materials window.

For example:

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.

Material Libraries

To be used in the project, materials should be organized in libraries.

A library is an XML file with the .mat extension that includes a set of materials, which usually belongs to one specific project or a part of a project.

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.

Notice
There is no need to include the default material libraries into the world, they are included by default when creating the world.

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.

Loading order for material libraries

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:

  1. In the Materials window, click the button. The list of material libraries will open.

  2. Click to add a new library. The file dialog window will open.
  3. Choose the directory for storing the library, specify a name for the library in the Name field and click Ok.

    The new library will be added to the list of preloaded libraries.

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:

  1. Select the base material in the material library.
  2. Inherit this material: click the   Inherit material button or press Ctrl+I.

    In the dialog window that opens, choose the library and the name for the new material.

  3. Enable options you want to apply to your material in the States tab of the inherited material.

  4. Replace default textures with your prepared ones in the Textures tab of the inherited material.

  5. Tweak the available parameters in the Parameters tab of the inherited material.

Notice
States, textures and parameters of the base material cannot be changed.
Last update: 2017-07-03
Build: ()