Getting More out of Seamless Tiles
Page 5 of 7
<1 | 2 | 3 | 4 | 5 | 6 | 7>
Single-page view
Getting More out of Seamless Tiles

DIFFERENT BLEND SCHEMES

The blending approach above is very powerful: to get a different way of combining tiles, we only need to change the blend mask. The basic rule is:

  • your source tiles should be seamless,
  • your vertical blend mask should be horizontally seamless,
  • your horizontal blend mask should be vertically seamless.

Here are a few ideas for different blend images:

Blendmasks
You can use variations in blend masks to get more tiles. As long as the blend tiles are seamless and interchangeable, the resulting tiles will also be seamless.
You can use variations in blend masks to get more tiles. As long as the blend tiles are seamless and interchangeable, the resulting tiles will also be seamless.
As you can see, the area where four regions meet looks a bit artificial.
As you can see, the area where four regions meet looks a bit artificial.
Even with smoother blending, the result is not totally satisfactory.
Even with smoother blending, the result is not totally satisfactory.

To solve this problem, you might need to modify our algorithm to use different masks for tiles with corners. Classify tiles by the following scheme:

From top-left: Centre tiles, Straight-edge tiles, Corner tiles, Cross tiles, Diagonal-line tiles, Half-edge tiles
From top-left: Centre tiles, Straight-edge tiles, Corner tiles, Cross tiles, Diagonal-line tiles, Half-edge tiles

Each of these classes are treated differently, using specific blend masks. The exact format of your algorithm will depend on how you design the masks. In general each set of tiles will be generated with a separate algorithm. Here, for example, is what you would use to generate the cross tiles:

foreach (tile1 in tile_set)
  foreach (tile2 in tile_set)
  {
    new_tile = blend (tile1, tile2, blend_mask_cross)
    lookup_table[i, j, j, i] = new_tile
  }

A very attractive (but more complicated) method of solving the transition problem can be found in the GameDev.net article Tile/Map-Based Game Techniques: Handling Terrain Transitions.

NOTES ON REGION BLENDING FOR HEXAGONAL AND TRIANGULAR TILES

The first important point of applying the algorithms above to hexagonal and triangular tiles is that your logical and tile grids will have different shapes: if your tiles are triangular, the grid will be hexagonal, and vice versa. It also has the effect that hexagonal tiles look triangular, and vice versa.

The blending algorithm depends on how your tiles are orientated. In my (square) image processing code, i use a data structure that will give me an index iterator that I can use to iterate over all indices of a grid. This allows me to not ever have to worry about boundaries. With triangular and hexagonal tiles, this is even more useful. It will allow you to write code for blending like this:

foreach (index in tile1.index_iter())
{
   new_tile[index] = mix_color(tile1[index], tile2[index], blend_mask[index])
}

Using this approach also allows you to pack your tiles more efficiently without complicating higher level algorithms (such as blending) if that is a concern. (Packing a regular triangle in a rectangle wastes 50% space. This can be totally eliminated).



Words from the readers
No comments posted for this article yet. Have something to say? Make yourself heard below.
Have your say: