Shader 代码部分

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

float rand(vec2 p){return fract(sin(dot(p,vec2(12.3,45.6)))*43758.5);}
uniform float progress:hint_range(0,1)=0.5;

void fragment(){
    vec2 cell=floor(UV*40.0);
    float r=rand(cell);
    COLOR=texture(TEXTURE,UV)*step(progress,r);
}

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)

编辑器调整

封面

原型参考

封面