#version 150

uniform sampler2D t0;
uniform float radius = 2;
uniform vec2 dt;

void main(void) {
	vec2 tc = qgl_FragTexture.xy;
	float r = float(radius);
	vec4 v0 = texture(t0, tc);
	float rad;
	float coeff = modf(v0.w, rad) * 1.1;
	rad /= 10.;
	rad *= 2;
	float o = radius * rad, o2 = radius * rad * 2;
	vec3 scol = (v0.rgb * 3. +
				 texture(t0, tc + dt * vec2(  o,  0 )).rgb * 2. +
				 texture(t0, tc + dt * vec2(  0,  o )).rgb * 2. +
				 texture(t0, tc + dt * vec2( -o, 0  )).rgb * 2. +
				 texture(t0, tc + dt * vec2(  0,  -o)).rgb * 2. +
				 texture(t0, tc + dt * vec2(  o,  o )).rgb * 1.5 +
				 texture(t0, tc + dt * vec2(  o,  -o)).rgb * 1.5 +
				 texture(t0, tc + dt * vec2( -o, -o )).rgb * 1.5 +
				 texture(t0, tc + dt * vec2( -o, o  )).rgb * 1.5 +
				 texture(t0, tc + dt * vec2( o2,  0 )).rgb +
				 texture(t0, tc + dt * vec2(  0,  o2)).rgb +
				 texture(t0, tc + dt * vec2(-o2, 0  )).rgb +
				 texture(t0, tc + dt * vec2(  0, -o2)).rgb/* +
				 texture(t0, tc + dt * vec2( o2,  o )).rgb +
				 texture(t0, tc + dt * vec2( o2,  -o)).rgb +
				 texture(t0, tc + dt * vec2(-o2, -o )).rgb +
				 texture(t0, tc + dt * vec2(-o2, o  )).rgb +
				 texture(t0, tc + dt * vec2(  o,  o2)).rgb +
				 texture(t0, tc + dt * vec2(  o, -o2)).rgb +
				 texture(t0, tc + dt * vec2( -o, -o2)).rgb +
				 texture(t0, tc + dt * vec2( -o,  o2)).rgb*/) / 21.;
	qgl_FragData[0] = vec4(scol, v0.w);
}
