1uniform mat4 u_Color;
2varying vec2 v_TexCoord;
3varying vec2 v_TexCoord2;
4varying vec2 v_TexCoord3;
5varying vec2 v_Position;
6uniform sampler2D u_Tex0;
7uniform float u_Time;
8uniform vec2 u_Resolution;
9
10// CONFIG
11float speed = 10.0;
12float height = 10.0;
13float angle = 45.0; // degrees
14float intensity = 2.0;
15// CONFIG END
16
17vec2 rotate(vec2 v, float a) {
18 float s = sin(a);
19 float c = cos(a);
20 mat2 m = mat2(c, -s, s, c);
21 return m * v;
22}
23
24void main()
25{
26 gl_FragColor = texture2D(u_Tex0, v_TexCoord);
27 vec4 texcolor = texture2D(u_Tex0, v_TexCoord2);
28 vec4 texcolor2 = texture2D(u_Tex0, v_TexCoord3);
29 if(texcolor.r > 0.9) {
30 gl_FragColor *= texcolor.g > 0.9 ? u_Color[0] : u_Color[1];
31 } else if(texcolor.g > 0.9) {
32 gl_FragColor *= u_Color[2];
33 } else if(texcolor.b > 0.9) {
34 gl_FragColor *= u_Color[3];
35 }
36
37 vec4 col;
38 col.r = sin(.6 * (v_TexCoord.y * 150.0) + u_Time * 5. + 0.) * 0.5 + 0.5;
39 col.g = sin(.6 * (v_TexCoord.y * 150.0) + u_Time * 5. + 2.) * 0.5 + 0.5;
40 col.b = sin(.6 * (v_TexCoord.y * 150.0) + u_Time * 5. + 4.) * 0.5 + 0.5;
41 col.a = 1.0;
42
43 if(gl_FragColor.a < 0.01) {
44 if(texcolor2.a > 0.01) {
45 vec2 p = rotate(v_Position, (angle / 180.0) * 3.14);
46 float frame = mod(p.y, height);
47 float timeFrame = mod(u_Time * speed, height);
48 float dist = min(abs(frame - timeFrame), min(abs(frame - timeFrame - height), abs(frame - timeFrame + height)));
49 gl_FragColor.xyz *= intensity / sqrt(max(2.0, dist));
50 gl_FragColor = col;
51 } else {
52 discard;
53 }
54 }
55}