当前位置:网站首页>[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 .
边栏推荐
- 基因家族特征分析 - 染色体定位分析
- 天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库
- Zhejiang University Edition "C language programming (4th Edition)" topic set reference ideas set
- The mail function of LNMP environment cannot send mail
- Zzuli: cumulative sum of 1050 factorials
- retrofit
- Sendmail can't send mail and it's too slow to send. Solve it
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- FPGA blocking assignment and non blocking assignment
- NOI OPENJUDGE 1.6(09)
猜你喜欢

Four data flows and cases of grpc

tonybot 人形机器人 定距移动 代码编写玩法

论文分享:Generating Playful Palettes from Images

Tonybot Humanoïde Robot Infrared Remote play 0630

Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion

分布式事务(Seata) 四大模式详解

MySQL multi table query subquery

如何查询淘宝天猫的宝贝类目

Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
![[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?](/img/f6/fe61c84f289f0e74a45946dac687a6.jpg)
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
随机推荐
Zzuli: cumulative sum of 1050 factorials
tonybot 人形机器人 查看端口并对应端口 0701
Zzuli:1042 sum of sequence 3
【北大青鸟昌平校区】互联网行业中,哪些岗位越老越吃香?
Zzuli:1047 logarithmic table
To improve efficiency or increase costs, how should developers understand pair programming?
Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution
Zhejiang University Edition "C language programming (4th Edition)" topic set reference ideas set
7-9 one way in, two ways out (25 points)
Joomla! CMS 3.0~3.4.6 RCE
Déformation de la chaîne bm83 de niuke (conversion de cas, inversion de chaîne, remplacement de chaîne)
Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
Zzuli:1054 monkeys eat peaches
Ultra simple mobile map development
Adobe Premiere Pro 15.4 has been released. It natively supports Apple M1 and adds the function of speech to text
洛谷P3065 [USACO12DEC]First! G 题解
Zzuli:1048 factorial table
PHP GD image upload bypass
Zzuli:1040 sum of sequence 1
[opengl] pre bake using computational shaders