当前位置:网站首页>[ue4] HISM large scale vegetation rendering solution
[ue4] HISM large scale vegetation rendering solution
2022-07-03 14:43:00 【ZJU_ fish1996】
HISM, namely HierarchicalInstancedStaticMesh, yes ue4 It provides a solution for large-scale repeated object rendering such as vegetation . This article is only for HISM Guide to design , Specific details need to refer to the implementation of the source code .
ISM
In the discussion HISM Before , So let's see ISM, namely InstancedStaticMesh. In short, it is ue4 Instantiated rendering provided , adopt Instance, draw n Two identical objects , The original need n Time drawcall, Now it only needs one time ( More details can be thrust here ).
Imagine , If we want to render a bunch of flowers , A box of eggs , This seems to be a very good solution . however , If we want to render the endless vegetation , There will be the following problems :
(1) Only some plants will appear in the field of vision , But when drawing, you need to submit the whole vegetation ;
(2) We can't control far 、 in 、 Accuracy of close range (LOD);
A relatively simple idea is , The vegetation can be divided into several parts to manage , Carry out selective drawcall.
HISM
To solve the above problems ,ue4 Provides HISM Solutions for ,H The corresponding meaning is hierarchy . Its idea is essentially to split the vegetation , It's just more complicated , For each StaticMesh, Construct a ClusterTree Tree structure to manage vegetation . It is constructed automatically only once when an object is created , Therefore, it is only applicable to static vegetation like objects .
First , Regardless of the specific structure of the tree , Let's think about a problem : How to integrate instance The object is divided into several parts , And submit in sections ?
instance The object corresponds to a instance buffer, It stores the... Of each instance in order structure data , such as transform Information . If we want to make the original instance The object is divided into k Share , We can really allocate k individual instance, But there are simpler ways .
Drawing instance when , graphics API Relevant interfaces are provided , You can specify instancebuffer Start position and offset value of , And set the number of instances , To control the final drawn instance . in other words , We just need k Heads and tails instance id, You can split the original instance object into k part .
In this way , We can control the removal of vegetation and LOD Handoff .
ClusterTree
ClusterTree It's a multi branched tree , Each node of it contains the beginning and end Instance Id, Corresponding to a section . Cut the interval of the parent node and generate multiple child nodes .
In order to control the generation shape of the tree , We can set the default culling granularity ( The smaller the size, the finer the culling )、 Preset at least how many instances and other data are generated ,ue4 According to these settings, the appropriate BranchingFactor, As the basis for whether to continue to divide the current node .
ClusterTree How to build : Sort all instances on the maximum axis , Then it is divided into two , Then continue to divide each sub interval . The figure below describes the process :
Through recursive partition , We get several subintervals , But we didn't get a tree . To build the tree , We need to repeat the recursive process in the figure above , First build leaf nodes , Then treat leaf nodes as multiple large instances , Build its parent node , Complete the whole process from the bottom up .
To eliminate
stay ue4 The geometry of is drawn in the pipeline , There are static and dynamic processes , The final drawing instructions are MeshCommand encapsulation .
For static rendering , It will be built when objects are created and added to the scene StaticMeshBatch, And cache it , Only regenerate if necessary MeshBatch.
For dynamically rendering objects , You need to generate each frame MeshBatch, Then based on the MeshBatch Generate the final MeshCommand, Because every frame MeshBatch Information may change .
Due to the conversion of the lens , The vegetation we need to draw may change , So in use HISM after , We must follow the process of dynamic drawing .
The process of elimination is InitViews In the middle of , This process actually completes two operations , One is visibility calculation , In addition, collect the corresponding MeshBatch And generate MeshCommand.HISM The elimination of is not in the conventional visibility calculation process , It's collecting trends MeshBatch In the process .
It's generating MeshBatch when , from ClusterTree The root node starts to calculate whether the bounding box corresponding to the node is in the viewing cone , If yes, continue to query the child nodes . The corresponding head and tail of the visible node instance id Record to array ( Merge continuous intervals if necessary ), Get multiple heads and tails instance id.
Observe carefully MeshBatch Structure , You will find that it contains a Element Array of , But generally, static objects only use one Element. And for HISM for , A section corresponds to a Element, This structure seems to be designed for compatibility HISM This kind of data is submitted .
When we put HISM The data of is split into k After paragraph submission , We will be in MeshBatch I'll get k individual Element, They will be k Time drawcall. There is a trade-off problem here : The finer the split , It means that the finer the elimination , but drawcall It is possible to improve ; On the contrary, the coarser the elimination ,drawcall Will decrease .
LOD
LOD That is to choose different accuracy models according to the distance between the camera and the object ( For vegetation , The farthest switch is the bulletin board ). In the process of eliminating, calculate the intersection of the apparent cone and the bounding box corresponding to the node , We also calculate the distance from the center of the bounding box to the camera , And determine the drawing level of this interval , Then put the head and tail instance id Record to the corresponding LOD In the array of levels .
边栏推荐
- Adobe Premiere Pro 15.4 has been released. It natively supports Apple M1 and adds the function of speech to text
- Puzzle (016.3) is inextricably linked
- Optical cat super account password and broadband account password acquisition
- NOI OPENJUDGE 1.4(15)
- Table of mathematical constants by q779
- ShowMeBug入驻腾讯会议,开启专业级技术面试时代
- Understand the application scenario and implementation mechanism of differential segment
- [qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
- 从书本《皮囊》摘录的几个句子
- Common shortcut keys in PCB
猜你喜欢
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
Pyqt interface production (login + jump page)
Qt development - scrolling digital selector commonly used in embedded system
Rasterization: a practical implementation (2)
分布式事务(Seata) 四大模式详解
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
dllexport和dllimport
retrofit
tonybot 人形机器人 定距移动 代码编写玩法
随机推荐
Add ZABBIX calculation type itemcalculated items
Adobe Premiere Pro 15.4 has been released. It natively supports Apple M1 and adds the function of speech to text
Tonybot Humanoïde Robot Infrared Remote play 0630
Tonybot humanoid robot starts for the first time 0630
ZABBIX saves the page blank after adding calculated items
Etcd cluster permission management and account password usage
dllexport和dllimport
Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things
tonybot 人形机器人 首次开机 0630
Zzuli:1056 lucky numbers
SSH access control, blocking the IP when logging in repeatedly to prevent brute force cracking
Zzuli:1049 square sum and cubic sum
Plane vector addition
Showmebug entered Tencent conference, opening the era of professional technical interview
Solve the problem that PR cannot be installed on win10 system. Pr2021 version -premiere Pro 2021 official Chinese version installation tutorial
7-1 positive integer a+b (15 points)
Zzuli:1052 sum of sequence 4
[opengl] face pinching system
C language fcntl function
Luogu p4047 [jsoi2010] tribal division solution