Scene Management-culling

Source: Internet
Author: User

Scene Management --- culling

For personal use only, do not reprint, do not use for any commercial purposes. 

When talking about the large scene last time, it is impossible to transmit all objects to the rendering system at each frame when there are many objects. Considering that the area you see is only a small part of the scenario, removing objects out of the field of vision is particularly important, that is, cropping. Essentially, cropping is part of collision detection. Through collision detection, it determines whether an object is in the cone. However, it is very different from the collision detection in the game, so it cannot be confused. Of course, the last engine flow chart also evolved a little bit:


How to Implement the cropping process? Assume that there are objects in the area of X meters, the most elementaryAlgorithmIt is to traverse objects and calculate whether they are at the same time as the video cone. Unfortunately, this process is also very slow. It may only make usProgramIncrease from n spf (seconds per frame) to 1 or 2 FPS. As a result, smart people find that the entire area is subdivided into n sub-areas. As long as the sub-areas are within the cone, the objects in the sub-areas will inevitably be visible, this method is usually called an even grid ). For a uniform grid, it is difficult to determine the size of the Grid. If the scenario is subdivided into 1 × 1 areas, there is almost no improvement compared to the original method. If the sub-mesh is too large, when the entire video cone is in a certain grid, or when it is intersecting with the grid, it is still necessary to calculate whether each object in the sub-mesh is in the video cone, unfortunately, even if objects are in this subarea, the performance is still poor. Fortunately, this rarely happens, so in general, the efficiency of the even grid is greatly improved.

Based on the idea of subdivision grid, sub-grids can be further subdivided. Therefore, space partitioning algorithms like the quad-tree and the eight-tree are introduced for cropping. For the sake of simplicity, the following uses the quad-tree as an example. Obviously, the quad-tree solves the problem of dividing the granularity of a uniform grid. Its multi-level hierarchy not only ensures that a large number of objects are quickly removed, but also ensures the cropping accuracy.

the quad-tree is ideal for outdoor scenarios (for example, most of the areas outside the main city of wow, or an outdoor scenario (such as a city) where the objects are blocked by each other, it cannot help. The quad-tree divides all directions of the space, while indoor scenarios/underground cities generally only extend in several directions (Area A --- Area B --- Area C). Although the outdoor cities are evenly distributed, however, the occlusion is severe. Objects in the cone are not necessarily visible.
portal may be the best way to divide indoor scenarios: divide the space into a large number of connected areas, and calculate other areas that can be seen in a specific area, for example, if only Corridor B is visible in the Room A, it is clear that objects in other regions do not need to be rendered. This cropping process is more like database queries rather than collision detection, with high efficiency. However, the process of pre-computing visibility is very troublesome and requires a high level design. We hope to see as few additional areas as possible (such as one) in a certain area ), at the same time, it is necessary to ensure the rationality and Artistry of the level.
for cities, the Visibility Calculation of objects in the cone is also very important. For games like NFS, there may be a lot of objects in the cone, only those on the street are truly visible. Therefore, the occlusion cull concept is introduced to calculate whether an object is blocked by other objects. Although the concept is very simple, it is much more complicated to implement than the previous cropping methods, which is beyond the scope of this article.
now the most interesting part is that we can combine the above algorithms! For example, at the highest level, the world is divided into a large uniform grid (such as 500 × 500). In addition to the ability to quickly crop most areas, the dynamic loading scenario is also available. In the area of X, only N x n subgrids in the potential visible range are loaded. As the viewpoint moves, does not stop loading/detaching sub-areas. Next, in order to ensure efficient cropping, subgrids are subdivided into four forks. Furthermore, in indoor scenarios, a quad-Tree node can contain a portal node. Finally, if the protal node occupies a large space area, you can continue to use the quad-tree or occlusion cull to segment protal nodes! In terms of implementation details, as long as all methods inherit from culler, we can derive a number of adaptive cropping algorithms that can be nested with each other.

Finally, let's talk about whether an object must be rendered if it is inside the cone and is not blocked? Consider a pig knife in the cone that is far away from the observer :). Maybe after the raster is projected, it takes only a few pixels on the screen, and the observer cannot tell whether it is a pig knife or a nail clipper. In this case, you can ignore this object. The simplest method is to use the relationship between the area of the box surrounded by an object and the distance between the observer as a reference.
next time, it will be about collision detection, to be continue ..................

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.