The holiday is approaching, and the atmosphere for the holiday is getting stronger and stronger. Code Update the blog. This time I made an "outdoor terrain technology album", there will be several articles Article .
Article 1: Overview of outdoor terrain technology.
1. height chart
1. A height chart represents the height of each vertex on the terrain mesh.
2. Real-time terrain generation, so there will be a height chart.
3. Height graph level: one byte 0-level, two bytes 0-level. To save resources, different levels are used in different scenarios.
4. The normal of terrain mesh vertices can be calculated through peripheral vertex sampling or slopeAlgorithm(That is, the height of the adjacent four vertices and the K value of the algorithm are used to calculate the current vertex normal. The K value needs to be manually adjusted to achieve a better effect .)
5. You have noticed that only the Z value is recorded in the height chart, and the XY value cannot be adjusted to form a terrain like Xiangshan. However, I have not seen any online games or editors that support adjusting the XY value.
2. Terrain tiles
Unit editing block. A large terrain consists of countless tiles. The height chart and materials are finally applied to the terrain tile. Due to hardware restrictions, the number of vertices in a single submitted terrain patch cannot exceed 65535. Our design is a patch = 33*33 vertices. The vertex distance is 1 meter. Of course, the vertex distance can also be 2 meters, but the terrain is not delicate.
3. Terrain Materials
1. Texture Mixing
Generally, multiple textures and one hybrid texture are used, and the rgba channels of the hybrid texture are used for mixing. This is a common practice for online games. Warcraft is a maximum of five (4 terrain textures (A is the highlight channel) + 1 hybrid texture (RGB channel, Channel A is used to mark shadows ).
The terrain also supports highlights. You only need to add the highlights to the texture alpha channel and then mix them. It only requires a high level of art. As in the World of Warcraft, the vine path and stone road are much more realistic after the use of highlights.
We recommend that you do not use normalmap because the terrain occupies most of the display area and the rendering efficiency is significantly reduced when the PS pressure is too high.
2. Art maps must be seamless.
3. Terrain self-shadow
4. Static terrain Object Shadow.
5. It not only corresponds to the "material" concept on the image, but also contains other attributes of the terrain. For example, the sound attribute corresponding to each surface layer, the automatically generated vegetation, and whether the role leaves footprints when the terrain goes up.
According to the effects of the above terrain materials, the fixed pipeline cannot meet the requirements, and you need to write multiple PS/Vs pairs.
We will give a special introduction at, 1st, and 4.
4. Terrain levels
To put it simply, you can use a large number of polygon when you need them, but less polygon when you don't need them.
Roam: Real-Time Optimal Mesh adaptation algorithm.
Vdpm: Progressive mesh based on observation points.
Geomipmap: divides the terrain into N blocks, each of which has several different levels of vertex indexes with different levels of dles. During rendering, you can select the level of dles based on the distance. Avoid cracks.
Currently, we are implementing the geomipmap + game programming essence 2 "using interlocking slice to simplify terrain" algorithm, which is also the algorithm used by fracry. The vertex index is pre-calculated. During running, the level of the slice is adjusted based on the distance from the terrain patch to the intersection. However, the level difference between adjacent patches does not exceed 1.
It is best to use a triangle belt for Terrain patch. Do not use a triangle list. The obvious advantage is that it reduces the memory occupied by the index buffer and improves the speed.
5. Surface decorations
This is a big topic and will be discussed again after you have a deeper understanding of implementation.
6. References:
1. Focus. on.3d. Terrain. programming this is a must-read book for terrain. It basically covers technologies related to outdoor terrain.
2. game programming essence 2 Use interlocking parts to simplify terrain
3. World of Warcraft terrain shader. Use mywarcraftstudio to open wow's Misc. in the mpq package, the ghost file prefixed with "terrain" under the shader \ pixel \ directory is the shader used for terrain rendering, with the suffix "_ s" for rendering with highlights, otherwise, it does not contain highlights.
4. http://www.cognigraph.com/ROAM_homepage/
5. farcry sandbox
6. Battlefield 1942 Editor