outfit_glow.frag

main 46 lines · 1.8 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_TexCoord3;
5varying vec2 v_Position;
6uniform sampler2D u_Tex0;
7uniform float u_Time;
8uniform vec2 u_Resolution;
9
10vec3 outline_color = vec3(0.0, 1.0, 1.5);
11float outline_alpha = 0.75;
12float outline_color_threshold = 2.5;
13float outline_thickness = 0.02;
14
15void main()
16{
17 gl_FragColor = texture2D(u_Tex0, v_TexCoord);
18 vec4 texcolor = texture2D(u_Tex0, v_TexCoord2);
19 vec4 texcolor2 = texture2D(u_Tex0, v_TexCoord3);
20
21 if (texcolor.r > outline_color_threshold) {
22 if (texcolor.g > outline_color_threshold) {
23 gl_FragColor *= u_Color[0]; // Apply outline_color if both R and G channels exceed the threshold
24 } else {
25 gl_FragColor *= u_Color[1]; // Apply outline_color if only R channel exceeds the threshold
26 }
27 } else if (texcolor.g > outline_color_threshold) {
28 gl_FragColor *= u_Color[2]; // Apply outline_color if only G channel exceeds the threshold
29 } else if (texcolor.b > outline_color_threshold) {
30 gl_FragColor *= u_Color[3]; // Apply outline_color if only B channel exceeds the threshold
31 }
32 // Check alpha threshold and apply outline effect
33 if (gl_FragColor.a < 0.01) {
34 if (texcolor2.a > 0.01) {
35 // Apply outline effect with specified parameters
36 float outlineAnimation = abs(0.5 - mod(u_Time, 1.0));
37 float outlineWidth = smoothstep(outline_thickness, outline_thickness + 0.01, length(v_Position));
38 vec3 outlineColor = mix(gl_FragColor.rgb, outline_color, outlineWidth * outlineAnimation);
39 gl_FragColor = vec4(outlineColor, 1.0);
40 gl_FragColor.a *= outline_alpha;
41 } else {
42 discard; // Discard fragments below the alpha threshold
43 }
44 }
45}
46
Top