{Horizon culling} horizon culling

Source: Internet
Author: User

from:http://cesiumjs.org/2013/04/25/horizon-culling/

In the development of Virtual Earth (e.g., Cesium), we need to be able to quickly identify objects in the scene, such as terrain tiles (terrain tiles), satellites (satellites), buildings (buildings), vehicles (vehicles), etc., When it's not visible. Because these objects are not visible, there is no need to be rendered. Of course we need to take the viewshed (view-frustum) culling. However, horizon culling (horizon culling) is another important culling type.

In, the green point is that the Observer (Viewer) is visible. The red dots are invisible, because they are outside the viewport (the part of the area in the middle of the two white thick lines). The blue dots are in the range of sight, but they remain invisible because they are obscured by the earth. In other words, they are below the horizon. Horizon culling is a very simple idea: you don't need to render objects that are below the horizon relative to the current observer's position. Although it sounds easy to understand, the handling of the details is tricky, especially as the process requires very fast processing. Cesium needs to do this test thousands of times for each rendered frame to determine the visibility of the terrain tiles. However, this kind of testing is very important. In the configuration, terrain tiles covering the entire earth are in sight. However, more than half of the terrain tiles are below the horizon and do not need to be rendered.

A few years ago, Deron Ohlarik wrote two excellent articles about the horizon culling. Since then, we have been working to expand his technology and I will be here to share our results. Although it applies only to static data such as terrain tiles, we find this very useful because it is faster and more accurate than previous technologies. The improvement of the precision of the horizontal line culling originates from the ellipsoid of the earth rather than the approximate spherical surface.

Before that, I should mention that confidence in this technology is entirely due to my colleague--frank Stoner. My contribution was only achieved in Cesium, as well as written here, and he did the hardest job of getting this technology.

Horizon culling a point against a sphere

As Ohlarik describes, for the horizon culling, we can calculate a boundary range for a static object, such as a terrain tile, even if it is just a point. If the point is below the horizon, then we can be sure that the tile is below the horizon. Our new technology limits the reference to an ellipsoid to reject a single point, so we begin to assume that the obscured point has already been computed. For specific practices, please review the following blog.

I promise that we will achieve horizontal culling with reference to a general ellipsoid. I'll keep that promise, but let's start with a simple unit ball to introduce horizon culling. Then I'll show you how to extend this unit ball to an arbitrary ellipsoid. Consider the following picture:

In the picture above, the blue circle is our unit ball. The tangent of the two unit balls drawn from the camera position represents the viewshed. The black vertical line in the figure represents all the points on the horizon. On our unit sphere, the point on the horizon is on a plane and forms a circle. The vector from the camera position to the point on all the horizon forms an infinitely stretched cone.

A partially shaded sphere and the space around it represent areas below the horizon. Any point in the shaded area is invisible from the camera position. Intuitively, if a point is inside an infinite cone of tangent vectors and is behind a plane of all points on the horizon, then the point is below the horizon.

The Plane test

First, let's take a cheap test to determine if a point is on the side of a plane. Consider the following picture:

We know Vector VC and Vector VT: They represent the vectors of the observer to the target Point and the center of the ellipsoid, respectively. We also know that HC is a unit vector because we are dealing with a unit ball now. According to the Pythagorean Theorem (Pythagorean theorem):

< Span class= "Texatom" > < Span class= "Texatom" > < Span class= "Texatom" > next , we notice that the triangles VCH and HCP are similar triangles. They share the upper corner of a point C , and they all have a 90-degree right angle. Therefore: < Span class= "Texatom" > < span class= "Mo" > < Span class= "Texatom" > /span>

Thus, the distance from the observer to the ground plane is:

Vector VT projection on vector VC is less than | | vp| |, the target point is on the front side of the flat. In other words, the target point is on the back side of the ground plane when:

We can simplify this formula by multiplying both sides simultaneously | | vc| | 2, the result becomes:

To determine whether the target point is at the back of the ground plane, take the vector of the observer to the target point to the point product of the vector to the center of the ellipsoid. If the resulting value is less than 1 of the square of the size of the vector of the observer to the center of the ellipsoid, then the target point is on the back side of the plane. There is no need for square root or trigonometric operations.

The Cone Test

{Horizon culling} horizon culling

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.