#include "OgreUnifiedShader.h"

SAMPLER2D(inRTT, 0);
uniform vec2 texelSize;

MAIN_PARAMETERS
IN(vec2 oUv0, TEXCOORD0)
MAIN_DECLARATION
{
    vec4 accum = vec4(0.0, 0.0, 0.0, 0.0);

    // Get colour from source
    accum += texture2D(inRTT, oUv0 + texelSize * vec2(-1.0, -1.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2( 0.0, -1.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2( 1.0, -1.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2(-1.0,  0.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2( 0.0,  0.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2( 1.0,  0.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2(-1.0,  1.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2( 0.0,  1.0));
    accum += texture2D(inRTT, oUv0 + texelSize * vec2( 1.0,  1.0));

	// take average of 9 samples
	accum *= 0.1111111111111111;

	gl_FragColor = accum;

}
