//The Bonk BLUR-Shader PIXEL

// maximum size supported by this shader
const int MaxKernelSize = 50;
// size of kernel (width * height) for this execution
uniform int KernelSize;

// array of offsets for accessing the base image
uniform vec2 Offset[MaxKernelSize];
// array of kernel values
uniform float KernelValues[MaxKernelSize];


// image to be convolved
uniform sampler2D BaseImage;


void main()
{

    int i;
    vec4 sum = vec4(0.0);

    for (i = 0; i < KernelSize; i++)
    {
        vec4 tmp1 = texture2D(BaseImage, gl_TexCoord[0].st + Offset[i] );
        vec4 tmp2 = texture2D(BaseImage, gl_TexCoord[0].st - Offset[i] );
        vec4 Kernel = vec4(KernelValues[i],KernelValues[i],KernelValues[i],KernelValues[i]);
        sum += Kernel *tmp1;
        sum += Kernel *tmp2;  
    }

    gl_FragColor = sum;
}