Is there an equivivalent to `Light2D.Mode.MODE_MASK` in Godot 4?

Godot Version


Problem I’m trying to solve

I’m trying to create a game where certain other nodes are only visible when in sight. This doesn’t mean just a certain distance, but they won’t be visible behind e.g. walls.

Solutions I’ve seen so far

There’s this tutorial:

Which uses a Light2D node with the Mask Mode. This works fine for Godot 3, but apparently this feature was removed in Godot 4.

I did also find a Github issue where this was discussed as “expected” and replaced with the CanvasItem clipChildren property, which unless I’m missing something, does not handle visibility occlusion through walls.

The tutorials linked in that issue as well as another youtube video suggest using custom shaders. I can go through these and figure out the shader I want, but that seems like overkill for a feature that was in Godot 3 by default.

What is the best way to get this effect in Godot 4?

Specific details that may or may not be relevant

I will eventually have three visibility layers:

  1. visible always, which contains a non-detailed version of the environment (probably like a map or blueprints)
  2. visible only when in sight range of the player, which includes things like enemies
  3. a “extrasensory” layer which the player can activate to see enemies at a further range

The thing I’m trying to implement right now is just (1) and (2), which requires making nodes transparent (not black) so that I can show the “map” behind them.

I mention these because if there is a better way to get this effect, I would be open to other solutions than the one I’m asking about above.

Also, sorry about not providing links to the docs or issues, the forum is limiting how many links I can post since I’m new (even though I had an account on the old Q&A site)