Shader 代码部分

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
shader_type canvas_item;

float hash(vec2 p){return fract(sin(dot(p,vec2(17.3,41.7)))*43758.5);}

uniform float progress:hint_range(0,1)=0.5;

void fragment(){
    float n=hash(UV*600.0);
    float m=step(UV.x + (n-0.5)*0.05, progress);
    COLOR=texture(TEXTURE,UV)*m;
}

GDScript 代码部分

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
extends TextureRect

func _process(delta):
 var mat = material
 if mat:
  var current_progress = mat.get_shader_parameter("progress")
  current_progress += delta  # 线性增加
  if current_progress > 3.0:
   current_progress = 0.0  # 超过1后重置为0循环
  mat.set_shader_parameter("progress", current_progress)

编辑器调整

封面

原型参考

封面