Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | crossbito |
Hi, I have the following issue.
I’m using _draw to draw a draw_rect with specific colors, but it seems that the different shaders I create transform what I drew into a solid white color. What should I do to apply shaders to draw_rect? I see a lot of information on how to apply shaders to textures, but I can’t find how to apply a shader to something created with draw_rect.
Here’s a shader example that flashes, for instance. It works if I use it on a sprite, but not on elements created with draw_rect. It just turns everything white.
shader_type canvas_item;
uniform float blink_speed = 2.0; // Blink speed
uniform float blink_amplitude = 0.5; // Blink amplitude
void fragment() {
float time = TIME * blink_speed;
float blink_value = abs(sin(time)) * blink_amplitude; // Calculate blink value between 0 and blink_amplitude
// Original color of the object
vec4 original_color = texture(TEXTURE, UV);
// Color with red tint
vec4 tinted_color = vec4(original_color.rgb + vec3(blink_value, 0.0, 0.0), original_color.a);
COLOR = tinted_color;
}
I appreciate any help in resolving this issue. Thank you!