![c13ddbb9679dedaa9d76b657ec5e32d0.png](https://img-blog.csdnimg.cn/img_convert/c13ddbb9679dedaa9d76b657ec5e32d0.png)
此文为摘要,内容不全,原文包含了详细的代码分析,请到 https://zwcloud.net/#blog/109 查看
环境: Unreal Engine 4.25.2
此文主要分析移动端(ES3.1)从地形高度图到最终渲染的顶点高度的流程,顺带说明一下顶点在X/Y平面的分布,不考虑地面上的贴图混合(权重图),不考虑Landscape Layers,不考虑Hole、Grass等等内容的渲染。
基本概念-地形
- 地形(
ALandscape
)由多个Component(ULandscapeComponent
)拼成 - Component
- 每个Component由单独1个Section或者2x2个Section(横纵各2个)拼成
- 高度由高度图(ULandscapeComponent::HeightmapTexture)决定
- 各层贴图的权重由权重图(ULandscapeComponent::WeightmapTextures)决定
- Section(代码里又称SubSection)是LOD的基本单位
- 每个Section可以有7x7, 15x15, 31x31, 63x63, 127x127, 255x255个Quad;
- 每个section有自己的在Component里的Section坐标,Component有2x2个Section的话,可能的坐标就是(0,0) (0,1) (1,0) (1,1),Component只有一个Section的话,唯一的Section坐标就是(0,0);
- Quad指两个三角形拼起来的正方形,所以Section的顶点数就是 (SectionQuadNumber+1)^2
基本概念-UE渲染
FPrimitiveSceneProxy
是渲染线程版本的UPrimitiveComponent
,他们各自的子类一同实现了特定几何体的渲染逻辑。
ULandscapeComponent
和FLandscapeComponentSceneProxyMobile
:正如上面说的那样,ULandscapeComponent
是UPrimitiveComponent
的子类,用于封装用于GameThread的地形数据;而FLandscapeComponentSceneProxyMobile
继承自FLandscapeComponentSceneProxy
,FLandscapeComponentSceneProxy
是FPrimitiveSceneProxy
的子类,用于保存几何体数据,供渲染时(RenderThread)使用。ULandscapeComponent
转换