移动端渲染优化
Mobile Rendering Optimization
移动端优化的核心是认清设备的 CPU/GPU 速度、线程、带宽和内存,然后控制最主要的几项开销:Draw Call(官方称其为当前导致图形性能低下的最大因素,在 Galaxy Tab S6 上建议约 700 个,低端设备少于 500 个)、材质复杂度和 overdraw。合并网格和材质(Substance 把多种材质画进同一张纹理,用顶点色作遮罩)是减少 Draw Call 最直接的办法。
先了解设备
官方:要熟悉设备的 CPU 和 GPU 速度、线程数和带宽,以及内存、显存和可用磁盘空间。Stat TextureGroup 可以查看各纹理池的内存占用,Stat RHI 可以输出 Draw Call 数量。(Optimization and Development Best Practices for Mobile Projects in Unreal Engine)定位瓶颈的通用方法见 渲染瓶颈定位与性能度量、UE5 性能分析。
Draw Call:最大的开销
- Draw Call 数量取决于场景中唯一网格的数量,以及每个网格使用的唯一材质 ID 数量。官方原话:「目前,大量 Draw Call 是导致图形性能低下的最大因素,应尽可能减少。」(Optimization and Development Best Practices for Mobile Projects in Unreal Engine)
| 场景 | Galaxy Tab S6 目标 | 低端设备 |
|---|---|---|
| 优化过的一般场景 | 约 700 | 少于 500 |
| HMI(材质独特而复杂) | 100 | 最好少于 50 |
(Optimization and Development Best Practices for Mobile Projects in Unreal Engine)另外注意:PIE 中和设备上的 Draw Call 数不同,要在设备上测。
- 减少网格数是最简单的办法。合并材质:用 Substance Painter 等工具把多种材质画进同一张纹理,再用一个简单的 UE 材质作为材质实例的基础,只输入不同的纹理。遮罩可以用黑白纹理,但用顶点色更高效、边界更锐利,因为不依赖纹理分辨率。(Optimization and Development Best Practices for Mobile Projects in Unreal Engine)通用原理见 绘制调用与状态切换优化,材质实例见 材质系统。
像素开销
- 材质复杂度会增加像素开销:每个像素的指令越多,计算越久。不透明材质最便宜,但不同着色模型和基础着色器代码之间差别很大。多层半透明叠在一起会产生 overdraw。(Optimization and Development Best Practices for Mobile Projects in Unreal Engine)见 像素与帧缓冲优化。
- 移动平台并不支持所有类型光源的动态阴影,光源移动性的选择要考虑这一点,见 光源类型与静态光照。
资产质量
从高模烘焙法线贴图时,有很多因素会降低进入引擎后的质量;静态网格可以在 LOD 设置中开启 Use Full Precision UVs 和 Use High Precision Tangent Basis 来减少瑕疵。(Optimization and Development Best Practices for Mobile Projects in Unreal Engine,见 法线贴图与凹凸贴图)
移动端前向与延迟着色
5.8 没有专页,以下来自 5.4 文档《Rendering Features for Mobile Games》的功能表,以及 Epic 员工 Jack Porter 在 Unreal Fest 2025 的演讲幻灯片《Developing Mobile Games with UE 5.6》。(Rendering Features for Mobile Games (5.4) + Unreal Fest 2025 mobile talk)
5.4 文档列出三种移动渲染配置:
| 功能 | 移动前向 (Mobile Forward) | 移动延迟 (Mobile Deferred) | 前向且关闭 HDR(头显 XR) |
|---|---|---|---|
| 支持的 API | OpenGL ES 3.2 / Metal / Vulkan / Switch | Metal / Vulkan / Switch | — |
| 光照函数 (Light Function,静态光) | 否 | 是 | 否 |
| IES 纹理(固定/可移动光) | 否 | 是 | 否 |
| DBuffer 贴花 Roughness 响应 | 否 | 是 | 否 |
| 延迟贴花 (Deferred Decal) | 是 | 是 | 否 |
| 体积云 / 体积雾 / VSM / TSR | 否 | 否 | 否 |
演讲给出的 5.6 变化:延迟渲染器现在是所有移动平台的默认(Android GLES、Android Vulkan、iOS Metal),GBuffer 为每像素 128 位;支持更多光照模型和静态光照,BRDF 改为与桌面渲染器一致。在 iOS 和 Vulkan Android 上,GBuffer 是 memoryless 的,存放在 GPU 的 tile 片上内存;在 OpenGL ES 上改为多 Pass,官方称比 PLS 和 framebuffer fetch 更可靠也更快。(Rendering Features for Mobile Games (5.4) + Unreal Fest 2025 mobile talk)
以下流程图概括 5.6 及计划中的多 Pass 延迟方案:
flowchart LR
A["Base Pass 写 GBuffer 与深度"] --> B{"平台"}
B -->|iOS Metal / Android Vulkan| C["GBuffer 留在 tile 片上内存"]
B -->|Android GLES| D["多 Pass"]
C --> E["光照 Pass"]
D --> E
A -.->|"计划 5.7+"| F["GBuffer 存系统内存 多 Pass 延迟"]
F --> G["后处理可读 GBuffer DFAO DF 阴影 SSR"]图中虚线是演讲列出的未来计划:把 GBuffer 存进系统内存。好处是不需要深度预 Pass,可以把 DFAO、距离场阴影、SSR、DBuffer 贴花作为可伸缩选项,后处理也能访问 GBuffer,Epic 自己的内容测下来与 subpass 模式持平或稍快。代价是额外约 15 MB 系统内存和更高的带宽,帧缓冲压缩可以缓解一部分。(Rendering Features for Mobile Games (5.4) + Unreal Fest 2025 mobile talk)
怎么切换着色路径(UE 5.8 官方文档):在 Engine.ini 中用控制台变量 r.Mobile.ShadingPath 设置,0 为移动前向着色,1 为移动延迟着色;也可以在 Project Settings 中把 Mobile Shading 下拉框设为 Deferred Shading 并重启编辑器。(Mobile Rendering and Shading Modes for Unreal Engine Using the Mobile Deferred Shading Mode in Unreal Engine)
| 移动前向 | 移动延迟 | |
|---|---|---|
| 官方推荐场景 | 使用预计算光照的项目(强烈推荐) | 使用动态光照的项目、目标为 tile-based GPU |
| 光照特性 | 基础 | 额外支持 Light Function、IES 光源配置、受光贴花,局部光源渲染更高效 |
| 预计算光照下的着色模型 | 不受限 | 只有 DefaultLit 和 Unlit |
| 材质开销(官方示例) | 147 条指令、2 个采样器 | 34 条指令、0 个采样器 |
(Mobile Rendering and Shading Modes for Unreal Engine Using the Mobile Deferred Shading Mode in Unreal Engine)移动延迟把 GBuffer 放在 GPU 的 tile 内存里,不写入系统内存;不支持 memoryless 渲染目标的设备会为 GBuffer 分配系统内存,占用略多。它不需要为每次绘制绑定阴影和反射纹理,图形状态管理更少,因此 CPU 性能更好。(Using the Mobile Deferred Shading Mode in Unreal Engine)
还有第三种选择:在高端设备上使用桌面渲染器。iOS 在 Platforms > iOS > Rendering 中开启 Metal Desktop Renderer(Beta);Android 在 Platforms > Android > Build 中开启 Support Vulkan Desktop(实验性),要求设备支持 SM5,资源开销远高于两种移动路径。(Using the Desktop Renderer on Mobile in Unreal Engine)
默认着色路径:逐版本核对
| 版本 | 官方文档的说法 | 其他来源 |
|---|---|---|
| UE 5.5 / 5.6 / 5.7 / 5.8 | 《Mobile Rendering and Shading Modes》四个版本的文本完全相同:前向着色「是移动端的默认着色模式」 | — |
| UE 5.6 | 同上 | Epic 员工 Jack Porter 的 Unreal Fest 2025 幻灯片:「Deferred Renderer now default used on all mobile platforms」,旁边标注了「Used on Android Vulkan / Android GLES / iOS Metal」 |
| UE 5.7 / 5.8 | 发行说明全文中没有提到修改移动端默认着色路径(只提到 5.7 弃用 r.Mobile.UseClusteredDeferredShading、5.8 修复移动延迟路径的自发光问题) | — |
(Mobile Rendering and Shading Modes for Unreal Engine Mobile Rendering and Shading Modes for Unreal Engine)UE 5.6 发行说明页被拦截(403 或只返回目录),没能核对。
结论:按官方文档,引擎的 r.Mobile.ShadingPath 默认值在 5.5–5.8 中都是 0(前向)。演讲中的「default」更可能指 Epic 自己的项目(「Used on」)或新模板的配置,但这一点没有官方文字证实,因此仍保留为未解决的分歧。项目实际使用哪条路径,应以 DefaultEngine.ini 或 Project Settings 中 Mobile Shading 的值为准。
出处
- Optimization and Development Best Practices for Mobile Projects in Unreal Engine UE 5.8 文档
- Rendering Features for Mobile Games (5.4) + Unreal Fest 2025 mobile talk UE 5.4 文档 + Unreal Fest 2025 Epic 演讲(UE 5.6)
- Mobile Rendering and Shading Modes for Unreal Engine UE 5.8 文档
- Using the Mobile Deferred Shading Mode in Unreal Engine UE 5.8 文档
- Using the Desktop Renderer on Mobile in Unreal Engine UE 5.8 文档
- Mobile Rendering and Shading Modes for Unreal Engine UE 5.5–5.7 文档