Hey fellow Love2Ders,
Let's say you have a game with tiles, but the tiles are generated dynamically by players (like in Minecraft or Terraria). Any tile can be next to any other. Creating tilesets that have baked in transition tiles would be a combinatorial explosion. One solution is to interpolate between tiles. Another is to make the tiles slightly overlap and draw them on top of each other. Here is an example of that. By texturing on corners of tiles, you can actually create all the tile transitions using only 14 tiles. One problem with this technique is the texture repeats itself over and over.
An alternative for Wang tiles: Colored edges versus colored corners has a great solution to this problem. You can get transitions and texture variation using three colors, one for transitions and two for variation. This requires 80 texture tiles for each tile type (dirt, sand, water, cobblestone). That's a lot of texture painting if you do it manually, but it is doable.
So, I've made a demo of this technique. Try it out and let me know what you think.
A tiling technique demo

 Prole
 Posts: 41
 Joined: Wed Sep 26, 2012 9:19 pm
A tiling technique demo
 Attachments

 CornerTiles.love
 (16.95 KiB) Downloaded 223 times
Re: A tiling technique demo
Interesting post and articles. I'm working on the same problem currently.
Here's another, more gameoriented article on the subject.
http://www.codeproject.com/Articles/106 ... naTileM
Why do you have to use 81 combinations? Why not using alpha channels and terrain precedence, so you always have to deal with only two terrain types at once thus 16 * n instead of n^4 tiles.
Another approach would be the RPGmaker one, which splits tiles in four subtiles, to create every combination possible from a simple 12 tiles set.
Here's another, more gameoriented article on the subject.
http://www.codeproject.com/Articles/106 ... naTileM
Why do you have to use 81 combinations? Why not using alpha channels and terrain precedence, so you always have to deal with only two terrain types at once thus 16 * n instead of n^4 tiles.
Another approach would be the RPGmaker one, which splits tiles in four subtiles, to create every combination possible from a simple 12 tiles set.
Re: A tiling technique demo
Hi. Pretty cool example you have there.
BTW, there is a nice approach for doing 'autotiling' which involves a little bit of bitwise math:
http://web.archive.org/web/201107152342 ... com/?p=184
It works pretty well and you only need 16 tiles in total (2 tile types to the power of 4 edges).
If you want to have more than 2 tile types you'll need a lot more transitions: 3^4=81, 4^4=256, 5^4=625, etc but notice that the number grows quite rapidly after 3^4.
One solution is to overlay the different tile types as explained in the link you already provided:
http://www.gamedev.net/page/resources/_ ... errair934
BTW, there is a nice approach for doing 'autotiling' which involves a little bit of bitwise math:
http://web.archive.org/web/201107152342 ... com/?p=184
It works pretty well and you only need 16 tiles in total (2 tile types to the power of 4 edges).
If you want to have more than 2 tile types you'll need a lot more transitions: 3^4=81, 4^4=256, 5^4=625, etc but notice that the number grows quite rapidly after 3^4.
One solution is to overlay the different tile types as explained in the link you already provided:
http://www.gamedev.net/page/resources/_ ... errair934
Re: A tiling technique demo
80 combinations per tile is a bit unrealistic if you plan to do it by hand. Although it's always cool to see a new approach to an old problem.
If you're interested in the RPGmaker method I created a tutorial for it a while back. There might be an easier way but it works.mode7 wrote: Another approach would be the RPGmaker one, which splits tiles in four subtiles, to create every combination possible from a simple 12 tiles set.

 Prole
 Posts: 41
 Joined: Wed Sep 26, 2012 9:19 pm
Re: A tiling technique demo
Good article. One difference between techniques is here:mode7 wrote:Interesting post and articles. I'm working on the same problem currently.
Here's another, more gameoriented article on the subject.
http://www.codeproject.com/Articles/106 ... naTileM
This would require the tile variants to be seamless with each other on all texture edges. The technique I am using allows for more variety in the edges and corners.Variety
Despite the use of smoothly transitioning tiles, an observer can still be alienated by repeated patterns of the same tiles as can be seen in Figure 1. The algorithm can be improved by mapping each 4bit index to more than one tile variant and have the algorithm select variants at random for the newly placed tile and for its neighbours.
There are other ways to do it for sure. One thing to note about this technique is that there is no repeated texture over any of the tiles (except two small cobblestones exactly on the two non transparent colors, but that can be fixed a bit) that means none of the texture is actually wasted, all tiles are adding good variety.mode7 wrote:Why do you have to use 81 combinations? Why not using alpha channels and terrain precedence, so you always have to deal with only two terrain types at once thus 16 * n instead of n^4 tiles.
I really like the bitwise math way of just ORing the corners together. I kind of wish love2d included a bit library. I've been using https://github.com/davidm/luabitnumberlua for some stuff, but it is kind of slow.ivan wrote:Hi. Pretty cool example you have there.
BTW, there is a nice approach for doing 'autotiling' which involves a little bit of bitwise math:
http://web.archive.org/web/201107152342 ... com/?p=184
It works pretty well and you only need 16 tiles in total (2 tile types to the power of 4 edges).
If you want to have more than 2 tile types you'll need a lot more transitions: 3^4=81, 4^4=256, 5^4=625, etc but notice that the number grows quite rapidly after 3^4.
One solution is to overlay the different tile types as explained in the link you already provided:
http://www.gamedev.net/page/resources/_ ... errair934
Yeah, it's tedious as hell. I do like the end result though. Thanks for the RPGmaker tutorial, I was just about to go looking for information on that.Kadoba wrote:80 combinations per tile is a bit unrealistic if you plan to do it by hand. Although it's always cool to see a new approach to an old problem.
If you're interested in the RPGmaker method I created a tutorial for it a while back. There might be an easier way but it works.
Re: A tiling technique demo
BTW, the terrain in Civilization 3 uses tilesheets containing 81 tiles each.Kadoba wrote:80 combinations per tile is a bit unrealistic if you plan to do it by hand. Although it's always cool to see a new approach to an old problem
They have 3 transitions per tilesheet for example water/desert/grassland or water/grassland/plains, etc.
The end result looks pretty good and they only have about 810 tilesheets in total.
Basically, Civ 3 disallows certain transitions like desert/icesheet or tundra/desert, etc which is another way of lowering the total number of transition tiles.
That's still a lot of tiles to draw by hand but in Civ 3 they obviously used a 3D program to prerender the tiles.
Who is online
Users browsing this forum: No registered users and 31 guests