This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
创建内容
Content Optimization
Art Samples
Tutorials

层次结构和继承

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提供了一组 基础材料 ,这些着色器始终位于 materials层次结构的顶部。基础材料不能按层次结构进行组织:不能从其他基础材料继承基础材料。而且,基材的性能不能改变。因此,要修改基础材料之一,您应该从中继承 用户材料 :基础材料会将其属性传递给继承的材料。

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物料层次结构窗口中的物料层次结构
Base mesh_base material材质 mesh_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是使用SHA-1哈希算法生成的40个字符的十六进制字符串。

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. 对于基础和手册资料,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"/>
    父级:用户手册
    • 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.
      如果继承的用户资料也是手册,则*.mat文件存储用户资料的名称,父资料的名称和基础资料的名称。
      注意
      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"/>
      如果继承的用户资料不是手动的,则*.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.基材的状态,纹理和参数无法更改。
最新更新: 2020-11-11
Build: ()