TileMap: Partially modulate specific cells

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


I work on a 2D project that includes an isometric TileMap. The tiles can, e.g., be buildings. Now what I want to do is “paint” (=colormodulate) certain parts of these buildings. I would therefore have 2 graphics for these buildings, one which will remain unmodulated and one which will change its colour. It’s basically similar to how it’s done in this game where some buildings have some of their parts in the color of the player that owns them: https://www.openttd.org/screenshots/1.4-02-opengfx-1920x1200.png

The problem is, I believe a TileMap can’t do this. I can modulate ALL tiles in a tileset (which would already be insufficient as not all tiles of the same kind will need to be modulated in the same way), but not certain parts of the tile either. So from what it looks like, my only choice here is to use sprites that are placed on top of the TileMap. Is that correct? In this case, however, it is possible that other objects (e.g., units) are behind or in front of these sprites then. For example, they should be in front of a certain sprite but behind another one. Do I have to work with large z-indexes then?

Also, is it even worth it to use a TIleMap then in the first place? I mean, it’s supposed to be more efficient but then I will have to place all sorts of non-tile overlays on top of it. I’m a bit worried performance may suffer then. Although, I have to mention I will have around 1000 tiles in total, so I suppose it’s still rather small compared to what it could be.

Is my reasoning here correct? Is there any way to use a TileMap in the way I would like it to? If not, what is the best way to proceed from there? Should I lay another TileMap on top of it for the modulated parts with duplicates of unique tiles for each player that I can modulate? But that would lead to other problems, I guess.

:bust_in_silhouette: Reply From: rakkarage

Sorry not sure about 3 but in Godot 4 you can right click on any tile in the tile set editor and select “Create Alternative Tile” then change flip and modulate etc for the alternate.