Godot Version
Godot 4.6.1 stable
i am making a 2d pixel art platformer mobile game. there is a dark prison level that i want to make some areas dark and some light ( with torches) . i used the native point light 2d for torches and canvas modulate for darkening the scene.
i achieved this which is fine:
the problem is that this is heavy for mobile devices. i get low fps on highend devices 
i tried using a sprite with add material for fake light. but it doesn’t make the scene lighter. it doesn’t work with canvas modulate
this was the best i could make with sprite2d:
as you can see, it doesn’t make the scene lighter. it just colors it.
is there a way to get this effect with shader or something? or a way to optimize the light 2d to the maximum?
This is what I did in my last project (not using Godot):
- Create a screen-sized texture called the light buffer.
- Render lights as sprites into the light buffer.
- When rendering the scene, use a custom shader to multiply each pixel by the corresponding value in the light buffer. (You could also render normally and then apply the light buffer in a separate step, using multiplicative blending.)
The nice thing about this approach is that lights are no more expensive than other sprites, so you can have vast numbers of them in the same scene.
I have a similar technique (using Godot).
- CanvasGroup called Light
- Add colored sprites with full opacity
- Use a shader to overlay those lights on the normal scene
- This makes color mixing possible, but doesn’t brighten areas with overlapping light (which is what I needed for my game).
I should have added, I use additive blending for rendering the lights themselves. That takes care of overlapping lights.