Painting with multiple Terrain types

I have 4 terrain types (water, wet-beach, beach, and grass). Water can never connect directly to the beach, it always needs to create water->wet-beach->beach tiles. This seems to work about 90% of the time, but often odd tiles will just appear, like grass and water when I’m painting beach on water (and not connect correctly). I assume it due to me not having all the connections, but I can’t see anything missing.

I’m assuming the Terrain system is smart enough to use the wet-beach tiles when I paint beach on water. The errors seem very random. I move the mouse and the incorrect tiles change. Sometimes it shows correct connects, but if I place the mouse somewhere else and then move back to the previous location, it’s now incorrect.

What’s important is that water can never connect directly to beach tiles, it always has to go through wet-beach.

Here is my .tsx and texture file. The multiple water tiles are for animation and I’m not using it yet.

Terrain.tsx (8.2 KB)

tf_terrain_water

I’m running Version 2018.06.27 - Mac

Here is an example of painting with “sand” on “water”. Sometimes it does it correctly, other times it seems to randomly be wrong. All three were in the same place. By design, sand doesn’t connect directly to water, wet-sand is the in between.

sand-on-water-1

sand-on-water-2

sand-on-water-3

Bumping this… does any have an idea? I’ve noticed this again today but with different terrain. It seems to happen in situations where A -> B and B -> C. If you paint with terrain A, you get C for odd reasons when it should just paint with A and B. I just don’t know what I’m doing wrong.

My first thought is that the error is in the terrain definition. The terrain tool picks a random option when multiple options are possible. I’m at work now so I no’t have access to Tiled, I’ll try to check out the tsx tonight.

Alright I’ve had a look, the problem was indeed that multiple options were possible. When drawing over water, both the water-to-grass tiles in the left-center and the water-to-sand in the left-bottom of the tileset were possible options.

I’ve split the water-to-grass tiles from the Water terrain, and added it as “River terrain”. If you fill the map with the water tile (I’ve defined the left-bottom water-tile in the center of the sand-tiles as central water tile) and draw the sand terrain on it, it works as expected. And you can draw grass on top of the sand as well :grinning:
Terrain.tsx (8.5 KB)

I don’t doubt that you’re right, but I don’t follow the issue. I can’t see how those would both be valid options. I’m trying to understand the issue so I don’t fall into it again. I’m painting on water with sand, why would it ever choose grass? There is no grass in sight.

You’re painting sand on water, but you do not have a transition between sand and water. But you do have transitions from sand to two other terrains, that in turn have transitions to water (wet-sand and grass). Tiled uses these other terrain types in between to try to make the transition from sand to water.

However, Tiled considers each cell separately, and it considers grass and wet-sand as equal options to bridge from sand to water. It ends up sometimes choosing grass and sometimes choosing wet-sand, but then it runs into problems when the wet-sand meets up with the grass.

There is no solution for this implemented in Tiled currently. I think one possible way would be to add a penalty to using a certain terrain type. If grass would have a 0.1 penalty, then it would always end up preferring wet-sand in this situation. Of course, it may be that there is a different transition where you want it to use grass, in which case you’d have to put an even bigger penalty on some other competing terrain type.

Another solution may be to allow the algorithm to reconsider previously chosen tiles if it gets stuck. That way, it should sometimes choose grass and sometimes wet-sand, but it would discard the cases where it chose both. The problem with that approach is that it quickly becomes very CPU intensive as it tries the many possible combinations.

OK, makes sense. I don’t have tile art for Water -> Sand, so I was hoping the system would be smart enough to put the WetSand in between (I now see why it can’t).

I haven’t had the time to look at Marcel’s solution to see if it works in a general way. I’ll have a lot more of these 3-way transitions.

Part of my issue is workflow. I tend to fill the map with water, then I grab a single sand tile and paint/fill the outlines of the island(s), just to get a good feel for the layout. Then I go back and paid the edge with wet sand hoping it will join the the water/sand edge with wet sand, but it often doesn’t and I spend a lot of time cleaning up bad grass tiles.

I might need to find a better work flow. I have A LOT of these island maps to make.