Since Oskar posted about it, I see an increasing amount of praise for his Dual Grid proposal for autotiling terrains. It works by drawing tiles at a half-cell offset to the base grid, creating a dual grid, and using marching squares autotiling to select which tile to draw based on the terrains the corners of the dual grid, which is the centers of base grid.
This is a great scheme. It’s simple, only needs a few tiles and can be extended quite easily. It’s used in many games.
But, it does have some drawbacks. The dual grid is difficult to get your head around. You have to worry about ambiguous tiles. And despite being a substantial improvement over the blob pattern, it still requires drawing quite a number of different tiles.
I’m here to explain an alternative, quarter-tile autotiling. Quarter-tiling has also been called sub-tiles, meta-tiles (when doubling instead of halving). I’ve previous described as micro blob, which is the same thing with precomposition. It’s best known for being the tiling built into the RPG Maker engine.
Quarter-tiling is pretty easy to implement, and requires substantially less effort to create tiles for, as it uses fewer, smaller tiles. That does mean it’s not possible to produce as much tile variation as marching squares. But there’s plenty of techniques for adding that back.
Later, we’ll look at ortho-tiles – an extension of quarter-tiles to irregular, non-square, grids.
Table of Contents
Quarter-tile autotiling, as it names suggests, is based on splitting each cell in the base grid, into 4 cells, each half the height and width of the base cell. We then fill those quarter-cells with half size tiles called quarter-tiles.
Each quarter-tile is chosen based on the terrain of the current cell, and the 3 other cell it’s adjacent or diagonal to. So, the bottom right quarter-tile would look one cell right, one cell down, and one cell down and right.
There’s 6 rules total to chose which quarter tile to use, shown below. A “*” indicates we don’t care what terrain that tile has.
Alternatively, you can use a bitmask to find the matching tile:
The rules for the other three quadrants are the same, just rotated. If your tiles rotate, then only the 5 quarter-tiles above are needed for the entire tileset. Otherwise, it requires 14-20 tiles, depending on how much you share the same quarter-tile in different quadrants.
Applying them, you can get something like this:
Feature Comparison and Drawbacks
So why would you want to use quarter tiles, when marching squares is so handy? Well, it really comes down to there being fewer, smaller tiles, and not having to deal with the confusion of a dual grid.
But less tiles comes at a cost. This sort of tiling has far less variation between tiles, which can give it an artificial look. And some popular styles of tile are simply not possible. Because all the quarter-tiles are half size, you cannot make swooping curves of radius larger than half the size of a tile, something perfectly possible with marching squares.
You also cannot draw tiles where both terrains are roughly equal in spacing. Doing so would mean that the border between them ends up on the dividing line between quarter-tiles, which causes problems. Instead you need one terrain to shrink or grow a bit, so that the border ends up wholly contained inside the quarter tiles.
|Tiles needed (with rotation)||6||5 half size|
|Tiles needed (no rotation)||16||14-20 half size|
|Terrain data stored on…||Vertices (dual grid)||Cells|
|Handles larger curves and borders||Yes||No|
In 3d it works much the same, you’d split a cube into 8 smaller cubes, and the choice of which eighth-tile to use would depend on the cell, 3 adjacent cells, and 4 other cells. I think with full rotations and reflections, 10 tiles are needed (vs 15 for marching cubes).
Splitting up the grid into quarter-cells is a lot of coding, and not all that well supported in engines. In practise, it’s far more common to assemble the quarter-tiles into every possible full tile ahead of time. This gives you the 48 tiles of the blob pattern. Then those tiles can be handled normally by the game engine, including normal autotiling.
Marching squares extends quite logically to multiple terains, instead of using just solid/empty booleans. I’ve got a whole article on it. But it does require quite a lot of tiles.
There’s no obvious extension for quarter tiles. Generally, i’ve seen games take one of two approaches:
1) Overlap multiple seperate autotilings with transparency, one per terrain.
2) Design tiles for each pair of terrains, and pick the two most prominent one for each quarter tile. You end up with some “sharp” transitions, but often the main features are still preserved.
In my next article, I discuss ortho-tiling, an extension of quarter-tiles to any grid of polygons.