precision mediump float;

uniform sampler2D	texture_unit;
varying	vec2		texture_uv;		

uniform	vec2 	texel_size;									// set automatically by gfx engine
uniform	float	outline_size;// = 2;							// pixels, set by code

// 7x7 kernel basic 1 pass blur. 

void main()
{
	vec2 step_size = vec2(texel_size.x*outline_size, texel_size.y*outline_size);
	vec4 col = texture2D(texture_unit, vec2(texture_uv.x, texture_uv.y));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * -3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * -3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * -3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * -3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * -3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * -3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * -3)));
	
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * -2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * -2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * -2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * -2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * -2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * -2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * -2)));
	
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * -1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * -1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * -1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * -1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * -1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * -1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * -1)));
	
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * 0)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * 0)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * 0)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * 0)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * 0)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * 0)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * 0)));
	
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * 1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * 1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * 1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * 1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * 1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * 1)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * 1)));
	
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * 2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * 2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * 2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * 2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * 2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * 2)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * 2)));
	
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -3), texture_uv.y + (step_size.y * 3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -2), texture_uv.y + (step_size.y * 3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * -1), texture_uv.y + (step_size.y * 3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 0), texture_uv.y + (step_size.y * 3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 1), texture_uv.y + (step_size.y * 3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 2), texture_uv.y + (step_size.y * 3)));
	col += texture2D(texture_unit, vec2(texture_uv.x + (step_size.x * 3), texture_uv.y + (step_size.y * 3)));
	
	col /= 49.0;
	
    gl_FragColor = col;
}