Light shader
Godot’s Light2D has an annoying limit of 16, and while the official documentation recommends using Sprite2D with additive blending mode, it ends up not looking very good in a dark environment.
Here is a simple shader which was provided by HaruYou27!
No 16 limit, no performance issue, you can place as many lights as you want in a dark environment!
The final effect is as follows:
Shader code
shader_type canvas_item;
render_mode blend_add, unshaded;
// 2D light shader by HaruYou27.
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, repeat_disable, filter_nearest;
uniform float intensity = 10.0;
void fragment() {
// Sample the underlying screen color
vec3 under_color = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
// Make it brighter
vec3 final_color = under_color * COLOR.rgb * intensity;
// Don't forget the alpha value
COLOR = vec4(final_color, COLOR.a);
}
Cool, it works for me