Godot 3 fog of war over tilemaps

Godot Version

3.6

Question

I have a tile map on a scene. It contains objects of different sizes and some of them are bigger than the tilemap cell (e.g. cell is 48x48 and an object is 48x60)

I tried 2 approaches:

  • 2 tile maps (one for fog, one for object)
  • texturerect inside tilemap (to have proper y-sorting)

In both cases when I put a fog on the tile - the exceeding part of the texture is visible. If I’m making fog tile bigger - it hides something that should be visible.

How can I make this fog?

You could make a version of the fog that only covers the object and nothing that is transparent in the object’s image. So it would have the same silhouette as the object that is being covered. Or you could have the cell empty so the object will not exceed the cell size and you will not have to cover other cells with the fog of war, and the object will actually be placed into the cell when the fog of war is removed.