Autotiling

Started by
1 comment, last by LorenzoGatti 10 years, 8 months ago

How do I autotile properly?

Right now, I have tried using this method: http://www.codeproject.com/Articles/106884/Implementing-Auto-tiling-Functionality-in-a-Tile-M

(and I've read the source code on there - that's how I wrote my own version of it, as the article was very abstractly written)

The problem is, however, that I cannot get it to use more than one tilesheet. (two tiles - dirt and grass)

I have been trying and trying for a long time to do it, and I've come across a lot of ways.

Like, making the tilesheet only have one tile, and the secondary tile being transparent - so there are limitless combinations, I also tried making a 9x9 tile that would overlap or underlap neighbour tiles depending on depth, but our pixel artist really dislikes this idea, and what I've primarily tried is making all the tiles have a main tile, like "dirt" "grass" or "water". I then named the tilesheets for "dirt grass", "dirt water", "grass water".

I then made two algorithms, which both failed, to find out what tileset to use for each neighbour around the new tile.

I am surprised that there is relatively very little information I find on Google about autotiling. Every result goes back to a few articles, which only covers the basics.

Am I missing some big thing with this method?

Are there any other methods that can be used?

Thanks in advance!

Advertisement

A one-pass algorithm (which I presume you are using) might not do the trick, on top of most likely being unpleasantly complicated to work with. I highly recommend you make use of simple cellular automaton to generate the rules which the tiles will follow in any particular situation. Essentially, you need to make a number of passes (and perhaps repetitions) over your data using simple rules and/or algorithms so that the data will procedurally arrange itself and come to an equilibrium with your desired results, which is in this case the rule set that a tile sheet or combination of such will follow.

http://simple.wikipedia.org/wiki/Cellular_automata

http://en.wikipedia.org/wiki/Cellular_automaton

Keep in mind that rigidly attempting to define standard rule sets is not the right way to go about this; you should be able to place particular tiles, sizes or classifications anywhere you want on a tile sheet. Feed your data into the initial rule set array that classifies a particular tile and what availability it has for use with other tiles. Like, this tile is grass. It can connect with sand. It forms a wall north. And so forth.

Once you have fed all of your information about a tile sheet into it's rule set array, iterate over each tile and analyze the rules that it follows. Using those rules, compare them with every other tile in the array and retain the resulted relationship information in a format of your choosing. Naturally every tile in the sheet with require a container that contains references to tiles it shares information with and how. If a tile has no effect on another, then that reference will not be required because they are estranged.

I think a cool way to implement this would be to retain in the actual image data information that you can implement as you are drawing the tile sheet. As an example, if the topmost left pixel of a tile is green, then it is grass. If it is blue, then water. And so forth. Then when you load the image, the information storing pixels would be interpreted as non-graphical supplementary information and then discarded. This would put complete control in the hands of the artist and would not require the relentlessly brutal alternatives that you have already considered.

The corner tile system in the article can be summarized as assigning terrain types to tile corners and setting all 4 corners of a square to a given type as a basic editing operation. With n terrain (corner) types there must be n^4 tiles to cover all corner type assignments: 2^4 =16 tiles for 2 types (like in the article), 3^4=81 tiles for 3 types, 4^4=256 tiles for 4 types, which is still affordable. Effort can be reduced by marking some tiles as forbidden and checking they aren't required instead of drawing the corresponding graphics. For example, if terrain types are woods, grass, dirt and water, you could allow only tiles with woods and grass, grass and dirt, dirt and water: only 46 out of 256.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement