uniform sampler2D texture0;

void main()
{
	float threshold = mix (0.45, 0.5, gl_Color.a);
	
	vec2 outlineThickness = vec2(0.1,0.006);
	
	//Simple passthrough, outputs interpolated vertex colours.
	float mainTextStrength = texture2D(texture0, gl_TexCoord[0].xy).a;
	float outlineStrength = mainTextStrength;
	
	
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.0707,-0.0707) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2( 0.0707,-0.0707) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.0707, 0.0707) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2( 0.0707, 0.0707) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.1, 0.0) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2( 0.1, 0.0) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2( 0.0, 0.1) * outlineThickness).a);
	outlineStrength = max(outlineStrength, texture2D(texture0, gl_TexCoord[0].xy + vec2( 0.0,-0.1) * outlineThickness).a);
	//outlineStrength = clamp(outlineStrength * 1.5, 0.0, 1.0);
		
	gl_FragColor = vec4(mainTextStrength * gl_Color.rgb, outlineStrength * gl_Color.a);
	
}