#version 150

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

void main(void) {
	vec2 tc = qgl_FragTexture.xy;
	float r = float(radius);
	int o = radius, o2 = radius * 2;
	vec3 scol = (texture(t0, tc).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) / 29.;
	/*vec3 scol = (texelFetch(t0, tc, 0).rgb * 3. +
				 texelFetch(t0, tc + ivec2(  o,  0 ), 0).rgb * 2. +
				 texelFetch(t0, tc + ivec2(  0,  o ), 0).rgb * 2. +
				 texelFetch(t0, tc + ivec2( -o, 0  ), 0).rgb * 2. +
				 texelFetch(t0, tc + ivec2(  0,  -o), 0).rgb * 2. +
				 texelFetch(t0, tc + ivec2(  o,  o ), 0).rgb * 1.5 +
				 texelFetch(t0, tc + ivec2(  o,  -o), 0).rgb * 1.5 +
				 texelFetch(t0, tc + ivec2( -o, -o ), 0).rgb * 1.5 +
				 texelFetch(t0, tc + ivec2( -o, o  ), 0).rgb * 1.5 +
				 texelFetch(t0, tc + ivec2( o2,  0 ), 0).rgb +
				 texelFetch(t0, tc + ivec2(  0,  o2), 0).rgb +
				 texelFetch(t0, tc + ivec2(-o2, 0  ), 0).rgb +
				 texelFetch(t0, tc + ivec2(  0, -o2), 0).rgb +
				 texelFetch(t0, tc + ivec2( o2,  o ), 0).rgb +
				 texelFetch(t0, tc + ivec2( o2,  -o), 0).rgb +
				 texelFetch(t0, tc + ivec2(-o2, -o ), 0).rgb +
				 texelFetch(t0, tc + ivec2(-o2, o  ), 0).rgb +
				 texelFetch(t0, tc + ivec2(  o,  o2), 0).rgb +
				 texelFetch(t0, tc + ivec2(  o, -o2), 0).rgb +
				 texelFetch(t0, tc + ivec2( -o, -o2), 0).rgb +
				 texelFetch(t0, tc + ivec2( -o,  o2), 0).rgb) / 29.;*/
	qgl_FragData[0].rgb = scol;
	//qgl_FragData[0].rgb = vec3(r/10.);
}
