Skip to content

Terrain

Mikulas Florek edited this page Oct 9, 2015 · 9 revisions

LOD

Video

Terrain in LumixEngine uses CDLOD for level of detail. The whole terrian is rendered using several instances of single mesh with 16x16 quads (512 triangles). This mesh is scaled and moved to cover the whole terrain. Only about 500 instances of this mesh are needde to cover 1024x1024 terrain.

Vertices of the mesh are further transformed in the vertex shader to create smooth transitions between LODs.

Texturing

Several types of textures are used when rendering terrain:

  • A heightmap
  • Detail diffuse maps
  • Detail normal maps
  • A satellite map
  • A color map
  • A splat map

Heightmap

A heightmap must be a 16bit raw texture or RGBA TGA. Only one channel from TGA is used, the rest of them is ignored. Therefore TGA can only represent one of 256 height values and it is not recommended to use TGA.

Detail diffuse and normal maps

These are textures applied on terrain close to the camera. This distance can be set in the material. Detail textures are tiles on terrain (i.e. on 256x256 terrain, a detail texture is repeated 256 times in one axis and 256 in the other one). Tiling can be set in the material. Detail textures must have a form of texture atlas. It means that all textures must be in 2x2, 3x3 or 4x4 grid (use the closest grid, e.g. for 4 detail textures use 2x2, for 5 detail texture use 3x3). Each detail texture must be tiled in the atlas in 4 copies, because otherwise mipmaps would blur diferent detail textures together. Used grid must be selected in a material, because LumixEngine has no way of knowing the size of grid.

atlas

A color map

Color in detail textures can be multiplied by color from colormap. This texture is stretched to cover the terrain.

Satellite map

This texture replaces detail textures in places too far from camera.

Splat map

This texture controls which detail texture is located at each quad. This is done internally by the engine when user paints a terrain in the editor.

Note: The texture is RGBA TGBA. The red chennel contains the index of detail texture. The green channel contains weight of the detail texture. The rest is not used.

Advanced terrain texture splatting

A special effect is used to improve the visual of terrain. This brings the better visuals however it is not possible to have more one detail texture per quad anymore.

Editing

Create new terrain

  1. Create an entity
  2. Add a terrain componenty to the entity
  3. Set material of the terrain in the property grid - the material must use terrain shader
  4. Set the y_scale of the terrain

Painting

Following items can be paint on a terrain:

  • Height
  • Layers
  • Color
  • Entity

User can select what he wants to paint in the property grid, once a terrain is selected.

Height

Height brush has 3 modes:

  • raise - default
  • lower - hold SHIFT
  • smooth - hold CTRL

Layers

This brush paints the detail textures. The splat map is modified as a result of using this brush.

Color

This brush paints the color in the color map.

Entity

This brush is meant to place many instances of an entity on a terrain at once (e.g. to place trees). Only entity templates can be paint with this brush.

Saving

Painting changes data only in the computer's memory and files are not modified. Click on one of the three buttons "Heightmap", "Splatmap" or "Colormap" to save the corresponding texture.

Clone this wiki locally