Is there a way to make the autotile feature work with more than two types of tile terrain/background at the same time?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NeolythicRichat01

I’m new to Godot but I got really interested in trying some advanced stuff with the autotile feature. From watching tutorials I became somewhat familiar with how the bitmask works, but there is something I’d like to do that I just can’t even imagine how from what I’ve seen:
Having different types of terrain/background interact with one another through the autotile system, something like…
Imagine that the background of the autotile is just transparency. Now imagine there are some jungle stone temple blocks, as well as some jungle grass/dirt blocks and both have their own autotile system telling them which sprites to use for which shapes and such, regular autotile stuff.
But how do I make it so that the stone blocks interact with the grass and dirt?

I know there has to be some way because Terraria seems to do this well enough, while it’s not perfect, you can still have something like the stone blocks inside the dirt and it behaves like a whole new autotile:



I searched for advanced tutorials and in the documentation, but I didn’t really find anything on this. Then I tried some thought experiments involving inverted bitmasks, and pairs of bitmasks without the center square that match each other’s normal bitmask, but since I couldn’t wrap my head around it really well and I had no clue if there was a way it would even work, I decided it was best to just ask.

Any help is greatly appreciated!

:bust_in_silhouette: Reply From: Cody Sass

Well shucks, I can’t believe nobody chimed in here.

So what you’re looking for is a non-binary bitmap or tilemap. Godot has only the binary version built in which means you either have tile, or no tile. Does not play well with multiple types of tile. You probably won’t find much on it because the solutions are varied, depends heavily on your art, they’re not intuitive, and they require a lot of tinkering to get how you want it to look. Fixing problems with them can often either be done by the artist, or by the code. It’s really crappy to make a tutorial for. So, just to make sure we’re on the same page. I am currently using 2x2 autotile bitmasks, my artwork purposely extends half the width of my tiles, I am not using angles, it’s all squares. Basically, I’m making a top down map with multiple biomes using a a tileset like this Basic biome tileset

The first thing you have to accept is that if you’re going to do this you need, at minimum, four layers of tilemap. Because at any point, 4 different biomes “or blocks, or whatever” are going to meet in a corner and if you want things to look nice and “spill” into the tiles next to them they have to overlap.

The way I have been tackling this is basically imagine your grid that you already have, and make a second “artwork” grid (4 layers deep), and shift it, down and to the right, half a tile. This makes it so that every tile in your main “grid” overlaps 4 “artwork” tiles. When you change a tile in your main “grid” You’re going to change the corner of each “artwork” tile you’re overlapping to make one complete tile. If you start filling out your artwork tiles and you find something already there, just move to a higher layer of artwork node.

I highly, highly recommend getting real warm and fuzzy with tilemaps. Specifically how autotiling actually works. This link Autotiling in Godot 3.0 | Michas gamedev blog is a fantastic dive on how the logic of autotiling actually operates.