This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
VR Development
双精度坐标
应用程序接口
Animations-Related Classes
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
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
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提供了一组 基础材质 ,这些着色器始终位于 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 Create Child button or right-click the material and choose Create Child.

    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.
    从此材质继承:单击Create Child按钮或右键单击材质,然后选择Create Child.

    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.基材的状态,纹理和参数无法更改。
最新更新: 2023-12-19
Build: ()