How godot tells if a node is hited by light2d

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By omar-bz

Hi, I am experiencing a weird behavior in working with the Light2D node: I have a sprite using a texture as OpenSimplexNoise and lights works really fine if I do not change the color of the texture via shaders( clipping the texture cause no problem: returning a zero in alpha, and setting up the normal is ok), but when I start changing the colors (say if I got black from the noise I put red and when I got white I put blue), Godot ignore the sprite and does not apply light to it and appears dark.

So how does Godot tell if a node is affected by lights and how I can change that behavior.

EDIT:
Basically what I’ve noticed is that when you change the color of a texture inside the shader (even ordinary image not necessarily noise) Godot begin to ignore that node from being affected by light

THANKS.

Can you post the shader you used?

Zylann | 2019-04-17 18:06

here it is the code of the shader:

shader_type canvas_item;

uniform vec4 COLOR1 : hint_color = vec4(0.);
uniform vec4 COLOR2 : hint_color = vec4(0.);

void fragment(){
vec4 origColor = texture(TEXTURE, UV);
vec4 color =(1.-smoothstep(0.49,.51,length(UV-vec2(.5)))) * (origColor * COLOR1 + (1. - origColor) * COLOR2 );
vec2 uv = UV-.5;
NORMAL=(vec3(uv,sqrt(0.25-uv.xuv.x-uv.yuv.y)))*5.0 ;
COLOR = clamp(color,vec4(.0),vec4(1.));
}

omar-bz | 2019-04-18 08:27