先看效果圖
同樣使用VS Code安裝glsl-canvas還有Shader Language兩個插件。

圓形掃描.gif
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D u_texture_0; //紋理圖片
uniform vec2 u_resolution; //畫布分辨率
uniform float u_time; //時間全局變量,動態(tài)改變
uniform int axis; //旋轉(zhuǎn)軸如:X軸 Y軸 Z軸
uniform sampler2D u_texture_1; //紋理圖片1
uniform sampler2D u_texture_2; //紋理圖片2
uniform sampler2D u_texture_3; //紋理圖片3
uniform sampler2D u_texture_4; //紋理圖片4
uniform sampler2D u_texture_5; //紋理圖片5
void main() {
vec2 uv0 = gl_FragCoord.xy/u_resolution;
float direction = 3.0;
float u_progress = u_time / 1.0;
vec2 size = u_resolution;
vec2 uv1 = uv0*size;
vec2 center = 0.5*size;
vec2 start = vec2(0.5*size.x,0.0)-center;
vec2 end = uv1 - center;
float cos_theta = dot(start,end)/(length(start)*length(end));
float theta = degrees(acos(cos_theta));
if(uv0.x>0.5)
{
theta = 360.0-theta;
}
float angle_threshold = u_progress*360.0;
if(theta<angle_threshold)
gl_FragColor = texture2D(u_texture_1,uv0);
else
gl_FragColor = texture2D(u_texture_0,uv0);
}