uniform mat4 u_Color; varying vec2 v_TexCoord; varying vec2 v_TexCoord2; varying vec2 v_TexCoord3; varying vec2 v_Position; uniform sampler2D u_Tex0; uniform float u_Time; uniform vec2 u_Resolution; vec3 outline_color = vec3(0.0, 1.0, 1.5); float outline_alpha = 0.75; float outline_color_threshold = 2.5; float outline_thickness = 0.02; void main() { gl_FragColor = texture2D(u_Tex0, v_TexCoord); vec4 texcolor = texture2D(u_Tex0, v_TexCoord2); vec4 texcolor2 = texture2D(u_Tex0, v_TexCoord3); if (texcolor.r > outline_color_threshold) { if (texcolor.g > outline_color_threshold) { gl_FragColor *= u_Color[0]; // Apply outline_color if both R and G channels exceed the threshold } else { gl_FragColor *= u_Color[1]; // Apply outline_color if only R channel exceeds the threshold } } else if (texcolor.g > outline_color_threshold) { gl_FragColor *= u_Color[2]; // Apply outline_color if only G channel exceeds the threshold } else if (texcolor.b > outline_color_threshold) { gl_FragColor *= u_Color[3]; // Apply outline_color if only B channel exceeds the threshold } // Check alpha threshold and apply outline effect if (gl_FragColor.a < 0.01) { if (texcolor2.a > 0.01) { // Apply outline effect with specified parameters float outlineAnimation = abs(0.5 - mod(u_Time, 1.0)); float outlineWidth = smoothstep(outline_thickness, outline_thickness + 0.01, length(v_Position)); vec3 outlineColor = mix(gl_FragColor.rgb, outline_color, outlineWidth * outlineAnimation); gl_FragColor = vec4(outlineColor, 1.0); gl_FragColor.a *= outline_alpha; } else { discard; // Discard fragments below the alpha threshold } } }