I am trying to make a shadder where I input a time in secs and it make the texture invisible by this time, but I could not understand how to use the TIME for this since I could not find any doc about what TIME is, I know it is the iTime, but how can I set an starttimer, reset, stop etc ( I know I cant stop a shadder, but I wander how can I make it stops changing the texture after the time runs out )
This is what I got so far, it use TIME, but by sin :
shader_type canvas_item;
uniform float fade_speed;
void fragment() {
vec2 texture_resolution = 1.0 / TEXTURE_PIXEL_SIZE;
vec2 pixel_within_texture = floor(UV * texture_resolution);
vec4 texture_color = texture(TEXTURE, UV);
float inv_value = sin(TIME * fade_speed) * 0.5 + 0.5;
inv_value = clamp(inv_value, 0.0, 1.0);
vec4 final_color = vec4(texture_color.r, texture_color.g, texture_color.b, inv_value);
COLOR = final_color;
}
How can I make it runs, starting from alpha 1, for a few seconds and stop changing the texture when alpha is 0 ?