Skip to main content
History: Terrain Scene Manager
View published page
Source of version: 11
(current)
Here is some information about the Terrain Scene Manager. __Note: The scene manager will work up to Ogre 1.7.__ Ogre 1.8 and newer versions won't support this scene manager, because of the new ((Ogre Terrain System)) with many improvements (which released with Ogre 1.7). {maketoc} The shape and coloration of the terrain in your scene is computed from a ''heightmap'', a ''terrain texture'' and a ''detail texture''. The heightmap is a simple greyscale image in which each pixel represents a height value, where 0 is ground level and 255 (resp. 65535 at 16 bit) represents the highest point in your terrain. The samples include a heightmap called ''terrain.png'' which you can use for experimentation. The terrain is textured with an image that is stretched over the terrain. These ''terrain textures'' are typically mottled brown, green, white or grey for earth, grass, snow or rock terrain. Since terrain textures are normally much smaller than the terrain being covered, terrain normally appears blurred when viewed close up. To help with this, a ''detail texture'' is used, which is blended with the terrain texture when viewed from close distances. The detail texture is not stretched as much as the terrain texture, removing the blurriness of terrains viewed close up. The samples include textures called ''terrain_texture.jpg'' and ''terrain_detail.jpg'' which you can use for experimentation. Terrains are divided into a grid of ''terrain tiles''. Terrain tiles may be displayed by the scene manager at a differing ((-LOD|level of detail)), depending on the topology of the tile and the distance from the viewer. The entire terrain is projected within a world coordinate space which specifies the dimensions of the terrain in 3-space. The -LOD calculation for the Terrain Scene Manager is based on [http://www.flipcode.com/articles/article_geomipmaps.pdf|this paper]. Terrain Scene Manager uses ((Mipmapping|GeoMipmapping)). The ((-LOD)) of the terrain chunks are chosen based on camera distance, and they are organised and culled inside an Octree (since the TerrainSceneManager builds on the OctreeSceneManager). !!Configuration Parameters The Terrain Scene Manager is configured via the ''terrain.cfg'' script. !!!Basic Configuration Parameters {img src="img/wiki_up/Terrain_texture_heightmap.jpg" alt="thumb|world texture + heightmap" align="right"} {img src="img/wiki_up/Terrain_detail_comparison.jpg" alt="thumb|without / with detail texture" align="right"} {img src="img/wiki_up/Texture_terrain_detail.jpg" alt="thumb|detail texture" align="right" width="100"} The basic parameters from this script are: * __WorldTexture''': Specifies the name of the terrain texture. * ''__''DetailTexture__: Specifies the name of the detail texture. * __DetailTile__: This specifies the number of times that the detail texture will be repeated in each terrain tile. I.e., if the value is __''__n'', the detail texture will be displayed in an ''n''x''n'' grid within each terrain tile. Setting this can involve some experimentation. If this number is low, the terrain may appear blurry at close distances. If this number is high, the terrain may appear to have repeating patterns when viewed over a distance. * ''__''PageSource__: Specifies the source of the heightmap. By default, __''__Heightmap''. * ''__''Heightmap.image__: The image file from which the heightmap is drawn. Thus must be a square where each dimension is of size 2~np~^~/np~__''__n''+1, for some integer ''n''. The larger the size of the heightmap, the more detail the terrain will have, but the more resources your application will consume (including longer application start time.) 8 bits or 16 bits height maps are supported. Important: The image format must be saved in ''monochrome mode'' - height maps in RGB mode (24bit) will throw an exception. * ''__''PageSize__: The terrain will be __''__PageSize'' x ''PageSize'' vertices large. ''PageSize'' must have the same value as the dimension of the heightmap image, and so must also have a value 2~np~^~/np~''n''+1 for some integer ''n''. * ''__''TileSize__: Terrain tiles have the dimension __''__TileSize'' x ''TileSize'' vertices. '' This number must be smaller than PageSize. TileSize must have a value 2~np~^~/np~''n''+1 for some integer ''n''. Making tile size too small impacts performance significantly while making tiles too large may result in unnecessarily high detail in some parts of the scene. * __MaxPixelError__: This specifies the maximum error tolerated when determining which level of detail to use. Setting this value too high can result in seams in the terrain. Setting the value too low can impact performance. This is the main way to control the distance at which the terrain displays LODs -- it is not a distance in world units but rather how much error can appear on the screen. The more error allowed, the less detailed the LODs can become. * __PageWorldX__, __PageWorldZ__: This sets the extents of the terrain in world coordinates. The larger the terrain, the lower the detail will be in the terrain, as the number of vertices used for the terrain is based on the heightmap, not the world size. This can be used to scale the terrain to any size you want. * __MaxHeight__: The maximum height of the terrain in world coordinates. The 0..255 (resp. 0..65535) range from the heightmap is scaled to 0..MaxHeight in world coordinates. * __MaxMipMapLevel__: Specifies the number of levels of detail that will be used in rendering the terrain. Terrain that is distant or is relatively flat can be rendered with less detail. --- !!!Advanced Configuration Parameters Some heightmap generators save data in a raw format rather than an image format. The following parameters describe the raw format. * __Heightmap.raw.size__: Specifies the dimension of one side of the heightmap. This must be a value 2~np~^~/np~''n''+1 for some integer ''n''. * __Heightmap.raw.bpp__: Specifies the ''bytes'' per pixel in the file. (1 for 8 bits, 2 for 16 bits, maybe also 3 for 24 bits support?) * __Heightmap.flip__: When set to true, flips the heightmap. Required for ''Terragen'' heightmaps. The following parameters control other aspects of the scene manager's operation. ''Can someone fill in better descriptions for these?'' * __VertexNormals__: This makes the TerrainSceneManager calculate and set vertex normals in the hardware buffer. If you use lighting or a GPU program that requires it, you should turn this on. * __VertexColours__: This makes the TerrainSceneManager calculate and set the vertex colors in the hardware buffer. Turn this on if you use a GPU program that needs this information. * __UseTriStrips__: When set to yes, optimizes the order in which terrain triangles are sent to the GPU so that fewer vertices are sent (though on most newer graphics cards this does not make a difference in framerate). Because this causes "cracks" to appear in some video cards and has little or no performance benefit, it is recommended that you turn this off. * __VertexProgramMorph__: Use vertex program to morph ((-LOD))s, if available. * __LODMorphStart__: The proportional distance range at which the -LOD morph starts to take effect. This is as a proportion of the distance between the current LODs effective range, and the effective range of the next lower LOD. !!!More Advanced Parameters Instead of using the terrain and detail textures to shade the terrain, you can provide your own shading routines, specified in your own material. A typical use of this would be to provide vertex programs in your material. * __MorphLODFactorParamName__: This option is used if ''VertexProgramMorph'' is set to ''yes'' and your custom material includes a ''high-level'' vertex program. This option specifies the name of the vertex program parameter to which you wish to bind the morph LOD. This parameter is 0 when there is no adjustment (highest) to 1 when the morph takes it completely to the same position as the next lower LOD. * __MorphLODFactorParamIndex__: This option is used if ''VertexProgramMorph'' is set to ''yes'' and your custom material includes an ''assemler-level'' vertex program. This option represents the index of the vertex program parameter to which you wish to bind the morph -LOD factor. This is 0 when there is no adjustment (highest) to 1 when the morph takes it completely to the same position as the next lower LOD. * __CustomMaterialName__: The name of the material you will define to shade the terrain. !!Using Custom Materials You can use custom materials to render your terrain. If your material contains a vertex program, the following parameters are available: * positions * two sets of texture coordinates (index 0 is world texture, index 1 is detail texture) * Normals, if enabled * Per-vertex delta values, for morphing a higher ((-LOD)) tile into a lower -LOD tile. This is one float per vertex bound as 'blend weight'. If you want to use this you also have to provide the name or index of the parameter you wish to receive the morph factor. !!Dirty notes Here are some plain notes. The style etc. has to be improved later. Also remove of redundancy. ... some of my points got lost by a Firefox crash /-: * The image dimensions of ''Heightmap.image'' has to be equal to ''PageSize'' * The Terrain is constructed as a page of terrain tiles ** Terrain Scene Manager (TSM) has only one tile ** ((Paging Scene Manager)) is an improved version of TSM (right??) that support different tiles * Related to the last point is a strange thing: ** ''TileSize'' has to be defined and must be smaller than ''PageSize'' {CODE(wrap="1", colors="ini")}# How large is a page of tiles (in vertices)? Must be (2~np~^~/np~n)+1 PageSize=513 # How large is each tile? Must be (2~np~^~/np~n)+1 and be smaller than PageSize TileSize=129{CODE} * The terrain is composed of ~np~PageSize^2~/np~ ((-Vertex|vertices)) ** This results in ~np~(TileSize-1)^2 quads~/np~ ** Dependent to the ((-Camera|camera)) distance the remoter ones are conflated to apploximated bigger quads (by ((-LOD)) algorithm) ** For tiles it's the same * World coordinates range from (0, 0, 0) to (''PageWorldX'', ''MaxHeight'', ''PageWorldZ'') * The ''WorldTexture'' is stretched over the entire world ** And for the ((Paging Scene Manager)) for each tile ?? (please fill in if you know) ** Common used file formats are JPG and PNG * ''PageSource'' can have any value that has been registered as a ''TerrainPageSource'' * TSM is a sub-class of ((OctreeSceneManager)) and uses an octree for culling. {DL()} The ((Mipmapping|mipmaps)) in ''terrain.cfg'' are about -LOD, how many levels of -LOD to provide for the terrain tiles. {DL} * ''VertexNormals=yes'' makes Ogre compute normals at each ((-Vertex|vertex)) for use with dynamic lighting of the terrain * ''VertexColours=yes'' creates a vertex element for diffuse colours ** is implemented yet? ** maybe ''VertexColors'' instead? (without U at colours) * ''UseTriStrips=yes'' as it implies, whether to use tri strips for rendering the terrain * The terrain of TSM can't be used for collision detection in combination with Newton physics engine ** alternatively see ((Using PLSM2 with Newton)) !!See also * ((SceneManagersFAQ)) * [http://www.ogre3d.org/docs/api/html/classOgre_1_1TerrainSceneManager.html|Ogre API] for TerrainSceneManager * ((Basic Tutorial 3)) - about Terrain, Sky, Fog, and the Root object * ((Terrain Alpha Splatting)) - a working example using the standard terrain scenemanager, complete with CG shader ** its ((Terrain Alphasplat Terrain Configuratin File|Terrain Configuration File)) - an example configuration * ((Paging Scene Manager)) * ((Terrain Howto)) * ((Ogre Compatible HeightMap)) - code snippet for function ''getHeightAt(x,z)'' --- Alias: (alias(Terrain_Scene_Manager))
Search by Tags
Search Wiki by Freetags
Latest Changes
Projects using OGRE
Building Your Projects With CMake
Compiled API Reference
Overlay Editor
Introduction - JaJDoo Shader Guide - Basics
RT Shader System
RapidXML Dotscene Loader
One Function Ogre
One Function Ogre
...more
Search
Find
Online Users
159 online users
OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username
Password
CapsLock is on.
Remember me (for 1 year)
Log in