Unreal 中的材料建议Material recommendations in Unreal

你使用的材料可以直接影响你的项目在 Unreal 引擎中的运行情况。The materials you use can directly affect how well your projects run in Unreal Engine. 此页面作为基本设置的快速入门,你应该使用这些设置来获得混合现实应用程序的最佳性能。This page acts as a quick-start for the basic settings you should be using to get the best performance out of your mixed reality applications.

使用 CustomizedUVsUsing CustomizedUVs

如果需要对材料提供 UV 拼贴,请使用 CustomizedUVs,而不是直接修改纹理节点的 UV。If you need to provide UV tiling on your material, use CustomizedUVs rather than modifying the UV of the texture node directly. CustomizedUVs 使你可以在顶点着色器而不是像素着色器中操作 Uv-11。CustomizedUVs let you manipulate UVs in the Vertex shaders rather than the Pixel shader.

Unreal 中的材料设置

可以在以下屏幕截图中的 Unreal 引擎文档 和最佳做法示例中找到材料详细信息:You can find material details in the Unreal Engine documentation and best practice examples in the screenshots below:

建议  在 Unreal 中设置的材料设置 Recommended material setup Recommended material settings in Unreal Recommended material setup

不建议  的材料设置 Unreal 不推荐的材料 设置 Non recommended material settings in Unreal Non-recommended material setup

更改混合模式Changing Blend Mode

除非有很强的理由,否则我们建议将混合模式设置为不透明。We recommend setting the blend mode to opaque unless there's a strong reason to do otherwise. 屏蔽和半透明的材料速度缓慢。Masked and Translucent materials are slow. 有关详细信息,请 参阅 Unreal 引擎文档You can find more details on materials in the Unreal Engine documentation.

更改混合模式

更新移动的照明Updating lighting for mobile

应关闭完全精度。Full precision should be turned off. 可以通过翻方向信息来拔下 Lightmap 照明。Lightmap lighting can be dialed down by turning of directional information. 禁用后,lightmaps 中的照明将是平面但更便宜。When disabled, lighting from lightmaps will be flat but cheaper.

Unreal 中的移动材料设置

调整前向底纹Adjusting Forward Shading

这些选项以性能为代价提高视觉保真。These options improve visual fidelity at the cost of performance. 为了获得最佳性能,应关闭它们。They should be turned off for maximum performance.

Unreal 中的前向底纹材料设置

设置材料半透明度Setting material translucency

指示半透明材料应不受布隆或 DOF 影响。Indicates that the translucent material should not be affected by bloom or DOF. 由于这两种影响都非常罕见,因此默认情况下此设置应处于启用状态。Since both those effects are rare in MR, this setting should be on by default.

Unreal 中的移动单独半透明度设置

可选设置Optional settings

以下设置可能会提高性能,但请注意,它们会禁用某些功能。The following settings may improve performance, but note that they disable certain features. 仅当你确定不需要使用这些功能时才使用这些设置。Only use these settings if you're sure you don't need the features in question.

Unreal 中的可选材料设置

如果材料不需要反射或闪光,则设置此选项可显著提高性能。If your material doesn't require reflections or shine, then setting this option can provide a tremendous performance boost. 在内部测试中,它的速度与 "unlit" 的速度一样快,同时提供照明信息。In internal testing, it's as fast as "unlit" while providing lighting information.

最佳做法Best practices

下面的 "设置" 不是与材料相关的最佳实践。The following aren't "settings" as much as they're best practices related to Materials.

创建参数时,最好尽可能使用 "静态参数"。When creating parameters, prefer to use "Static Parameters" wherever possible. 静态开关可用于删除内容的整个分支,而不会产生运行时开销。Static Switches can be used to remove an entire branch of a material with no runtime cost. 实例可以具有不同的值,从而使模板化着色器设置为无性能损失。Instances can have different values, making it possible to have a templated shader set up with no performance loss. 缺点是创建了多个将导致重新编译着色器的排列。The downside, is that several permutations are created that will cause shader recompilation. 尝试最大程度地减少材料中的静态参数数量以及这些静态参数的排列数。Try to minimize the number of static parameters in the material and the number of permutations of those static parameters that are used. Unreal 引擎文档中,可以找到有关呈现材料参数的更多详细信息。You can find more details on rendering material parameters in the Unreal Engine documentation.

材料设置最佳方案

创建材料实例时,应将首选项指定为在 "材料实例动态" 上的 " 材料实例常量 "。When creating Material Instances, preference should be given to Material Instance Constant over Material Instance Dynamic. "材料实例常量" 是一种在运行时之前只计算一次的实例材料。Material Instance Constant is an instanced Material that calculates only once before runtime.

通过 "内容浏览器" 创建的材料实例 (右键单击 > 创建材料实例 ,) 是一个材料实例常量。The material instance created via the Content Browser (right-click > Create Material Instance) is a Material Instance Constant. 通过代码创建 "材料实例动态"。Material Instance Dynamic are created via code. 有关详细信息,请 参阅 Unreal 引擎文档You can find more details on material instances in the Unreal Engine documentation.

在 Unreal 中创建材料实例

密切关注材料/着色器的复杂性。Keep an eye on the complexity of your materials/shaders. 可以通过单击 "平台统计信息" 图标来查看各种平台上的材料成本。You can view the cost of your Material on various platforms by clicking on the Platform Stats icon. 你还可以在 Unreal 引擎文档中找到有关材料的更多详细信息。You can also find more details on materials in the Unreal Engine documentation.

在 Unreal 中创建材料实例动态设置

您可以通过着色器复杂性 视图模式来快速了解着色器的相对复杂性。You can get a quick idea of the relative complexity of your shader via the Shader Complexity View mode.

  • 查看模式热键: Alt + 8View Mode Hotkey: Alt + 8
  • 控制台命令: viewmode shadercomplexityConsole command: viewmode shadercomplexity

Unreal 中的材料复杂性

请参阅See also