What are the implementation techniques behind the big map in the open world game Gulu? "Link: Http://gulu-dev.com/post/2014-11-16-open-world
# # 4. Handling of oversized terrain (terrain visualization)
Finally, the treatment of the super-large terrain. It can be said from the 90 's, the ultra-large terrain visualization, has been a hot topic in the 3D game field. Today we will take this opportunity, the relevant algorithm and implementation of the rationale.
Considering the length of the space is too long, my fingers are overwhelmed, and a lot of students interested in this topic may not be a programmer, some implementation details may I just simply mention, paste code or whatever, try to ensure that the whole article information concentration moderate bar.
----------------------------
In general, the history of terrain rendering technology has been a vivid development, utilization and improvement of modern GPUs for over more than 10 years. The whole process can be divided into three stages: at first, the GPU processing vertex ability is very weak, this period of a variety of sophisticated algorithms (such as some VDPM and later roam), * * Try to use the CPU to reduce the total number of vertices * *, avoid a inattention to the graphics system; Later, the ability of the graphics system went up, People are beginning to think more about the integration of the terrain system into the common scene management * *, such as Quadtree eight-tree what is in this phase is widely used; and then, the GPU is very powerful, the CPU to assume more complex game logic, more and more become the bottleneck of the entire system, this stage, People think more is, how to use the GPU to the CPU to offload * *, until now, driven by the GPGPU of heterogeneous computing, are also this way.
----------------------------
Because the content is miscellaneous, the super-large terrain of this paragraph, according to the above description, we divided into three small sections separately speaking it. Let me first brew a cup of tea, for Sir.
# # # 4.1 Classical algorithms (from geomipmapping,progressive Mesh to ROAM)
geomipmappingis a surface treatment technique evolved from the MipMapping technique of textures, based on the actual size shown on the screen in any small piece of terrain (mainly related to distance and fluctuation of the camera) to select the corresponding density grid. And then the different resolution of the mesh in a certain way together (without this step will have a crack), essentially a relatively rough area LOD algorithm. By the way, because of the many processing at the vertex level at that time, this type of T-crack is so common that there is a special name called "T-junction", and there are a lot of options for dealing with it.
This is I just to the old hard disk planing out of the geomipmapping code, compiled a bit incredibly still can run up. A bit of dirt, don't mind: P can see different MipMap levels are rendered in different colors, you can also see the treatment of the T-shaped cracks at the joints. Alas, this code reminds me of my green memories ah, then by the way two more T-type cracks and elimination process it.
----------------------------
----------------------------
Progressive Meshis a very popular technology Simplygon predecessor, the principle is basically also consistent, is in some way gradually degenerate a given Mesh.
There are two types of progressive meshes: viewpoint-Independent (view-independent Progressive MESH,VIPM) and viewpoint-related (view-dependent Progressive mesh,vdpm). The difference between the two is that the former pre-offline generation of all the gradient process, the runtime directly with the line (also later Simplygon adoption of the scheme), while the latter with the camera's position and angle of change, the corresponding simplified model is generated. Two-phase comparison, the benefits of VIPM is the operation of low-cost operations, simplifying the model's effect is good, the disadvantage is that the cost of memory (because the data are saved, of course, later the increment of the way to save some), and vdpm at that time is a good choice, because with VIPM compared to the cost of extra memory, And for applications where the point of view (that is, the camera) is not very dramatic, there is no need to process and update the corresponding simplified model per frame (ordinary MMO classes are usually one-time enough), and because of some simple occlusion culling and back culling, you can cut far more vertices than the VIPM (usually 1/3 to half more, It was a priority at the time).
Overall, at least at the time, both applications are relatively broad, and later, more and more video memory, the bus is getting more and more tense, vdpm this typical brush vertex algorithm (compare fee bus bandwidth) gradually lost the market, this is something.
You can see some of the PM's applications in terrain rendering [here] (3d Page (www.cbloom.com/3d)). We are not on the map, we can go to Simplygon's website to see.
----------------------------
ROAMCan be counted as the above mentioned VDPM went further. This algorithm in fact borrowed from the mainstream engine standard BSP idea, want to use binary tree, the most concise space to describe the data structure, the (CPU-side) vertex reduction to play to the extreme. The entire surface is organized into a huge two-fork tree, with two queues, one split queue, and one merge queue, which is used to handle camera movements, adding area details to the field of view and area details that diminish the field of view. Carefully designed ROAM effect is very gorgeous (especially in the online box mode), you will see the impact of various factors (including the local slope, the angle of the camera, occlusion, etc.), a variety of triangles like magic constantly changing, generate and erase ultra-many details, the effect is very magical. I was very impressed by the two-hour continuous playing Quake3 I, debugging this thing, often less than 10 minutes of the eye spent.
On the internet to find two more typical ROAM everyone feel it.
----------------------------
----------------------------
# # # 4.2 Levels of art (Quadtree and Chunked LOD)
In fact, the tree structure used for space management has four fork tree and eight-fork tree (and the above two-fork tree), but the surface is usually the majority of the previous. Because, from a small scale, the dramatic terrain is 3D, suitable for the eight-fork tree in the xyz three direction expansion, but when the scale is large to a certain size, the topography is usually degraded to a relatively flat 2D space, like the flattened earth surface, in the vertical z direction of the relatively small change, The XY plane is potentially infinitely extended.
QuadtreeThe quadtree is straightforward, and I won't tell you the specifics. It is worth mentioning that quadtree is often also used for quick culling and finding of scene management, in theory, Quadtree is the most rapid use of a plane to reject space, positioning an object, memory overhead is relatively low data structure. When used for terrain rendering, the efficiency of vertex culling is also high, and I am second only to highly optimized ROAM. The low memory overhead is mainly due to the fact that quadtree can be perfectly unfolded into a bit array, which means that the utilization of the entire tree is 100%--all the space is used to store the data rather than maintain the structure.
But the four fork tree is not everything good, T-type crack is more difficult to deal with than geomipmapping, because there are cross-level multi-segment T-joints, such as:
In addition to some of the details, here does not explain that the terrain of the four-tree rendering or there are many details need to be handled carefully, here for the moment put down the table.
----------------------------
Chunked LODis a hybrid of the improved LOD, in fact, a mix of the above said a lot of details, essentially a partition block to reduce the details of the technology. The so-called Chunk is a way of batch processing, just a unit of granularity, similar to the current concept of partition recycling in Java GC.
The following is a typical Chunked LOD effect:
Vertex multiple filter Optimized effect:
The effect was still amazing at the time. Typically less than 50k of rendering data can have a very realistic effect.
----------------------------
# # 4.3 GPU-based technology (from Paging,clipmap to GPU Terrain)
The above is basically a traditional solution, this section we will gradually transition and introduce the GPU as the main operator of the algorithm.
----------------------------
Calledpage Out(Paging) is actually a way to emulate the running mechanism of virtual memory. Because the vertex data of the surface is static data, it is suitable for resident memory. When the world scale is large, the video memory can not be put into all the data at once, then the system like virtual memory, the temporary unused data exchange out. As the game progresses, the Paging in/out is also ongoing, supplemented by a certain asynchronous mechanism, and the delay in loading into the video memory can be well masked. The intuitive feeling of the player is: wow, a huge amount of detail.
----------------------------
andClipmapis more than Paging, in the form of pyramid to arrange the data, direct overall update and rendering. From here, we can also see the gradual changes in the way people think in the GPU era. From the "pinching irritate D" at the previous vertex level (Vertex levels), it doesn't matter if you have more than one plug at a later time, as long as the batch is less than OK. Can see the basic idea of clipmap.
----------------------------
The so-calledGPU Terrain RenderingThe advantage is that the CPU and memory are completely liberated by moving the height map from memory through 2D Vertex Texture to VS to create a triangular polygon. It's just that there are some restrictions on access, not as convenient as dealing with memory directly. Specific details can be seen here: [GPU Gems 2:terrain Rendering Using gpu-based Geometry clipmaps] (GPU Gems-chapter 2. Terrain Rendering Using gpu-based Geometry clipmaps)
There is also a huge advantage to doing on the GPU that you can generate more details on the fly with Gaussian Noise. Just take a small piece of pre-generated Gaussian noise to overlay it when you need it, adding a variety of details without much extra overhead. As shown in the following:
----------------------------
With the understanding of the GPU in depth, the terrain of the processing and a lot of small tricks can be done, especially in the PS inside, such as normal generation, dynamic UV expansion, light on demand overlay/attenuation what. However, as far as I know, there is nothing very unique in the architecture of new ideas, so no more in-depth.
Ultra-large terrain processing (terrain visualization) "Turn to Know"