float2 fullTexel;

texture gTextureSlot1;

sampler2D TextureSampler = 
sampler_state
{
    Texture = (gTextureSlot1);
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    ADDRESSU = CLAMP;
    ADDRESSV = CLAMP;
};

texture gTextureSlot2;

sampler2D TextureSampler2 = 
sampler_state
{
    Texture = (gTextureSlot2);
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    ADDRESSU = CLAMP;
    ADDRESSV = CLAMP;
};
 
struct VS_INPUT { 
    float4 Position : POSITION0; 
    float2 UV : TEXCOORD0; 
};

struct VS_OUTPUT { 
    float4 Position : POSITION0; 
    float2 UV : TEXCOORD0; 
};
 
VS_OUTPUT NullVertexShader(VS_INPUT IN) { 
    VS_OUTPUT Output;
    
    Output.Position = IN.Position; 
    Output.UV = IN.UV; 

    return Output; 
}; 
 
float4 psCopyArray(VS_OUTPUT IN):COLOR0
{
	return tex2D(TextureSampler,IN.UV);
}
 
technique CopyArray { 
    pass P0 { 
        VertexShader = compile vs_3_0 NullVertexShader(); 
        PixelShader = compile ps_3_0 psCopyArray(); 
    } 
}

float4 psBoxBlur3x3(VS_OUTPUT IN):COLOR0
{
	float4 comp = tex2D(TextureSampler,IN.UV);
	comp += tex2D(TextureSampler,IN.UV + fullTexel);
	comp += tex2D(TextureSampler,IN.UV - fullTexel);
	comp += tex2D(TextureSampler,IN.UV + float2(fullTexel.x,0.0));
	comp += tex2D(TextureSampler,IN.UV + float2(0.0,fullTexel.y));
	comp += tex2D(TextureSampler,IN.UV + float2(-fullTexel.x,0.0));
	comp += tex2D(TextureSampler,IN.UV + float2(0.0,-fullTexel.y));
	comp += tex2D(TextureSampler,IN.UV + float2(-fullTexel.x,fullTexel.y));
	comp += tex2D(TextureSampler,IN.UV + float2(fullTexel.x,-fullTexel.y));
	
	comp /= 9.0;
	
	return comp;
}
 
technique BoxBlur3x3 { 
    pass P0 { 
        VertexShader = compile vs_3_0 NullVertexShader(); 
        PixelShader = compile ps_3_0 psBoxBlur3x3(); 
    } 
}