outfit_line_fragment.frag

main 42 lines · 1.1 KB Raw
Alex Alex Commit Client Upload Part 1 19/10/2026 00:04
1uniform mat4 u_Color;
2varying vec2 v_TexCoord;
3varying vec2 v_TexCoord2;
4varying vec2 v_Position;
5uniform sampler2D u_Tex0;
6uniform float u_Time;
7
8// CONFIG
9float speed = 4.0;
10float height = 12.0;
11float angle = 50.0; // degrees
12float intensity = 2.0;
13// CONFIG END
14
15vec2 rotate(vec2 v, float a) {
16 float s = sin(a);
17 float c = cos(a);
18 mat2 m = mat2(c, -s, s, c);
19 return m * v;
20}
21
22void main()
23{
24 gl_FragColor = texture2D(u_Tex0, v_TexCoord);
25 vec4 texcolor = texture2D(u_Tex0, v_TexCoord2);
26 if(texcolor.r > 0.9) {
27 gl_FragColor *= texcolor.g > 0.9 ? u_Color[0] : u_Color[1];
28 } else if(texcolor.g > 0.9) {
29 gl_FragColor *= u_Color[2];
30 } else if(texcolor.b > 0.9) {
31 gl_FragColor *= u_Color[3];
32 }
33
34 if(texcolor.a > 0.9) {
35 vec2 p = rotate(v_Position, (angle / 180.0) * 3.14);
36 float frame = mod(p.y, height);
37 float timeFrame = mod(u_Time * speed, height);
38 float dist = min(abs(frame - timeFrame), min(abs(frame - timeFrame - height), abs(frame - timeFrame + height)));
39 gl_FragColor.xyz *= intensity / sqrt(max(1.0, dist));
40 }
41 if(gl_FragColor.a < 0.01) discard;
42}
Top