Ah, apologies, this is what it looks like:
Here’s the code:
varying mediump vec2 var_texcoord0; // position of sprite colour coordinates
uniform lowp sampler2D texture_sampler; // colour of sprite
uniform lowp vec4 tint; // stores applied sprite colour
uniform lowp vec4 border_width; // stores outline width and state (x and y)
uniform lowp vec4 outline_tint; // stores applied outline colour
uniform lowp vec4 blink_trigger; // stores blinking state
uniform lowp vec4 blink_tint; // stores applied blink colour
void main()
{
// write a color of the current fragment to a variable (lowp = low precision)
lowp vec4 tint_applied = vec4(tint.xyz * tint.w, tint.w); // default sprite tint
lowp vec4 colour_of_pixel = texture2D(texture_sampler, var_texcoord0.xy); // initial pixel colour
lowp vec4 outline_tint = vec4(outline_tint.xyz * outline_tint.w, outline_tint.w); // colour on outline
lowp vec3 border_width = vec3(border_width.r,border_width.g,border_width.b);
lowp vec4 blink_tint = vec4(blink_tint.xyz * blink_tint.w, blink_tint.w); // colour on blink
if((blink_trigger.r == 1.0) && (colour_of_pixel.a != 0.0))
{
colour_of_pixel = vec4(blink_tint.xyz * blink_tint.a * colour_of_pixel.a, blink_tint.a * colour_of_pixel.a); // apply blink colour
} else {
if(colour_of_pixel.a >= 0.5) {
colour_of_pixel = colour_of_pixel * tint_applied; // apply base colour
} else { // Important code starts here
if ((texture2D(texture_sampler, vec2(var_texcoord0.x + border_width.x, var_texcoord0.y)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x - border_width.x, var_texcoord0.y)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x, var_texcoord0.y + border_width.z)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x, var_texcoord0.y - border_width.z)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x + border_width.x, var_texcoord0.y + border_width.z)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x + border_width.x, var_texcoord0.y - border_width.z)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x - border_width.x, var_texcoord0.y + border_width.z)).a != 0.0
|| texture2D(texture_sampler, vec2(var_texcoord0.x - border_width.x, var_texcoord0.y - border_width.z)).a != 0.0)) // Important code ends here
{
if (colour_of_pixel.a >= 0.25) {
colour_of_pixel = colour_of_pixel * vec4(outline_tint.xyz*border_width.y, border_width.y) * tint_applied;
} else {
colour_of_pixel = vec4(outline_tint.xyz*border_width.y, border_width.y);
}
} else {
colour_of_pixel = vec4(0.0,0.0,0.0,0.0);
}
}
}
gl_FragColor = colour_of_pixel; // write the colour_of_pixel to the output gl_FragColor
}
Some of this code is (quite obviously) taken from the fragment program tutorial. The important code has been marked.