Ogre1.7 terrain analysis

Source: Internet
Author: User

As early as a year ago, I wanted to study the new shape of ogre1.7, But I downloaded the source code of ogre1.73 only for various reasons. In addition, you can only study in your spare time,

Previously, the terrain of ogre has been criticized and cannot be used in games. Therefore, ogre enthusiasts have to implement some terrain plug-ins to solve this problem, such as the motion picture. In China, the most successful is the tianlong Babu terrain system. I am proficient in my research on tianlong, And I have improved a lot in terms of terrain efficiency. However, it is not a satisfactory terrain that cannot be implemented by splatting or with a low level of details.

I probably looked at the new terrain, which is far beyond my imagination. I am very excited. The main functions are as follows:

1) vertices Based on the quad-tree

2) Multi-texture hybrid technology based on Shader Model 2.0

3) the real-time editing function allows you to edit height and texture, and automatically generate terrain lightmap and normalmap. I am going to use QT to create a terrain editor in my spare time.

4) the shadow of a scene object supports PSSM. Ogre finally officially added the shadow map implemented by the shader to the project.

5) The paging component is not interested for the moment. For me, it is enough to make a 512*512 terrain.

Certificate ----------------------------------------------------------------------------------------------------------------------------------------------

I mainly studied the construction of vertices and texture mixing of the entire terrain:

1) terrain Construction

How many tile should a terrain with a terrainsize of 513 be divided?

Determined by the maxbatchsize parameter, numtiles = (terrainSize-1)/(maxBatchSize-1)

When maxbatchsize = 65 is added, the terrain is divided into 8x8 terrain tile, a tile 64x64 vertex,

The default value of maxbatchsize is 65 and the maximum value is 129. Why is the maximum value 129 instead of 257? For the versatility of the graphics card, ogre uses 16 as the vertex index.

The number of indexes cannot exceed the 16 power of 2. If the vertex is 257*257, it will exceed... When I think of my project, I encountered this problem. As a result, some graphics cards that do not support 32 vertex indexes cannot see the model.

The minbatchsize parameter determines that the size of the tile should be merged into a tile with the three brothers around it to a certain extent. Generally, this value should not be too many times different from maxbatchsize.

Because the ogre is only merged into a tile with the three brothers around it at the minimum level of dashboard, rather than merged at the intermediate level of dashboard,

Maxbatchsize = 65, minbatchsize, = 33 Let's see:

 

In recent cases, the tile of the two houses is 64*64, and every tile is surrounded by things. It is called Skirt technology, used to cover the gaps produced by tile of different levels of dles.

 

 

 

 

 

 

The camera is a little farther away, and tile becomes 32*32. Because minbatchsize = 32, 32 won't be merged with the three brothers around it. If it is smaller, it will be merged.

 

In the farthest case, all tile is merged into a 32*32 tile,

 

How to set the two values to the best efficiency depends on the terrain size. You can try it on your own.

 

Worldsize, the terrain and texture both have the worldszie parameter, indicating the size of the world coordinate system. This value determines the scaling size,

For example, worldsize 12000, scaling = 12000/512 = 24

The worldsize of the texture is also scaled, which is equivalent to scaling in the material script.

2) Texture Mixing

Ogre uses the Shader Model 2.0 to achieve multi-texture mixing. It supports the combination of up to 16-layer textures for the sm2.0 exclusive display. Some intel's pitfall collection displays support sm2.0, the maximum number of texture layers is only 4... Simply put, to run this terrain, the old graphics card will definitely not work,

Generally, people think that the Ogre terrain supports 8-Layer Texture mixing, but the actual operation found that there are only 6 layers of effects at most, and let me hear it slowly.

Because Layer 1 of ogre uses two textures, the first one is diffuse/specular. The first three channels of RGB save diffuse information, that is, the actual texture, and the second one stores the specular information.

The first three channels of the 2nd normal/height textures are RGB to save the information of the normal texture and realize the normal texture. The last channel a stores the height information and implements the parallax texture, anyway, 2nd textures are used for the next generation technology. No matter you don't need them, the texture units in the materials will be occupied.

Therefore, in theory, a maximum of eight layers are supported, but in fact, there are only six layers. Because there are a total of 16 textures, a maximum of 16 texture units are included in the material.

1. Global color map: a layered terrain map, which is similar to the vertex color.

2. A global normal map is required to save the data of the terrain normal.

3. lightmap: Save the shadow generated by the terrain. We recommend that you keep it.

4. One to N shadow textures. If PSSM is used, the number of textures equals to the number of splits. The default value is 3. the overhead is huge. We recommend that you keep the shadow textures.

5. belnd maps 1 to 2 rgba each channel stores the mixed Alpha data of each layer. If layer 5 is used, the mixed data of Layer 4 is required, so one is exactly the rgba4 channel,

6. layer textures 16 minus the number of sheets above layer textures is the surface texture we actually use. There is not much left. What's more difficult is that one layer requires two textures,

My recommended texture allocation scheme is:

Normalmap + lightmap + PSSM + blendmap + layer 5

1 + 1 + 3 + 1 + 5*2 = 16

So what is the most reasonable reason for a single terrain and five layers? You still have to discard a few layers. Let me tell you.

World of Warcraft terrain is 4 + 1 mixed texture and 4 layers, so three alpha mixed data are required. The last channel of the mixed texture stores the shadow data.

We have five different surfaces, one more than World of Warcraft... The results are completely flushed out.

PSSM cannot be removed, so there can be 6 layers.

Therefore, five to six layers are the real data supported by the Ogre terrain,

 

3) Optimization of texture mixing: composite map

The above textures are scary, but in fact, only the tile with high levels of details needs this clear texture.

If it is far away, it will be pasted with a composite map. composite map is a texture generated by mixing all the effects of the above 16 textures,

How far can we use composite map? It is determined by the parameter mterrainglobals-> setcompositemapdistance (3000 );

By default, the distance is 3000.

 

Certificate ---------------------------------------------------------------------------------------------------------------------------------------------

Because of the analysis, I wrote it here. I learned about the design idea of Sinbad and the meaning of some parameters, and it is easy to configure the terrain. I will not write about how to configure the terrain.

There is a handsome pot written very clearly: http://www.cnblogs.com/lancidie/archive/2011/06/19/2084490.html

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.