Hi, I'm trying to code a shader that makes a Sprite2D transparent dependently on the lights by changing the alpha of the texture color. I started by making it invisible in the dark and visible in the light, and it works flawlessly. But then, when I try to make the opposite, it just doesn't work, no matter what I try. This is what happens when I make the sprite visible only in the light:
This is what happens when I make it visible only in the dark:
For reference, here's the code of the shader:
shader_type canvas_item;
uniform float light_opacity : hint_range(0, 1);
uniform float dark_opacity : hint_range(0, 1);
void fragment() {
COLOR = texture(TEXTURE, UV);
if (AT_LIGHT_PASS) COLOR.a *= light_opacity;
else COLOR.a *= dark_opacity;
}
What am I doing wrong?