circular pattern
Circular Pattern meant to be used in a plane as a placeholder for a 3D character but you can easily convert it to canvas item
You can manipulate the speed easily from gdscript by adding delta to the uniform “revolutions”, so you have 1 revolution per second.
(I show the script in the video)
Shader code
shader_type spatial;
uniform vec3 color:source_color;
uniform float density:hint_range(0.0, 1.0, 0.01);
uniform float radial_res:hint_range(1, 40, 1);
uniform float angular_res:hint_range(1, 40, 1);
uniform float line_space:hint_range(0.0, 1.0, 0.01);
uniform float revolutions;
uniform float emission:hint_range(0.0, 20.0, 0.01);
float circle(vec2 uv, float diameter, float feather)
{
float radius = diameter/2.0;
return smoothstep(radius, radius + feather, length(uv - vec2(0.5)));
}
vec2 polar_coordinates(vec2 uv, vec2 center)
{
vec2 dir = uv - center;
float radius = length(dir) * 2.0;
float angle = atan(dir.y, dir.x) / TAU;
return (vec2(radius, angle));
}
float random (vec2 st) {
return fract(sin(dot(st.xy,
vec2(12.9898,78.233))) * 43758.5453123);
}
float randomf(float x){
return fract(sin(x) * 100000.0);
}
void fragment() {
vec2 res = vec2(radial_res,angular_res);
vec2 uv = polar_coordinates(UV,vec2(0.5));
vec2 igrid = floor(fract(uv)*res);
vec2 uv2 = polar_coordinates(UV,vec2(0.5));
uv2.y -= revolutions * (randomf(igrid.x)+0.1);
vec2 igrid2 = floor(fract(uv2)*res)/res;
vec2 fgrid = fract(uv2*res);
float vsmask = step(line_space, fgrid.x);
float rnd = random(igrid2);
float val = float(rnd > (1.0 - density));
float cmask = 1.0 - circle(UV,1.0,0.0);
ALBEDO = color;
EMISSION = color * emission;
ALPHA = val*vsmask*cmask;
}
Outstanding usefulness, and a must-have for any sci-fi game. Though having revolutions use in-game time would make this shader even more efficient (I thought the shader was bugged until I saw the video xD)
uv2.y -= revolutions * (randomf(igrid.x)+0.1) * TIME;
How do you animate this ? Mine is just static
My guess is you multiply the alpha by Time?
I’ll test it out in a bit but that should work.
Oh I see in the video he is setting the revolutions parameter by duration on a separate script.
Okay so now looking at it you can do this a different way, you could just multiply the UV -= revolutions * Time and have revolutions by default = 1 and adjust it as you like.