lod basic idea

Reference article
http://blog.sina.com.cn/s/blog_5e3213f30100zxet.html LOD Technology Brief
http://blog.sina.com.cn/s/blog_458f87120100q9eg.html LOD Technology Overview
http://my.oschina .net/u/997451/blog/122649 LOD crack problem solution
http://blog.csdn.net/baozi3026/article/details/5732989 ROAM real-time dynamic LOD terrain rendering
http://www.gulu-dev.com/ post/2014-11-16-open-world Technology used in open world map

Basic idea of ​​LOD
Because large terrain rendering needs to process hundreds of millions of triangles in a short time, its real-time rendering requirements are still a difficult point in virtual reality applications such as flight simulation and digital entertainment. Although in recent years, the hardware technology has been rapidly formed, and the performance indicators of the graphics card have been greatly increased, it still cannot meet the real-time rendering requirements of large terrain. The meshes are all drawn with triangles, and even the best graphics card cannot perform real-time processing under the requirement of at least 24 frames per second, so the multi-resolution technology (Multi-resolution) was born.

write picture description here

write picture description here

Multi-resolution mesh simplification technology/level of detail model technology (LOD technology), introducing the idea of ​​"divide and conquer", according to the different complexity of the terrain and the characteristics of the human eye to observe the terrain, the different areas of the terrain are described and drawn with different details . Using LOD technology to draw terrain, on the premise of not reducing the performance effect, the number of triangles can be reduced as much as possible to improve the efficiency of graphics rendering and realize real-time interactive visualization of terrain. Generally speaking, it is to divide a terrain into countless small areas. The closer the area to the viewpoint, or the more complex the terrain of the area (large undulations, such as mountains), the more triangles are drawn, and the higher the terrain description accuracy; for the area farther from the viewpoint, or the flatter the area, the more accurate the terrain description is. The lower the number of triangles, the less accurate the terrain description. To sum up, it is "closer to reality and farther to imaginary".

In 1996, Lindstrom et al. proposed a quadtree-based continuous level of detail model (Continuous level of Detail) construction algorithm, which is one of the representative research results based on regular grids. The "continuous" nature of the algorithm has three meanings:

When the frame is updated, the terrain surface maintains continuity, that is, "time continuity";
terrain blocks with different resolutions maintain continuity without cracks, that is, spatial continuity;
the algorithm's real-time network construction ability is very strong to maintain Higher screen refresh rate.
Height data storage and retrieval
Specialized elevation data can be downloaded, read into memory by reading text, and then created vertex buffers and index buffers.
A more general approach is to store height data through heightmap reading. The height map can be made with ps or professional software. There is a special terrain editor in a special game engine, which directly brushes the terrain.

Node evaluation system
In order to better optimize the vertices, we divide the LOD terrain into several nodes, and the number and size of the divided nodes must be determined by a set of node evaluation system. In order to make the details can be refined according to the requirements, the tree method is used to realize the segmentation of nodes. The commonly used methods are quadtree and binary tree segmentation. In this article, quadtree segmentation is used.
Write the picture description here .
Due to the use of quad-tree segmentation, when the nodes are split to the maximum extent, the number of nodes should match the terrain size, and (TerrainSize+1)*(TerrainSize+1), which is why the terrain size must be 2n+1 .
In order to describe the idea of ​​the algorithm more clearly, the three-dimensional terrain has the following requirements:

The terrain must be a square area nxn;
the number of terrain vertices must be (2 n+1) X (2 n+1)
A quadtree node needs to contain vertex information, the number of vertices is related to the adjacent nodes of the node, in order to facilitate segmentation , the number of vertices is set to 9, and the structure is as shown in the
picture. Write the picture here to describe
the 0 vertex as the center point, the 1, 2, 3, and 4 points as the corner points, 5, 6, 7, and 8 as the edge points, and the vertices and corner points are fixed The change in the number of vertices refers to the change in the number of edge points.
Write a picture description here.
Imagine that the more times the nodes are divided, the finer the terrain, but the greater the amount of calculation, so it is necessary to target nodes in areas with complex terrain. Segmentation is performed, with less segmentation for flatter terrain.
The evaluation system of node segmentation is roughly divided into two parts

The first is the distance from the node to the observation point. The
second is to calculate the complexity of the node area.
Write the picture description here
. The closer the node is to the observation point, the more times of division. According to the first evaluation principle, the first evaluation formula is summarized:
L/d < C1
L is the distance from the vertex to the observation point, d is the length of the node, C1 is a custom constant, the larger the value of C1, the more times the vertex is divided

The more complex the terrain of the node area, the more times of division. According to the second evaluation principle, the second evaluation formula is summarized:
L/r < C2
First obtain the height from the vertex h0 to the vertex h4, if the node is divided, it will also be To obtain the heights h5 to h8 of the child nodes, then compare the height values ​​in turn, take out the maximum value Max, and the minimum value Min, r = Max-Min.

In summary, the evaluation formula 1 and the evaluation formula 2 are combined:
L/(d×r) < C1×C2
deformed to obtain the final formula:
f = L/(d×r×C1×C2) <
1When f < When it is 1, it is judged that the node needs to continue to be split.

After judging whether to split a node, we need to store the split information flag. We set an array variable QuadMat of type bool[][]. The length of the array should be consistent with the number of nodes, that is, QuadMat[TerrainSize+1][TerrainSize +1], the storage method is as shown in the figure below. It can also be seen from the figure below why the number of vertices and the size of its height data HeightDate are also (TerrainSize+1)*(TerrainSize+1).
write picture description here

View frustum and clipping
Another important way to reduce the number of vertices drawn in LOD terrain is to clip vertices in areas outside the camera that we can't see. The clipping mentioned here is not the clipping mentioned in D3D, but the control of node division. For those nodes that we cannot observe, set their segmentation information to false.
Write a picture description
here. I won't go into details about frustum culling.

Rendering of nodes.
Write pictures here to describe
whether there are edge points on each edge of the node, which mainly depends on whether the adjacent nodes are divided. However, adjacent nodes include their own friend nodes (the four node levels divided by the same parent node are as follows: n) and the parent node's friend node (the level is n-1), and these two cases should also be distinguished when making judgments. The nodes in the red area as shown in the figure, the blue vertices represent the edge points added by judging the parent node's friend nodes, and the red vertices represent the edge points added by judging its own friend nodes. The effect of using edge points is to increase the number of node faces to avoid seams between the different levels of connection of adjacent nodes.
According to the distribution characteristics of the vertices in the node, the triangular surface is drawn by a fan shape, as shown in the figure, both directX3D and OpenGL include this drawing method. (In fact, it can also be rendered by ordinary two-dimensional traversal index)
Here, write pictures to describe
the order of node rendering. The recursive method is used to traverse the nodes of the entire quadtree in depth first, and the cotyledon is traversed to render, and the sign to judge whether the node is a cotyledon is Observe that the split information of this node is false.

Problems existing in LOD and solutions
Crack problem
Usually we regard the node as a quad tree, and the size of the node is different according to the different segmentation levels, so that the segmentation goes down layer by layer until the limit size of the segmentation.
Write picture description
here Write a picture description Write a picture description
here Write a picture description
here

The reason for the crack is that the height value of the left node at the intersection B is from the original accurate data, while the Level of the right node is lower than that of the left, and the height value at the intersection B is the average of A and C. In this way, the height difference between two adjacent nodes of the same point will produce a triangular crack.
Write a picture description here
Two techniques can solve the primary problem of cracks:
1) Edge deletion technology
Edge deletion technology deletes an edge at the T-shaped crack of a node with a higher level, so that two adjacent triangles are merged into one. As shown in the figure, to solve the problem of cracks, a total of 3 edges need to be deleted. The grid after deleting the edges is as shown in the figure.
Write the picture description here
2) Edge insertion technology is to add an edge inside the node with a lower level,
This divides a triangle into two

However, to avoid the T-shaped crack phenomenon, it is not enough to rely on edge deletion or edge insertion technology. The terrain grid also needs to meet a condition: the level difference between two adjacent nodes cannot be greater than or equal to 2. At this time, the edge Deletion is powerless, and the use of edge insertion technology will make the algorithm too complicated and difficult to implement.

Solution: When the level difference between two adjacent nodes is greater than 1, force the node with lower level to be split into 4 child nodes

In addition, the practice in cryengine is
to write a picture description here.
In advance, a row and a column are vacated around the grids of different levels for connecting lines to eliminate cracks, as shown in the figure.

Protrusion problem
When the viewpoint moves, the terrain grid is constantly updated. When the node Level changes, a certain point in the terrain will suddenly jump from one height to another, which is called the "protrusion" phenomenon (Poping -up). In the terrain roaming system, the "bump" phenomenon gives an unreal feeling. To eliminate this unnatural behavior, a "deformation" algorithm is introduced. The meaning of deformation is that when a node transitions from one level to another, a certain point transitions from one height to another smoothly and slowly. Although the deformation does not essentially eliminate terrain height changes, this "slow change" is often imperceptible to the naked eye.
Regarding the LOD algorithm for solving protrusions, you can refer to related papers, which are more.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324344216&siteId=291194637