Hidden Surface removel algorithms -- Occlusion Culling an efficient occlusion culling algorithm based on Large-Scale Terrain scenarios

Source: Internet
Author: User

For general scenarios, the interval scanning line Z buffer algorithm I introduced previously can eliminate most of the inaccessibility

However, in the Large-Scale Terrain scenario based on heightmap, it will be found that the function is not too big, and the range scanning line z

The buffer algorithm needs to manually specify the occluder in the scene, and the occluder must be a rule object, while

There are very few occluder types in a scenario, that is, objects such as buildings in the scenario. Actual terrain scenarios

The most suitable for occluder is the rolling hills and mountains. It blocks most of the things in the scenario.

But the Z buffer algorithm of the range scanning line is powerless for the OC in this case, and other calculations are required.

Currently, the following types of OC technologies are available for Terrain scenarios:
Voxel column culling, hierarchical visibility, and incremental horizon. These

Algorithms all require preprocessing. The most popular one is the incremental horizon (incremental horizon) technology.

This technology requires that you calculate a potential contour line for each terrain block before rendering.

The potential contour lines are merged into the horizon for OC processing. This algorithm is not suitable for preprocessing.

After using Game Development, I developed a realtime computing incremental horizon algorithm myself,

However, it is found that the overhead is too large to be used in realtime rendering (and Pascal Junod
Implementation of a O (Na (n) log (n) Point
Visibility Algorithm on digital terrain models uses the same algorithm.

I also discovered it later. If you are interested, you can refer to my previous articles in gameres ).
The papers related to the Internet are listed below. If you are interested, please take a look.
Loyd B, Egbert P. Horizon occlusion culling for real-time rendering

Hierarchical terrains. In: Gross M, Joy Ki, moorhead RJ, eds. Proc.

The IEEE visualization. Boston: IEEE Computer Society Press, 2002. 403-

410.
Stewart J. Hierarchical visibility in terrains. In: Dorsey J, slusallek

P, eds. eurographics Workshop on rendering. Vienna: Springer-Verlag,

1997. 217-228.
Zaugg B, Egbert P. Voxel column culling: occlusion culling for large

Terrain models. In: Ebert D, Favre JM, peikert R, eds. Proc. Of the joint

Eurographics-IEEE tcvg Symp. On Visualization. Vienna: Springer-Verlag,

2001. 85-93.
Stewart J. Fast horizon computation at all points of a terrain

Visibility and shading application. IEEE Trans. On Visualization and

Computer Graphics, 1998,4 (1): 82-93.
Daniel Archambault. All the distant horizon edges of a terrain. B. SC.

(Hons.) In computing science, Queen's University (Kingston), 2001
Pascal Junod. Implementation of a o (Na (n) log (n) Point
Visibility Algorithm on digital terrain models. October 1999

Later, I took a closer look at farcry's editor sandbox. After more than two months of experimentation, I finally developed

An OC algorithm that can run in real time for Terrain environments. This algorithm has very low overhead.

In the test on the Ogre platform, this algorithm can be precisely eliminated, and FPS is significantly improved. Because of this calculation

The core of the method is the intersection of line segments, So I temporarily call it the intersection OC algorithm of line segments.
Before introducing this algorithm, clarify the coordinate system. The behavior X of A heightmap is column Y and the height direction is

Z.
Consider the single point of OC first, as shown in:
P
|
| C
A-------------------B
|
|
O
Assume that plane AB is an occluder and O is the camera position. If you want to determine whether point P is blocked by AB, only

You need to determine whether the line op and occluder AB are intersecting. If there is a intersection point C, the point P is masked.

The problem is simplified to line segments and intersection. Next we will continue to consider how to simplify this question in the terrain environment.

In the terrain environment, each row and column of heightmap can be considered as an occluder. Here we assume that AB is

A line segment composed of two vertices in a row or column. To determine whether point P is blocked by AB, you can compare the intersection points.

Determine the Z value of the C online segment op and line AB:
Zc_op> zc_ AB point P is not blocked by line AB.
Zc_op <= zc_ AB point P is blocked by line segments AB
Now, whether checkpoint P is blocked is simplified to a simple 2D line segment intersection problem in the terrain environment.

The reason why the algorithm is efficient.
Next we will continue to look at how to promote the algorithm from a point to the entire terrain. In the heightmap-based terrain System

Generally, the terrain is divided into smaller tile blocks. The tile size can be 17*17 or

33*33, where 17*17 tile is used.
First, let's look at how to remove the blocked tile in the scenario. For tile, if all vertices are located before it

The row and column must be hidden. For more precise definitions

, If the line segment formed by the location of camera is all in the row or column between tile and camera

If any line segment is overlapped, it can be confirmed that tile is completely blocked.
According to the above definition, if a tile is detected to be completely blocked, check 17*17 = 289 times, although the 2D line

Segment calculation overhead is very small, but a tile requires 289 operations, which is still unacceptable.

A simpler algorithm. Consider the interval scanning line Z buffer algorithm. occludee uses AABB, which is an object.

Can I use AABB of tile for computation? Because of the nature of the terrain environment, you do not need to consider the AABB most

The following four vertices, but it is absolutely impossible to directly use the top four vertices of AABB for computation.

Description:

Although the four vertices are completely blocked, occludee is not completely blocked.

To divide the up surface of AABB into a 16*16 lattice, the number of operations does not change.
Here we can use a clever method, as shown in:

Project AABB to the camera space, directly obtain the line AB, divide the line AB into 16 equal points, and obtain 17 new vertices.

Note that the Z values of these vertices are all equal. Now you only need to check whether ocludee is visible 17 times.
Next, let's take a look at the algorithm complexity. For a completely blocked tile, we only need to compute 17 vertices. For a completely unmasked tile, we only need to compute one vertex, partial occlusion tile is about 2-16 vertices. Since tile requires frustum culling before the OC operation, remove the tile that has been culling by frustum, and then remove the tile that has not been blocked, in fact, the amount of computing is very small.
Note that the calculation of each vertex here is not a simple 17-time line segment tutorial operation. The number of transactions is different based on the distance between the tile and the camera position. For example:

In the line segment OA, you need to check three rows and columns. There are six intersections. You need to perform the intersection operation on six line segments.
When performing OC operations on the model in the scenario, you also need to convert the AABB of the model to the camera space according to the above method to obtain an occludee line segment, then, the number of vertices is determined based on the distance between the adjacent vertices.
This algorithm can be used in combination with the Z buffer algorithm of the range scanning line to obtain the maximum number of excluded objects in an outdoor scenario. The tile and model that are blocked by the surface are removed by using the line segment intersection OC algorithm, then, use the Z-buffer algorithm of the range scanning line to remove the tile and model blocked by buildings. The perfect OC solution for outdoor scenarios is very nice !!!!

Original article. For more information, see the source !!!!!!!

Line Segment intersection OC algorithm demo program download (using the Ogre platform, read the README file before running ):
/Files/dreams/ogrene1_part01.rar
/Files/dreams/ogrene1_part02.rar
/Files/dreams/ogrene1_part03.rar

/Files/dreams/ogrene1_part04.rar
/Files/dreams/ogrene1_part05.rar

/Files/dreams/ogrene1_part06.rar
Due to the size limit of the cnblog file to be uploaded, the file is split into 1 MB for uploading. Sorry !!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.