Weird behavior with PointLight2D

Godot Version

4.5

Question

So I’ve been experimenting with adding lighting to my game, and I have the following setup currently:

  • PointLight2D on the player
  • CanvasModulate on the Room scene
  • Occlusion Layer on wall tiles

And I’m experiencing the following weird behaviors:

  1. Shadow on the walls that’s on top of the player (preferably I’d want to remove the shadow on the wall entirely and have it be lit up.
  2. When the player gets close to a wall, the wall lights up, while the environment around doesn’t.

I’m aware that there were similar issues brought up before, but I wonder if Godot 4.5 added something to fix this without workarounds.

Would be grateful for any help!

Isn’t that the point of the occlusion layer, to block the passage of light? Why put occluders where you want the illumination.

Well I want the walls to cast shadows, and as far as I know the way to do this is with occluders. But I don’t want the walls themselves to be dark like shown above.

An occluder does cast a shadow for you. Just your wall tiles happen to be behind, or inside the occluder, so they are inevitably in this casted shadow too. You seem to want for two exclusive things to have place simultaneously.

Remeber that there isn’t a “wall” to the engine. It’s all just a flat sheet with tiles painted on it. There isn’t an automatic way for it to tell what parts should be iluminated and how, as it could in a 3D environment where the floor and the walls are distinct polygons facing in different directions. Here your intent regarding lighting necessarily will have to be communicated to the engine via some “workaround”.

You could place the walls in a separate layer, and have that illuminated to whatever rules you have in mind for the walls. Or maybe there is a way to configure masks on light sources and occluders, but I have no working recipe to share.

1 Like