Avoid self-shadowing on TileMap with Light2D

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

I am trying to implement a top-down 2D game using a TileMap with a Light2D set to Mask mode in order to implement fog of war.

If I build a TileSet Autotile with Occluder2D squares for each tile and position a Light2D on the player, the fog of war effect is achieved but the walls themselves are blacked out. I would like to be able to see the walls but not what is behind them.

My next idea was to set the cull mode to Clockwise so that only the backfaces of the Occluder2D would cast a shadow. This works to some extent, but because there are faces between each tile in a continuous wall section, unwanted shadows are cast from within the wall as described in this post: How can I make tilemap walls with an occluder show and cast shadows?

Finally, I discovered I could describe an unclosed Occluder2D on a tile which was a single face rather than a closed polygon. This works great for one edge of the tile but not the opposite edge. If I was able to add multiple occluders to a single tile I think I could solve the problem, I would use unclosed lines rather than closed polygons to draw the outline of the wall. However, it doesn’t seem to be possible to add more than one occluder to a tile even if I create a separate scene and bulid the tileset the old fashioned way.

I tried examining the tileset.tres file and even modified it to associate two occluders with a single tile. When the tres file is next parsed by the editor, one of the occluders is removed.

Any ideas how I can achieve the desired effect? Is it possible to modify the behaviour of TileMaps without needing to delve into the underlying C++ code? Or can anyone think of a better way to solve this problem?

Thanks!