This page has been translated automatically.
Setting Up Development Environment
Usage Examples
High-Level Systems
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
Double Precision Coordinates
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.

Custom 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. This way is not recommended, as even slight changes in the source code can influence your material and it would not work correctly.

The algorithm of a custom material creation is the following:

  1. Create a material library - a .mat file in the target directory (all of the Unigine libraries are located in the data/core/materials/default directory).
  2. Create a base material declaration in the created material library.
  3. Specify a set of shaders - either combine existing shaders or write your own ones.
  4. Depending on the set of shaders, add required textures, parameters, and states to the declaration.
  5. Check, if the new material is loaded and rendered correctly.

As an example, check the base mesh_base material (data/core/materials/default/unigine_mesh.mat). It has two workflows: specular and metalness, contains a huge set of features.

  1. Declare the XML file and material library.

    Source code (XML)
    <?xml version="1.0" encoding="utf-8"?>
    <materials version="2.0" editable="0">

    Check the materials element for the details.

  2. Declare the material.

    Source code (XML)
    <material name="mesh_base" editable="0" parameters_prefix="m" defines="VERTEX_ATTRIBUTE_GEOMETRY">

    Check the material element for the details.

  3. Specify shaders.

    Source code (XML)
    <shader pass="deferred" object="mesh_static"
    <shader pass="depth_pre_pass" object="mesh_static"

    Check the shader element for the details.

  4. Specify material states.

    Source code (XML)
    <state name="alpha_fade" defines="name" hidden="1"/>
    <state name="workflow" items="metalness,specular" defines="items">
    <state name="multiple_environment_probes" transparent="2" defines="name">0</state>
    <state name="specular_map" workflow="0" defines="name" pass_defines="deferred,forward>

    Check the state element for the details.

  5. Set parameters.

    Source code (XML)
    <parameter prefix="m" name="material_mask" deferred="1" shared="0" type="expression">0xffffffff</parameter>
    <parameter name="albedo_color" workflow="0" shared="0" type="color">1.0 1.0 1.0 1.0</parameter> 
    <parameter name="color" type="combiner"

    Check the parameter element for the details.

  6. Specify textures.

    Source code (XML)
    <texture unit="0" name="diffuse"	workflow="1" anisotropy="1">core/textures/common/</texture>
    <texture unit="0" name="albedo"	workflow="1" anisotropy="1">core/textures/common/</texture>

    Check the texture element for the details.

  7. Set bindings.

    Source code (XML)
    <bind object="mesh_cluster" to="mesh_static"/>
    <bind object="mesh_clutter" to="mesh_static"/>
    <bind object="mesh_dynamic" to="mesh_static"/>
    <bind object="mesh_skinned" to="mesh_static"/>

    Check the bind element for the details.

Last update: 2017-07-03
Build: ()