Godot Version
4.3
Question
I have wriiten the shader below, but the diagonal bars aren’t moving right.
After around half the time, the middle bar is vanishing, but I would like to have a continuous flow. What I am doing wrong?
It should work on a 1:4 aspect ratio (i.e. PlaneMesh: x=1; y=4).
shader_type spatial;
render_mode shadows_disabled;
uniform float scale = 10.0;
uniform vec4 color : source_color = vec4(0.225, 0.97, 0.9, 0.75);
void fragment() {
vec2 uv = UV * scale;
float ar = (VIEWPORT_SIZE.x/VIEWPORT_SIZE.y);
float t = (fract(TIME/3.75) * scale * ar);
float x = uv.x + (uv.y * ar) - t;
ALPHA = 0.0;
for(float i = -1.0; i < 2.0; i += 1.0) {
float off = (i * scale) + x;
if(off > 0.0 && off < 0.5) {
float m = mix(0.25, 1.0, off);
ALBEDO = vec3(color.rgb) * m;
ALPHA = color.a;
}
}
}