This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Программирование на C#
Рендеринг
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров узла
Setting Up Materials
Setting Up Properties
Освещение
Landscape Tool
Sandworm
Использование инструментов редактора для конкретных задач
Extending Editor Functionality
Встроенные объекты
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
UnigineScript
C++
C#
Унифицированный язык шейдеров UUSL
File Formats
Rebuilding the Engine Tools
GUI
Двойная точность координат
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Работа с контентом
Оптимизация контента
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Иерархия и наследование

In Unigine, materials can form hierarchy. However, there are several rules and constraints that described below and must be taken into account.В Unigine материалы могут образовывать иерархию. Однако есть несколько правил и ограничений, которые описаны ниже, и их необходимо учитывать.

Materials HierarchyИерархия материалов#

Materials hierarchy forms by inheriting one material from another. A parent material passes its properties to the inherited material so that they can be overridden.Иерархия материалов формируется путем наследования одного материала от другого. Родительский материал передает свои свойства унаследованному материалу, чтобы их можно было переопределить.

Unigine provides a set of base materials with the built-in shaders which are always at the top of the materials hierarchy. The base materials cannot be organized in hierarchy: no base material can be inherited from another base material. Moreover, properties of the base materials cannot be changed. So, to modify one of the base materials, you should inherit a user material from it: the base material will pass its properties to the inherited material. Unigine предоставляет набор базовых материалов со встроенными шейдерами, которые всегда находятся наверху иерархии материалов . Базовые материалы не могут быть организованы в иерархию: никакой базовый материал не может быть унаследован от другого базового материала. Кроме того, нельзя изменить свойства основных материалов. Итак, чтобы изменить один из базовых материалов, вы должны унаследовать от него пользовательский материал : базовый материал передаст свои свойства унаследованному материалу.

However, not only base materials can be used as parent ones. You can inherit a new material from any user material.Однако не только базовые материалы могут использоваться в качестве исходных. Вы можете унаследовать новый материал от любого пользовательского материала.

Примечание
All inherited and non-overridden properties will be updated automatically, if they are updated in the parent material.Все унаследованные и непереопределенные свойства будут обновлены автоматически, если они обновлены в родительском материале.

The parent of the material can be changed by dragging the material to a new parent.Родителя материала можно изменить, перетащив материал на новый родительский элемент.

In this way, there are the following reasons to create materials hierarchy:Таким образом, существуют следующие причины для создания иерархии материалов:

  • Inheriting from the base material allows editing its properties via Materials Editor.Наследование от базового материала позволяет редактировать его свойства через Редактор материалов.
  • Inheriting from the user material allows for mass controlling values of multiple materials parameters.Наследование из пользовательского материала позволяет массово контролировать значения нескольких параметров материалов.

Hierarchy of materials in the Materials Hierarchy WindowИерархия материалов в окне Materials Hierarchy
Base mesh_base materialМатериал mesh_base base
Child material inherited from mesh_base Дочерний материал, унаследованный от mesh_base

The material ball on the left picture is rendered using the mesh_base base material from the default set of materials. 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.Материальный шар на левом изображении визуализируется с использованием базового материала mesh_base из набора материалов по умолчанию. Материальный шар на правом изображении унаследован от mesh_base и имеет 1 измененную текстуру (текстура albedo ). Все остальные свойства идентичны свойствам основного материала.

Materials Loading OrderПорядок загрузки материалов#

Materials hierarchy doesn't affect the loading order of materials: on the engine start-up, all materials of the project are loaded, the base materials are loaded first. And since each user material refers to both the parent and the base materials, the base material is used as the parent one until the actual parent is loaded. So, when the application is loaded, all materials existing in the project are presented in the materials hierarchy.Иерархия материалов не влияет на порядок загрузки материалов: при запуске двигателя загружаются все материалы проекта, сначала загружаются базовые материалы. И поскольку каждый пользовательский материал относится как к родительскому, так и к базовому материалам, основной материал используется в качестве родительского, пока не будет загружен фактический родительский материал. Таким образом, когда приложение загружено, все материалы, существующие в проекте, представлены в иерархии материалов.

Referring Materials by GUIDsСсылки на материалы по GUID#

A GUID (Globally Unique Identifier) is an identifier for a material. The GUID is a 40-character hexadecimal string generated by using the SHA-1 hash algorithm. GUID (глобальный уникальный идентификатор) - это идентификатор материала. GUID - это шестнадцатеричная строка из 40 символов, созданная с помощью хэш-алгоритма SHA-1.

Materials hierarchy is based on GUIDs: all materials are referred by GUIDs, even the base and manual ones (the GUIDs for such materials are generated in run-time by their names).Иерархия материалов основана на GUID: все материалы ссылаются на GUID, даже базовые и ручные (GUID для таких материалов генерируются во время выполнения по их именам).

Only the user materials store their GUIDs explicitly: the GUID is generated automatically on user material creation and is written in the *.mat file.Только пользовательские материалы явно хранят свои GUID: GUID генерируется автоматически при создании пользовательского материала и записывается в файл *.mat.

Примечание
Each user material created via Material Editor has the GUID.Каждый пользовательский материал, созданный с помощью редактора материалов, имеет идентификатор GUID.

For example:Например:

Исходный код (XML)
<material version="2.5.0.2" name="mesh_base_0" guid="3e7f5c9535777e15966cb5f915d25b62620b2bef" parent="401e90ccd85f4f2bb97c19ab9e1351325c4012eb" base_material="mesh_base"/>

The user material GUID is stored in the guid attribute. If the user material is inherited from another user material, it will refer the parent by its GUID (the parent attribute in the example above). GUID пользовательского материала хранится в атрибуте guid . Если пользовательский материал унаследован от другого пользовательского материала, он будет ссылаться на родительский элемент по его GUID (атрибут parent attribute in the example above).

Using GUIDs makes it difficul to edit the user materials manually. For example, to rename such material, it is required to generate a GUID for the new name and replace the current GUID. Использование GUID затрудняет редактирование пользовательских материалов вручную. Например, чтобы переименовать такой материал, необходимо сгенерировать GUID для нового имени и заменить текущий GUID.

For the base and manual materials, the GUIDs are generated in run-time by their names. If the name of such material is changed, the GUID will also be changed. That is why the base and manual materials cannot be renamed in run-time. For the same reason, the *.basemat and *.mat files store their names, not GUIDs. And references to such materials stored in these files are usually name-based too. Для базовых материалов и материалов manual идентификаторы GUID генерируются во время выполнения по их именам. Если название такого материала изменится, GUID также изменится. Поэтому базовые и ручные материалы нельзя переименовать во время выполнения. По той же причине файлы *.basemat и *.mat хранят свои имена, а не GUID. И ссылки на такие материалы, хранящиеся в этих файлах, также обычно основаны на именах .

Types of InheritanceТипы наследования#

As it was mentioned above, the user material can be inherited from the base, user or manual user material. Depending on the type of the parent, the *.mat file will store the reference to it as follows:Как было упомянуто выше, пользовательский материал может быть унаследован от базового, пользовательского или ручного пользовательского материала. В зависимости от типа родителя файл *.mat будет хранить ссылку на него следующим образом:

  • Parent: base material. The *.mat file stores a GUID of the user material and a name of the base material.
    Исходный код (XML)
    <material version="2.5.0.2" name="mesh_base_4" guid="67cc0594c0ff0f50ac7b34978a5e04c73c2cff90" base_material="mesh_base"/>
    Родитель: базовый материал . Файл *.mat хранит GUID пользовательского материала и имя основного материала.
    Исходный код (XML)
    <material version="2.5.0.2" name="mesh_base_4" guid="67cc0594c0ff0f50ac7b34978a5e04c73c2cff90" base_material="mesh_base"/>
  • Parent: user material. The *.mat file stores a GUID of the user material, a GUID of the parent material and a name of the base material.
    Исходный код (XML)
    <material version="2.5.0.2" name="mesh_base_6" guid="9542cd76ae16362527359168ea2e9ff1b42c8c2e" parent="67cc0594c0ff0f50ac7b34978a5e04c73c2cff90" base_material="mesh_base"/>
    Родитель: материал пользователя . Файл *.mat хранит GUID пользовательского материала, GUID родительского материала и имя базового материала.
    Исходный код (XML)
    <material version="2.5.0.2" name="mesh_base_6" guid="9542cd76ae16362527359168ea2e9ff1b42c8c2e" parent="67cc0594c0ff0f50ac7b34978a5e04c73c2cff90" base_material="mesh_base"/>
  • Parent: manual user material.
    • If the inherited user material is also manual, the *.mat file stores a name of the user material, a name of the parent material and a name of the base material.
      Примечание
      Only the manual material can refer to the parent manual material by the name.Only the manual material can refer to the parent manual material by the name.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" parent_name="mesh_base_1" base_material="mesh_base"/>
      Only the manual material can refer to the parent manual material by the name.
      If the inherited user material is also manual, the *.mat file stores a name of the user material, a name of the parent material and a name of the base material.
      Примечание
      Only the manual material can refer to the parent manual material by the name.Only the manual material can refer to the parent manual material by the name.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" parent_name="mesh_base_1" base_material="mesh_base"/>
    • If the inherited user material isn't manual, the *.mat file stores a GUID of the user material, a GUID of the parent material (generated in run-time by its name) and a name of the base material.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" guid="8c8cc0a19ff114521d9594e04a178a1c6b25ec5c" parent="ee43b4c84571cebeafd4153e24e35c113b5f56c2" base_material="mesh_base"/>
      If the inherited user material isn't manual, the *.mat file stores a GUID of the user material, a GUID of the parent material (generated in run-time by its name) and a name of the base material.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" guid="8c8cc0a19ff114521d9594e04a178a1c6b25ec5c" parent="ee43b4c84571cebeafd4153e24e35c113b5f56c2" base_material="mesh_base"/>
    If the inherited user material is also manual, the *.mat file stores a name of the user material, a name of the parent material and a name of the base material.
    Примечание
    Only the manual material can refer to the parent manual material by the name.Only the manual material can refer to the parent manual material by the name.
    Исходный код (XML)
    <material version="2.5.0.2" manual="1" name="mesh_base_2" parent_name="mesh_base_1" base_material="mesh_base"/>
    Only the manual material can refer to the parent manual material by the name.If the inherited user material isn't manual, the *.mat file stores a GUID of the user material, a GUID of the parent material (generated in run-time by its name) and a name of the base material.
    Исходный код (XML)
    <material version="2.5.0.2" manual="1" name="mesh_base_2" guid="8c8cc0a19ff114521d9594e04a178a1c6b25ec5c" parent="ee43b4c84571cebeafd4153e24e35c113b5f56c2" base_material="mesh_base"/>
    Родитель: manual материал пользователя.
    • If the inherited user material is also manual, the *.mat file stores a name of the user material, a name of the parent material and a name of the base material.
      Примечание
      Only the manual material can refer to the parent manual material by the name.Only the manual material can refer to the parent manual material by the name.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" parent_name="mesh_base_1" base_material="mesh_base"/>
      Only the manual material can refer to the parent manual material by the name.
      Если унаследованный пользовательский материал также является manual, файл *.mat хранит имя пользовательского материала, имя родительского материала и имя основного материала.
      Примечание
      Only the manual material can refer to the parent manual material by the name.Только manual материал может ссылаться на основной manual материал по имени.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" parent_name="mesh_base_1" base_material="mesh_base"/>
    • If the inherited user material isn't manual, the *.mat file stores a GUID of the user material, a GUID of the parent material (generated in run-time by its name) and a name of the base material.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" guid="8c8cc0a19ff114521d9594e04a178a1c6b25ec5c" parent="ee43b4c84571cebeafd4153e24e35c113b5f56c2" base_material="mesh_base"/>
      Если унаследованный пользовательский материал не является manual, файл *.mat хранит GUID пользовательского материала, GUID родительского материала (сгенерированный во время выполнения по его имени) и имя базового материала.
      Исходный код (XML)
      <material version="2.5.0.2" manual="1" name="mesh_base_2" guid="8c8cc0a19ff114521d9594e04a178a1c6b25ec5c" parent="ee43b4c84571cebeafd4153e24e35c113b5f56c2" base_material="mesh_base"/>

Creating a User MaterialСоздание пользовательского материала#

Unigine provides the huge set of built-in base materials to meet practically all user's demands. So, the fastest and the safest way to create a new material is to create a user material by inheriting it from the base one and adjusting its properties.Unigine предоставляет огромный набор встроенных базовых материалов, чтобы удовлетворить практически все потребности пользователя. Итак, самый быстрый и безопасный способ создать новый материал - создать пользовательский материал, унаследовав его от базового и настроив его свойства.

Примечание
The user material created via Materials Editor in run-time cannot be customized: a set of user material properties cannot differ from properties of the parent (base) material.Пользовательский материал, созданный с помощью редактора материалов во время выполнения, нельзя настроить: набор свойств пользовательского материала не может отличаться от свойств родительского (базового) материала.

To inherit a material, perform the following in the Materials Editor:Чтобы наследовать материал, выполните в редакторе материалов следующие действия:

  1. Select the base material.Выберите основной материал.
  2. Inherit from this material: click the Inherit button or right-click the material and choose Inherit.

    The new *.mat file that stores a GUID of the new material and a reference to the mesh_base base material will be created. To rename the material, right-click the material and choose Rename: the file will be renamed as well.The new *.mat file that stores a GUID of the new material and a reference to the mesh_base base material will be created. To rename the material, right-click the material and choose Rename: the file will be renamed as well.

    The new *.mat file that stores a GUID of the new material and a reference to the mesh_base base material will be created. To rename the material, right-click the material and choose Rename: the file will be renamed as well.
    Наследуйте из этого материала: нажмите кнопкуНажмите кнопку Наследовать или щелкните материал правой кнопкой мыши и выберите Inherit.

    The new *.mat file that stores a GUID of the new material and a reference to the mesh_base base material will be created. To rename the material, right-click the material and choose Rename: the file will be renamed as well.Будет создан новый файл *.mat, в котором хранится GUID нового материала и ссылка на базовый материал mesh_base. Чтобы переименовать материал, щелкните материал правой кнопкой мыши и выберите Rename: файл также будет переименован.

  3. Enable properties 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.
    Настройте доступные параметры на вкладке Параметры унаследованного материала.
Примечание
States, textures and parameters of the base material cannot be changed.Состояния, текстуры и параметры основного материала не могут быть изменены.
Последнее обновление: 09.04.2021
Build: ()