struct fragment {
	float4 position  : POSITION;
	float4 color0    : COLOR0;
	float2 texcoord0 : TEXCOORD0;
};

struct pixel {
	float4 color0 : COLOR0;
};


pixel main(fragment IN, 
		   uniform sampler2D texture,
		   uniform sampler2D texture2)
{
	pixel OUT;



	float ox = 1.0 / 512.0;
	float oy = 1.0 / 256.0;


	
	float4 col = (tex2D(texture, IN.texcoord0) +
				  tex2D(texture, IN.texcoord0 + float2(-ox,   0)) +
				  tex2D(texture, IN.texcoord0 + float2( ox,   0)) +
				  tex2D(texture, IN.texcoord0 + float2(  0, -oy)) +
				  tex2D(texture, IN.texcoord0 + float2(  0,  oy)) +
				  tex2D(texture, IN.texcoord0 + float2(-ox, -oy)) +
				  tex2D(texture, IN.texcoord0 + float2( ox, oy)) + 
				  tex2D(texture, IN.texcoord0 + float2(-ox, oy)) +
				  tex2D(texture, IN.texcoord0 + float2( -ox, oy)));
	

	float x, y;
	//float4 col = (0,0,0,0);
	for (x=-3; x<4; x+=1) {
		col += tex2D(texture, IN.texcoord0 + float2(ox*x, 0));
	}

	for (y=-3; y<4; y+=1) {
		col += tex2D(texture, IN.texcoord0 + float2(0, oy*y));
	}

	col /= 23;

	float4 col2 = tex2D(texture2, IN.texcoord0);
	
	OUT.color0.r = col.r * col2.r;
	OUT.color0.g = col.g * col2.g;
	OUT.color0.b = col.b * col2.b;
	
	//OUT.color0 = col;
	OUT.color0.a = 1;




	return OUT;
}
