Origin
zhuanlan.zhihu.com
Tags
Unity
渲染
性能优化
经验分享
技术详解
项目
收藏夹
创建时间
收藏类型
Cubox 深度链接
更新时间
原链接
描述
一、Demo 介绍
参考文献:
Book of the Dead 首次在 GDC 2018 亮相,由 Unity Demo Team 制作。Demo 中所有的自然环境资源都是照片扫描级别的真实物件和纹理,主要来源于 Quixel Megascans,一个在 Asset Store 上发布的高质量扫描资源库。
Book of the Dead: Environment 的资源下载(免费):
Quixel Megascans 的资源下载(收费):
Demo 针对现在主机平台的性能进行了优化,展示了 Unity 2018 新的 HD 渲染管线的出色效果,让我们可以更加深入的了解 Unity 目前和将来可以做到的事情。
Book of the Dead 可以在 PS4 Pro, Xbox One X , Windows/DX11 等平台上以 1080p 的分辨率运行达到 30 fps,同时也支持 macOS/Metal, Windows/Vulkan/DX12 平台。
二、Unity 版本和配置
1、需要 Unity 2018.2b9 以上版本。使用 Unity 2018.2.10f1 测试配置流程。
2、新建一个 3D project 避免与内置 Package 的冲突。
部分 packages(比如 PostProcess/CoreRP/HDRP)的版本需要注意。在资源下载页面也强调了要创建一个空的 3D template,而不是直接创建 HDRP template。
3、导入 unitypackage。
4、重新启动 Unity。
通过 Tools > Load Book of the Dead: Environment 打开场景,
Tools > Load Asset Library 打开资源。
三、技术文档
Unity 官方更新了一系列关于《Book of the Dead》制作细节的技术博文,还在持续更新中。
暂时有两篇关于场景制作的文章:
notion image
我认为在研究 <Book Of The Dead Environment.unitypackage> 的场景资源之前,先了解制作流程非常重要。这个 Demo 给出了很完整的开发世界场景制作的解决方案,我们可以从博文中找到一些对自己的项目有帮助的点,再结合资源包中的内容进行更具体的制作流程分析。
举个例子,我们看到场景中的植被动画,却不了解背后的原理。在 Book of the Dead: Environment Art(Quixel, wind, scene building, and content optimization tricks)一文中,详细介绍了植被资源、风场、场景设计、美术资源优化技巧等。
notion image
  • 博文中对植物动画的介绍
Our team decided to create a custom vertex shader based procedural animation for the wind effect on our vegetation assets. We made it tailored to work with our specific project and the trees or bushes it contains. Allowing us to have a complete control over it.
Torbjorn Laedre, our Tech Lead built a shader that would support several different types of vegetation, using 3 different techniques:Hierarchy Pivot,Single Pivot, Procedural Animation。
我们可以从 HDRP Lit shader 中找到对 Vertex animation 中 Wind Mode 的扩展:
notion image
三种不同的风,分别适用于树、草、浮萍,选择不同类型的风会有不同的控制参数。
从 shader 代码中找到 Vertex animation 的算法:
notion image
理解了实现的原理,还可以在普通管线的 standard shader 上进行扩展。
  • 博文中对顶点颜色的介绍
A value of 0 for the green channel of the vertex color would signify that it is the trunk
A value between 0 and 1 would be the branches level A
A value of 1 would be the branches level B
I did this using Autodesk Maya, with some small scripts I was able to set up all of the LODs of an asset in 10-15 minutes.
In addition to this, we also used what we called a ‘Flutter Mask’.
notion image
从博文中了解美术资源上顶点颜色的制作方式,通过制作插件来生成顶点颜色和 LODs Group 的配置。
  • 博文中对 Tree Prefab 的介绍
With all this information prepared, I could use the C# script that would input my tree prefab, and generate a new prefab with the pivot information of every vertex baked in. After adding a WindControl object to my scene, I can import my tree in the scene, and start playing with the material properties.
使用 C# 脚本从场景中的 Tree Prefab 生成一份新的 Prefab,我们可以看到资源库中有两份资源。其中 Baked Prefab 中不再使用 FBX 中的 Mesh,而是使用烘焙的一份 Mesh Asset 数据。但是并没有找到 Prefab 和材质的烘焙脚本和流程,需要得知更多的细节,可以进一步请教官方团队。
notion image
在 Demo 中找到场景中的 WindControl,它使用了 SRP 提供的 Volume System 定制了 AreaVolume,不同的 Volume 激活的情况下,WindControl 的属性会被覆盖,实现了在不同的区域使用不同的风场参数。Wind Control Script 提供了大量的风场的参数,包括风的方向、强度、草和树的不同控制参数等,下面的截图没有显示完整的参数,可以从 Demo 中查看。
notion image
有了风场,调整场景中导入的树的材质参数就可以看到树的动画。如果想要学以致用,还需要花更多的时间和精力去验证技术,在自己的项目中进行实现。
四、小结
博文中像这样的技术点还有很多,比如:
  • 使用 RealityCapture 图像扫描软件进行建模和纹理制作,使用 Unity 的 DeLightingTool 可以去掉纹理上的阴影和 AO。
notion image
  • Quixel 发布的 Megascans Bridge 工具可以方便的将资源重新打包为支持 HDRP 管线或 LWRP 管线的资源。
  • 使用 3ds max 的插件 GrowFX 制作树,Normal Thief 插件修正法线。
  • 定制 Unity C# 脚本重新烘焙树的 prefab 制作流程。
  • 定制植被动画的 vertex shader,使用 Volume System 控制不同区域的风场。
  • 使用 3ds max 的插件 Multiscatter 制作集群
notion image
  • 使用 PhoenixFD 流体解算动态风场的数据导入 Unity。
notion image
  • 根据风的动画制作风的声音效果。
  • 定制 Unity C# 脚本 UberTreeSpawner 模拟树枝散落在地面的效果。
  • 使用 Mixed Lighting 的 Baked Indirect 混合光照模式,使用实时的直接光照和烘焙的间接光照。
  • 对场景中大量的植物使用 Light Probes,使用 Occlusion Probes 烘焙物件对于天空的遮挡信息。
  • 大气散射解决方案 Atmospheric Scattering。
  • 使用 Debug Window 观察 GBuffer 的每一层绘制,检查显示错误。
  • 场景美术资源的优化技巧。(详见 [翻译] 死者之书:Quixel,风,场景搭建,美术资源优化)
根据需要可以进一步挖掘和验证。
整理学习笔记的同时,将两篇博文大致翻译(非全篇幅完整翻译)了一遍,分享出来供大家参考,如有理解不对的地方还请指正。 > 本文由简悦 SimpRead 转码