r/godot•
DomkeGames

A way to darken everything on screen except select node

free tutorial

I was looking for a way to darken everything except a selected building in a 2d game I'm working on. The only solutions I found were using shaders, like having a dark color overlay in a canvas layer and then cutting out the texture that should not be darkened with a shader. In that case you need to figure out the screen position of the node, but I change the camera zoom and it's a lot harder to also cut out everything in a node if it has several sprites, or having several different nodes which don't need to be darkened.

Turns out the solution is easier than I though :D You can just have a CanvasModulate node in the main scene, darken it's RGB values, hide it by default, show it when you want to darken and compensate the darkening in selected nodes by multiplying the modulate values with code.

The only weird thing is selecting the modulation values for the non darkened nodes and this solution will probably not work if you are using WorldEnvironment with glow enabled.

Examples of the modulation values:

  • CanvasModulate value: Color(0.5, 0.5, 0.5) (50 % darkening), not darkened nodes modulate value: Color(2, 2, 2)
  • CanvasModulate value: Color(0.75, 0.75, 0.75) (25 % darkening), not darkened nodes modulate value: Color(1.33, 1.33, 1.33)

I would say it's a bit hacky, but it works :). Also works if you don't want to darken, but overlay other colors as well

Posted Sep 19, 2025, 7:58 PM UTC

10
Loading comments…