Godot Autotile & Bitmask Guide: 47-Tile Terrain Sets, Unity Tilemaps & Free Generator
Anyone who has manually placed tiles in a game editor knows the tedium — picking the right corner tile, the right edge tile, the right inner corner for every single terrain transition. Bitmask autotiling solves this entirely. You paint terrain with a single tile type and the engine automatically selects the correct variant based on which neighbouring cells are filled.
This is the definitive guide for Godot 4 Terrain Sets (the modern autotile system), with parallel notes for Unity and RPG Maker. Generate your 47-tile or 16-tile layout template with the free Bitmask Autotile Generator, then import into your engine. If you are building procgen levels, pair this with the Procedural Level Generator — exported tilemaps need a terrain set to render seamlessly.
What Is Bitmask Autotiling?
A bitmask is a binary representation of a tile's neighbourhood. Each of the 8 surrounding cells (top-left, top, top-right, left, right, bottom-left, bottom, bottom-right) is either filled (1) or empty (0). The combination produces a number from 0 to 255, and each value maps to a tile variant that visually fits that neighbourhood.
In practice:
- A tile surrounded on all sides = full interior tile
- A tile with nothing above = top edge tile
- A tile with nothing above-left but filled everywhere else = inner corner tile
- A lone tile = isolated tile variant
Instead of placing each variant manually, the autotile system reads the bitmask and places the correct art automatically as you paint.
Bit Value Reference (47-Tile / 3×3)
Each neighbour contributes a power-of-two weight. Sum filled neighbours to get the bitmask ID:
| Neighbour | Bit value | | --- | --- | | Top-left | 1 | | Top | 2 | | Top-right | 4 | | Left | 8 | | Right | 16 | | Bottom-left | 32 | | Bottom | 64 | | Bottom-right | 128 |
Example: a tile with top, left, and right neighbours filled (but not corners or bottom) = 2 + 8 + 16 = 26 → top edge variant.
The Bitmask Autotile Generator labels every cell in the export template with these values so you never hand-calculate during art production.
The Two Standard Autotile Formats
47-Tile Format (Full Bitmask)
The full bitmask considers all 8 neighbours, producing 256 possible combinations. Many combinations are visually identical (mirrored or rotated), so you need 47 unique tile variants to cover all meaningful cases. This is the format used by Godot 4 "Match Corners and Sides" terrain mode.
The 47 tiles cover every combination that produces a visually distinct result — proper inner corners, diagonal handling, and smooth organic terrain.
16-Tile Format (Cardinal Only)
The simplified format only considers the 4 cardinal neighbours (top, right, bottom, left), ignoring diagonals. This produces 16 combinations — far easier to draw. The tradeoff is no inner corners, which gives terrain a blockier appearance. Used by RPG Maker and some retro engines.
| Use case | Recommended format | | --- | --- | | Grass, water, sand, lava | 47-tile | | Dungeon walls, city blocks, grid aesthetic | 16-tile | | Game Jam deadline | 16-tile first, upgrade later |
Godot 4 Terrain Sets — Complete Setup
Godot 4 replaced Godot 3's autotile bitmask editor with Terrain Sets in the TileSet resource. This is the workflow most readers need.
Step 1: Create TileSet and Add Texture
- Create a
TileSetresource (or open TileSet panel on aTileMapLayernode) - Add your autotile atlas PNG — ideally exported from the Bitmask Autotile Generator with correct cell layout
- Define tile size (e.g. 16×16) and separation if your sheet has gutters
Step 2: Configure Terrain Set
- Open the Terrains tab in the TileSet editor
- Add a Terrain Set — choose mode:
- Match Corners and Sides → 47-tile (3×3 minimal)
- Match Sides → 16-tile (cardinal only)
- Add terrain types: e.g.
Grass,Dirt,Stone— each gets an ID and color for editor painting
Step 3: Paint Terrain Peering Bits
For each tile variant in the atlas:
- Select the tile cell
- In the terrain peering editor, click neighbour directions that must be the same terrain for this variant to appear
- Godot highlights valid placements — mismatched peering causes wrong tiles at runtime
Tip: work through the generator template in order — edges first, outer corners, inner corners, interior last.
Step 4: Paint on TileMapLayer
- Add
TileMapLayerto your scene (Godot 4.3+ split TileMap into layers) - Select terrain paint mode in the bottom panel
- Paint strokes — Godot resolves variants from neighbour terrain automatically
- Use Connect Terrains tool to fix seams after bulk fills
Step 5: Validate With Edge Cases
Test these patterns before shipping art:
- Single isolated tile
- 1×N thin corridor (tests parallel edges)
- Concave L-shape (tests inner corner)
- Terrain surrounded by void on three sides
Godot 4 GDScript: Runtime Tile Placement
When importing procgen data from the Procedural Level Generator:
extends TileMapLayer
@export var terrain_grass := 0
func paint_cell_from_data(x: int, y: int, terrain_id: int) -> void:
set_cells_terrain_connect(
[Vector2i(x, y)],
terrain_id,
false # no instant update — batch then call update_terrain_connections()
)
func load_level(tiles: Array) -> void:
for t in tiles:
if t.type == "grass":
paint_cell_from_data(t.x, t.y, terrain_grass)
update_terrain_connections()
Read the full pipeline: Godot 4 2D Pipeline in the Browser.
Godot 3 Legacy Notes
Godot 3 uses TileSet autotile with explicit 3×3 or 2×2 bitmask painting in the TileSet editor. Projects migrating to Godot 4 should re-export art using a generator template — peering bits do not convert 1:1.
Unity Tilemap Autotile
Unity uses Rule Tiles (2D Tilemap Extras package) rather than Godot-style terrain peering:
- Install 2D Tilemap Extras via Package Manager
- Create a Rule Tile asset
- Define rules: for each neighbour pattern (This / Not This / Any), assign sprite
- Paint with Rule Tile brush — Unity evaluates 3×3 neighbourhood
The 47-tile layout from the generator maps directly to rule entries. Inner corner rules are the most commonly missed — copy them from the labeled template.
For large terrains, enable TilemapCollider2D with simplified geometry — see Polygon Collider Optimization.
RPG Maker MZ / MV
RPG Maker uses fixed A-tile autotile sheets with 16 variants in a prescribed grid order. The Bitmask Autotile Generator exports RPG Maker-compatible layouts — deviating from the expected cell order produces the classic "random wrong tile" bug.
Workflow:
- Select 16-tile RPG Maker export preset
- Draw variants into the template cells
- Import as A1-A5 tileset slot per RPG Maker docs
- Paint in map editor with pen tool — autotile resolves on placement
Art Production Workflow
Step 1: Design the Interior Tile
Draw the fully surrounded interior tile first — tileable on all edges with no visible seams. Every other variant adds edge/corner art on top of this base.
Step 2: Generate Layout Template
Open Bitmask Autotile Generator, select 47-tile or 16-tile, download PNG template with labeled cells.
Step 3: Draw Variants Systematically
Recommended order:
- Center / interior (all neighbours filled)
- Four edges (N, E, S, W)
- Four outer corners
- Four inner corners (47-tile only)
- Isolated and special cases
Inner corners are where diagonals are empty but all cardinals are filled — the visual trick is shading the concave corner darker so terrain reads as continuous.
Step 4: Export and Import
Export final atlas PNG. Keep tile size consistent with your sprite sheet pipeline — mixed scales break camera zoom consistency.
Wang Tiles vs Bitmask — Quick Comparison
| System | Tile count | How it works | | --- | --- | --- | | Bitmask (this guide) | 16 or 47 | Neighbour presence bits select variant | | Wang / corner tiles | 16 corner combinations | Tile corners match adjacent tile corners | | Blob / minimal | Variable | Reduces redundant combinations by symmetry |
Godot 4 Terrain Sets implement bitmask peering. Wang tiles appear in custom shaders and some procedural tools — choose bitmask for editor-native painting.
Common Autotile Mistakes
- Wrong variant order in the tileset: Engine reads variants by atlas position. Always use a generator template as ground truth.
- Missing inner corner tiles: Concave terrain edges look broken without them — the #1 art bug in indie tilemaps.
- Mismatched tile size vs grid: A 16px tile on a 16px grid with 1px accidental gutter causes sub-pixel seams when camera moves.
- Ignoring diagonal peering in 47-tile mode: Top-left empty + all cardinals filled ≠ fully surrounded — different variants.
- Autotile before procgen validation: Generate level layout first with the Procedural Level Generator, then confirm terrain types cover every cell type in the export JSON.
FAQ
Do I need 47 tiles or 16?
Use 47-tile for organic terrain where inner corners matter. Use 16-tile for structured environments or tight deadlines.
Can I use autotile for walls, not just floors?
Yes — wall autotiling is standard in dungeon games. Setup is identical; art depicts vertical surfaces instead of ground transitions.
Godot 4.3+ TileMapLayer vs old TileMap?
Use TileMapLayer nodes — Godot split multi-layer maps into separate nodes for cleaner scene trees and per-layer physics.
How do bitmasks map to tile variants automatically?
The engine compares neighbour terrain IDs against each tile's peering requirements. First matching variant wins — order rules in Unity; peering completeness in Godot.
Can one atlas hold multiple terrain types?
Yes — each terrain type (grass, water) shares the same peering logic but different sprite assignments per terrain set.
Related Guides
Conclusion
Bitmask autotiling is one of the highest-ROI skills in 2D level design. The upfront cost of 16 or 47 variants pays back on every map you build — painting terrain becomes instant, and procgen exports finally look polished.
Generate your template: Bitmask Autotile Generator →