Latest Posts

Changes in HelpTerrains

Editor Comment


Revision Differences of Revision 21

[TOC] ¶

![terrain_tool_2014.jpg](/wlmedia//wlimages/terrain_tool_2014.jpg) ¶
Terrains are one of the base graphics in widelands. This page describes how they are implemented and should help with creating new terrains. ¶
In the end you'll find how to get your terrain in the game. ¶

# Properties of the terrain patterns ¶

The patterns for terrains do have some restrictions: ¶

1. the width and height has to be 64 pixel ¶
2. they must be color indexed ¶
3. they couldn't get transparent areas ¶

# Squared patterns as triangles ¶

The surface of the widelands screen consists of a lot of triangles: ¶

![surface.png](/wlmedia/wlimages/surface.png) ¶

See [geometry]( for more about this issue. The squared terrain patterns are splitted into triangles to fit the triangles of the surface. This test pattern shows how the splitting is made: ¶

![test.png](/wlmedia/wlimages/test.png) ¶

The four colors represent the triangles in which the pattern is splitted while rendering. Only one of those triangles are displayed for each triangle: ¶

![terrain_split_1.jpg](/wlmedia//wlimages/terrain_split_1.jpg) ¶

Note that the red and white triangles of the original pattern are assembled from two patterns to get one big red and one big white triangle. In the above picture the patterns are knowingly spread, to help distuinguish the single patterns. If all patterns are close together, it looks like this: ¶

![terrain_split_3.jpg](/wlmedia/wlimages/terrain_split_3.jpg) ¶

The patterns do have allways the same area where they adjoin: ¶

Testpattern 2 | Result ¶
---------- | ---------- ¶
![test_2.png](/wlmedia//wlimages/test_2.png) | ![terrain_split_4.jpg](/wlmedia//wlimages/terrain_split_4.jpg) ¶

This is importand to create terrain patterns which do not have visible edges if the patterns of the same type adjoin. ¶

# Implementing in the game

# sectiSmon describes how the terrains patterns are implemented in the game. s ¶

Above you have seen, that the resulting triangles will have hard edges. But in game the edges are smooth. This is made with dithering.... ¶

## Dithering ¶

Different types of terrains do not have hard edges if they adjoin. This is made with dithering, a technique which blur the edges from one terrain type to another. Dithering could result in different results: ¶

![dithering_1.jpg](/wlmedia//wlimages/dithering_1.jpg) ¶

The above left example shows, that the testpatterns overlaps with the meadow terrain. The right one shows the opposit: The blue terrain overlaps the testpattern. If we use the blue terrain for all edges, the visible area of the testpattern shrinks drastically.

Who decAnidmates whichd terrain dither over the other?s

### DithTerraings coanfigur atilson ¶

be danimatherd, whingch is configurseed in the fileor `path/to/gamedata/widelands/world/ terrains/init.lua` (for linux-systems) with athe var. Animablte `di ther_layer`. ¶

**This sett
aings are valid for thse wholque gamnce. It is notf possibngle to cherrain images twhich loops ovaluer andu overing. To mapchieve creation org adjustn anit for each map differtent!** ¶

d terrain, you hasve its own dithecr_layer valute. Terrains witmuch himaghers valyoues lnet thed teforr ain dismoother lovok and feerl. tTherrae ins witha lessertting vcalules.d I'fps' theo dither_lmayer vnaluge the sampe,ed nof dithering anis madetion. Examples

Howhich to arget yousr tedrrain into cthapter [[ HgamelpTerrains/

#dit Wheringe |to disave ther inmag ]]:es

| dither_lmayger |s consequence ¶
-------- | ---------
ds | ------------ ¶
to be stpattorerd in | 220 | Tthie s ubfovlderlaps of `pathe /to/gamedata/widoelands/w orld/terrain
s/*`. Animeatedow | 120 | This patterrain is coverused by theo testpattern ¶
blue | 240 | Thisn terrain overlaps meadow and the testpattubfoldern .

DefiConfing urathe kind of terrain ¶

ere are several pcossibilities to explanfin whgurat "kiond of" all terrains is. F.e. done could define a therrain as "arabfile" which me`pans tha/t buildino/gs could bame build. This definiation a/wis made by the `is` -value ian `ds/world/terrains/init.lua` for each terrain. The current fimplementation allow following valutses: ¶

lue |f Mexplanings
--------| ------------- ¶
the" | Allows building of normal buildettings andt roads ¶
theable" | Allows buegildnning. Yofu mines cand roads ¶
alkable" | Allows building of roads only ¶
efer" | to Nothe [Onlinge documentation beof built hTere, but ships rand aquatic animals can ](httpass ¶
://wl.wideland" | Ns.othinrg /docan be built herme (not even immovables), and nothing can walk on it ¶
/able" | Nutothing can be builn_t here, rand nothing cs_luan _waorlk od_units_in it/)

# A side note on programming

This values defines a description for a terrain, but most of the calculation in widelands do not depend on terrains, they depend on the nodes where the terrains adjoin. Every node has 6 terrains around it. Depending on this terrains the node becomes f.e. walkable, arable or mineable. ¶

## Flags, buildings and immovables ¶

All of the graphical things in widelands is placed not on the terrain itself, they are placed on the edges where the terrains adjoin. Buildings, roads, trees,... animals are walking along the edges: ¶


# How to get your terrain into the game ¶