shader problem with smooth scale galaxy.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zszen John

I crreat a far away galaxy shader scale effect.
here is the demo:

the demo video:

It can’t smooth move. I can’t know what happened with it. Sometimes faster somthime slower.

the shader code:

shader_type canvas_item;

uniform float speed:hint_range(.01,10.0) = 1.0;
uniform float scale:hint_range(.01,1.0) = 1.0;
uniform float distance:hint_range(.5,10.0) = 3.;

void fragment(){
	vec4 cc_all = vec4(vec3(.0),1.0);
	float scale_base = 1./scale/distance;
	
	float percent = fract(TIME*speed);
	
	for(int i=4;i>=1;i--){
		float i_seq_before = pow(2.,float(i));
		float i_seq = pow(2.,float(i+1));
		float scale_small = scale_base/i_seq_before;
		float scale_big = scale_base/i_seq;
		vec2 uv = ((UV-.5)*(percent*(scale_small-scale_big)+scale_big)+.5);
		vec4 cc = texture(TEXTURE, uv);
		if(i==1){
			cc.a *= 1.-smoothstep(0.0, 1.0 ,percent);
		}
		cc_all.rgb = cc_all.rgb*(1.-cc.a)+cc.rgb*cc.a;
	}
	COLOR = cc_all;
}