8-neighbour masks
For each terrain cell, look at its eight neighbours and add a weight for each one that is also terrain: N = 1, NE = 2, E = 4, SE = 8, S = 16, SW = 32, W = 64, NW = 128. The sum (0 to 255) is the mask. A cell with no neighbours is mask 0; a cell surrounded on all sides is mask 255. Cells outside the map count as empty.
Why 256 cases become 47
A corner neighbour only changes the look of a tile when both edge neighbours next to it are present. If N or E is empty, the NE bit cannot be seen, so masks that differ only in such a hidden corner draw the same tile. Clearing every corner bit that is not backed by both of its adjacent edges maps all 256 masks onto 47 distinct results. That is the blob set, also described in general terms under tile-based games on Wikipedia.
In our generator, bitmaskToCell applies this reduction, so you may look up any raw mask from 0 to 255 and get one of the 47 cells below.
Sheet layout
The autotile sheet is 192x64 pixels: 12 columns by 4 rows of 16x16 tiles. The index is row * 12 + column. The 47 tiles fill indices 0 to 46 in ascending order of mask; the last cell (column 11, row 3) is empty.
| Index | Mask | Column | Row |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 |
| 2 | 4 | 2 | 0 |
| 3 | 5 | 3 | 0 |
| 4 | 7 | 4 | 0 |
| 5 | 16 | 5 | 0 |
| 6 | 17 | 6 | 0 |
| 7 | 20 | 7 | 0 |
| 8 | 21 | 8 | 0 |
| 9 | 23 | 9 | 0 |
| 10 | 28 | 10 | 0 |
| 11 | 29 | 11 | 0 |
| 12 | 31 | 0 | 1 |
| 13 | 64 | 1 | 1 |
| 14 | 65 | 2 | 1 |
| 15 | 68 | 3 | 1 |
| 16 | 69 | 4 | 1 |
| 17 | 71 | 5 | 1 |
| 18 | 80 | 6 | 1 |
| 19 | 81 | 7 | 1 |
| 20 | 84 | 8 | 1 |
| 21 | 85 | 9 | 1 |
| 22 | 87 | 10 | 1 |
| 23 | 92 | 11 | 1 |
| 24 | 93 | 0 | 2 |
| 25 | 95 | 1 | 2 |
| 26 | 112 | 2 | 2 |
| 27 | 113 | 3 | 2 |
| 28 | 116 | 4 | 2 |
| 29 | 117 | 5 | 2 |
| 30 | 119 | 6 | 2 |
| 31 | 124 | 7 | 2 |
| 32 | 125 | 8 | 2 |
| 33 | 127 | 9 | 2 |
| 34 | 193 | 10 | 2 |
| 35 | 197 | 11 | 2 |
| 36 | 199 | 0 | 3 |
| 37 | 209 | 1 | 3 |
| 38 | 213 | 2 | 3 |
| 39 | 215 | 3 | 3 |
| 40 | 221 | 4 | 3 |
| 41 | 223 | 5 | 3 |
| 42 | 241 | 6 | 3 |
| 43 | 245 | 7 | 3 |
| 44 | 247 | 8 | 3 |
| 45 | 253 | 9 | 3 |
| 46 | 255 | 10 | 3 |
Mapping the sheet in your engine
These are general steps for the three common tools. We have not tested our sheets in these engines, and menu names can differ between versions, so check the official documentation of your version.
Godot 4: terrain sets
- Import the PNG with filtering off (Nearest) so the pixels stay sharp.
- Create a TileSet with tile size 16x16 and add the sheet as an atlas source; create the tiles from the atlas, skipping the empty last cell.
- In the TileSet, add a Terrain Set in Match Corners and Sides mode, add a terrain, and set the terrain on every tile.
- For each tile, mark the terrain bits that are terrain according to its mask in the table above (edge bits for N, E, S, W and corner bits for NE, SE, SW, NW). The tile at mask 0 has no bits set; mask 255 has all of them.
- Paint with the terrain tool of the TileMap and Godot picks the tile from the bits.
Tiled: terrain and Wang sets
- Create a tileset from the image with tile width and height 16 and 12 columns.
- Add a Wang set (or a terrain set in versions with terrains) of the corner-and-edge type with one colour for the terrain.
- For each tile, assign the colour to the edges and corners that its mask says are terrain; leave the others empty.
- Use the terrain brush on a tile layer to paint.
Unity: rule tiles
- Import the PNG with Filter Mode Point (no filter), Sprite Mode Multiple and a 16 pixels per unit setting that matches your grid; slice by cell size 16x16.
- Create a Rule Tile (from the 2D Tilemap Extras package) and add one rule per tile, with the sprite of that cell.
- In each rule's 3x3 neighbour grid, mark the neighbours that are terrain with the green arrow and the empty ones with the red cross, following the mask bits in the table.
- Because corners are ignored when an adjacent edge is empty, set those corner positions to "not specified" in the rules, or list every mask explicitly.
The same table is shipped as bitmask_table.csv inside the packs; see the packs page. For a neutral overview of tile maps, see tilemaps on MDN.