Disabling Self Shading on Tilemaps in Godot 4

Godot Version

Godot 4.2


Hey Godot Users, I’m having an issue I hope maybe one of you could solve. I am working with a TileMap (Terrains, specifically, not sure if that matters), and I added occlusion to tiles. The occlusion is working perfectly, however, I wanted the textures under the occluder to also take in light. I found a discussion from 2016 with someone having the same issue, but they were on Godot 2, and they were using Sprite2Ds and OcclusionShape2Ds, rather than Godot 4 and TileMaps. I set up the same scene in Godot 3, and the effect I want works perfectly, but if I do the same thing in Godot 4, it doesn’t work.
Basically, to sum it up, the textures of tiles are affected by light and also occlude, in Godot 3, and in Godot 4, it only occludes and doesn’t get lit up.

Link to the old article, for more examples

I think this is a rendering issue that will be difficult for you to solve. Rather, you will need to find a workaround. Here are two standing issues in the GitHub which I believe are related to your issue:

If you have a GitHub account, it might be a good idea to “like” those issues to help show the maintainers that you would like the issue to be prioritized.

As for a workaround, it will be easier to provide suggestions if you could show screencaps of your setup and how it’s looking vs how you would like it to look.

1 Like

This isn’t the issue I’m having, but I appreciate the effort(I don’t mean to sound sarcastic btw), also sorry for not adding the screencaps before, when godot Q&A changed to the forums, my account got deleted, so I can’t post more than two pictures at a time, I’ll try to send them in different replies.
Regarding my issue though, here is my scene working perfectly in Godot 3:
Screen Shot 2023-12-12 at 12.53.40 PM
Notice how the wall is lit up, and it’s also occluding, this is how I want the scene to work (The light source is placed under where the wall is to avoid that issue you replied about).

And then here is the Godot 4 version of that scene, everything is done the same except for the placement of tiles, but you can still see how it doesn’t work:
Screen Shot 2023-12-12 at 12.54.55 PM
The wall isn’t lit up, but it still occludes. This is the self-shadowing I was speaking of earlier, and I’d like to make it so the wall is lit up and occludes, like in the Godot 3 image.

I know a workaround, but it’s a bit tedious. It requires your walls and your floor to have different CanvasItem Light Mask layers. Of course, this is a feature TileSets don’t have, which means it requires two separate TileMaps, one for the walls and one for the floor.

The floor TileSet is normal, but the walls TileSet needs two occlusion layers: one for occluding the light for the floor, and one for occluding the light for both the floor and the walls. The “side” walls get the one occluding only the floor, while the “ceiling” walls get the one occluding both.

You also need two identical light sources, with one projecting only on the floor and the other projecting only on walls.

Does that all make sense? I told you it was tedious, right? I really wish TileMap fixes would get some more love…

1 Like

That does make sense, and it’s gonna be really tedious to set up, but as long as it works, i’m happy. I had already seperated the floor and walls, but hadn’t put the walls and tops separately. Thanks for the help! I’ll let you know if it works

1 Like

Just making sure: You don’t need a separate map for the walls and the ceiling, if that’s what you think I meant. You can, fortunately, assign different occlusion layers to different tiles in a tileset. Just not different light mask layers.

1 Like

No, yeah I understood what you meant, I still appreciate it though, it sucks how the tilemaps aren’t treated as important as other nodes by the devs

1 Like

Ok, saying I appreciate you would be an understatement, this problem has been bugging for like the past month or so, and the original Q&A site was down, so I had no clue what to do. Thankfully though, you showed up. I appreciate it so much, thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.