Shader 代码部分

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

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

void fragment(){
    float line = UV.x + UV.y*slope;
    float mask = step(line, progress*(1.0+slope));
    COLOR = texture(TEXTURE,UV)*mask;
}

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)

原型参考

封面