Some problems about Light2D

Godot Version

4.3

Question

When using Light2D’s Mix mode and setting the energy to 0 during the day, the lights darken the scene as shown below. This is not what I want.

I tried Add mode and when the energy is set to 0, it’s like it’s disabled, which is realistic. But if two lights using Add mode are too close together, they are too bright. Here is the scene. The lantern on the left is OK, but the lanterns on the right are too bright.

But if the lanterns are set to Mix mode, the final effect is what I want. But it has the negative effect of darkening above.

What I want:
The lights gradually change brightness with the clock, and I want to have a Mix effect so they are not too bright at night. But Mix mode darkens the environment during the day, and I don’t know how to adjust it.

Is it possible to make a Light2D gradually brighter like Add mode, but have a Mix mode effect at night?

Also, the brightness of Light2D depends on which value of its texture? Alpha? But a black and white texture can also be used as its texture, so I’m really confused.

This depends entirely on the blend mode you’re using. With Add you can either use the texture’s luminance or it’s alpha to modulate the strength of the light. With the way Mix works, you must use the texture’s alpha if you wish to hide parts of the light.

The Mix blend mode: (see docs)
Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation.

With regards to the result you want to achieve, I think there are two ways of going about it currently:

  1. Make a custom shader (make your own light)
  2. Revert to using Add and configure light intensities per area

I’m not at all familiar with custom lighting in Godot, and I haven’t messed around with 2D games that much, but it’s probably possible to make your own CanvasItem shader which clamps the intensity of lights. That said, it’s probably easier to use the 2nd approach.

Sorry for not having a definitive answer for you.


Other users have requested a feature for this very use case (see issue).

I tried again after I posted this. In the end, like you said, I chose the Add mode and adjusted the texture of Light2D, because it is the most convenient solution for a new developer.
Thanks for your advice.

1 Like

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