Tilemaps and ShadowCaster2D help

Hi, I am working on a project which has tilemaps with destructible tiles. These tiles are rule tiles that are essentially ‘walls’ that the player can break. Everything works great, except for when I try to implement shadows. I want these wall tiles to block light from passing through them from whatever direction the spotlight attached to the player is coming from.

My original system had a prefab gameobject on each tile that included the script for destroying the tile. When I add a Shadowcaster 2D to these gameobjects I am unable to get them to properly cast shadows. They always self shadow no matter what settings I try. I believe this is due to the fact the sprites themselves are on a tilemap and not the gameobject itself.

So, I have now tried a system without individual gameobjects and one shadow caster on the tilemap. Because the shadows can be slightly different shapes depending on the rule the tile is following, this is set up to source from the Polygon Collider 2D.The problem with this option is it really impacts performance. These tilemaps have probably 200 tiles. There are very few spotlights in the scene and it actually seems that it is the global light that is the main issue. If I turn this off, the performance goes back to normal. This is frustrating because i don’t even want the global light to cast shadows but I believe its to do with the shadow calculations that Unity does.

My question is, is there some way of fixing this or some other way of achieving the results I want that I haven’t been able to discover? I have been going round in circles on this so any help would be amazing.

Hi, would it be possible to describe and share your setup with more details? You mentioned that you are using the PolygonCollider2D, so I assume you are not using the TilemapCollider2D with the Tilemap? If you could share how the PolygonCollider2D are generated and passed onto ShadowCaster2D, that would be helpful.

You could also try to use the Unity Profiler when there is a slowdown to see where the main costs are and post them here.

Thanks!