[程式] 了解UE4 Landscape的组成元件

楼主: yekdniw (yekdniw)   2020-07-08 10:24:47
网页版
http://yekdniwue.blogspot.com/2020/07/landscape.html
简介
官方文件连结
https://docs.unrealengine.com/en-US/Engine/Landscape/TechnicalGuide/index.html#recommendedlandscapesizes
一开始接触Landscape,对里面的各个名词以及拥有各式各样的数目感到非常的陌生。
就算看文件还是有很多细节是不懂,后来跟同事一起研究,
想到一些测试方法,我后续测出一些结果与结论,在本篇说明一下。
组成结构与了解
有关Landscape的组成结构,Level里面可以放置Landscape,
一个Landscape有一到多个components。
每一个component又可以决定要细切2*2个section或不细切两种。
一个Section又由多个Quads所组成。
最后一个Quad就是两个三角片,为3D最基础的绘制单位。
数量限制规范
一个Landscape的Component数目是有规范的,范围是1~1024个,并且要是2的幂次方。
一个Component的Section数目如同前面所提,只有1*1与2*2两种。
一个Section的Quad数目最少是7*7,最大到255*255。
不同参数下的Draw call
一个Component 2个draw calls,
然后一个component是landscape可以被culling的最小单位。
制作一个Landscape Components是1*1, section是2*2,quads是7*7。
以及一个Landscape Components是2*2, section是1*1,quads是7*7。
观察在不同视线的draw call变化,例如看的到全部的components或sections,或是只看
的到一个component或section。
[表1.]
[表2.]
除了表格之外,也一并列出场景截图提供参考。
[图1.] Only 1 section in view in 1*1 component with 2*2 section landscape.
[图2.] 4 sections in view in 1*1 component with 2*2 section landscape.
[图3.] Only 1 Component in view in 2*2 component with 1*1 section landscape.
[图4.] 4 Components in view in 2*2 component with 1*1 section landscape.
量测注意事项
数据中draw call使用的是stat scenerendering。
然后观察Mesh draw calls的项目。
在Editor有没有选取到Landscape actor,
显示的draw call也会明显不同(要多画Gizmo),
所以记得在量测的时候要固定量测的环境。
Overall resolution说明与计算
这部份可以参考UE4官方文件在Recommended Landscape Sizes里面列出来的表。
引擎里面是用Overall resolution,文件是写Overall size。
Overall resolution会随着参数不同而改变。
为了简单说明,这边就以一个维度来算就好。
overall resolution = section size *
sections per component *
num of components + 1
计算范例
8 = 7*1*1 + 1
15 = 7*2*1 + 1
15 = 7*1*2 + 1
31 = 15*2*1 + 1
31 = 15*1*2 + 1
所以代表改变section或是component数,都是会影响产生的地表面积的。
虽然section隶属于component下,但是把一个1*1component配1*1section的地形改为
2*2section的地形,面积是增加的。如下图所示
[图5.]
Different sections produce different size landscape.
The Left landscape is 1*1 component with 1*1 section.
The Right landscape is 1*1 component with 2*2 sections.
这部份我本来以为参数改变会维持大小不变,
component内会再细切4个section,结果不是。
想法上要改为section才是最小单位,是用section去铺地表,
只是多少个section会用一个component表示。
结论
Section数决定了Draw call数,Component管理CPU有关的项目(例如Culling)
在相同的平方面积,使用
1*1 component配上2*2 section或是2*2 component配上1*1 section,
最大draw call数是相同的,因为Section数相同。
使用较多的component可以透过culling直接剔除,可是culling计算也需要耗时间。
有关Section负责处理LOD的部分,section内的quad会因为距离远近改变网格,
最终透过减点的方式达到降低分辨率的结果。
图中是将一个4*4 quad的section缩成3*3的减点过程图(俯视)。
[图6.]
LOD changed when 4*4 quad section to 3x3 quad section.
The left image is the original section.
The Middle image presents vertex moving between LOD change.
The right image is the low level result.
参考资料
官方学习影片
https://learn.unrealengine.com/course/3590620
作者: damody (天亮damody)   2020-07-08 21:44:00
赞啦 感谢持续分享
作者: coolrobin (泳圈)   2020-07-08 22:29:00
只能推
作者: metallican (钢铁人)   2020-07-09 00:24:00
赞赞赞 太神啦

Links booklink

Contact Us: admin [ a t ] ucptt.com