// force vc7 to group all shader related stuff into the Shader namespace
#ifdef WIN32
namespace Shader {
#endif

// define inputs from vertex program
struct in_fragment
{
  float4 texCoord0 : TEXCOORD0;
  float4 texCoord1 : TEXCOORD1;
};

// define outputs from fragment program
struct out_fragment
{
	float4 color : COLOR0;
};

// fragment program
out_fragment main(
		// varying parameters
	  in_fragment f_in,

	  // uniform samplers (textures)
	  uniform sampler2D   diffuseMap  : TEXUNIT0,
    uniform sampler2D   diffuseMap_small  : TEXUNIT1
		
		// maybe more uniform parameters fed from the application
		//uniform float3 someParameter
		)
{
  out_fragment f_out;
  
  float3 gaussianBlur[3] =
  {
    float3(0.045f,0.122f,0.045f),
    float3(0.122f,0.332f,0.122f),
    float3(0.045f,0.122f,0.045f)
  };
  float pixelSize = 0.015625/2;//*1.5; // 1/64

  float2 modTex = f_in.texCoord1.xy;

  f_out.color = float4(0,0,0,0);

  modTex = f_in.texCoord1.xy;

  modTex.x = f_in.texCoord1.x - pixelSize;
  float4 blurColor = 0.2 * tex2D(diffuseMap_small, modTex);
  modTex.x = f_in.texCoord1.x + pixelSize;
  blurColor += 0.2 * tex2D(diffuseMap_small, modTex);
  modTex.x = f_in.texCoord1.x;

  blurColor += 0.2 * tex2D(diffuseMap_small, modTex);
  modTex.y = f_in.texCoord1.y - pixelSize;
  blurColor += 0.2 * tex2D(diffuseMap_small, modTex);
  modTex.y = f_in.texCoord1.y + pixelSize;
  blurColor += 0.2 * tex2D(diffuseMap_small, modTex);

  f_out.color = tex2D(diffuseMap, f_in.texCoord0.xy);
  //if(blurColor.r > 0.5)
  //blurColor *= 0.75;
  float mod = tex2D(diffuseMap_small, f_in.texCoord1.xy).a;
  f_out.color += blurColor * 0.7;//mod;
  //f_out.color *= 0.66;

  return f_out;

  // upper left
  /*float4 blurColor = 0.045 * tex2D(diffuseMap_small, modTex);
  // upper
  modTex.x += pixelSize;
  blurColor += 0.122 * tex2D(diffuseMap_small, modTex);
  // upper right
  modTex.x += pixelSize;
  blurColor += 0.045 * tex2D(diffuseMap_small, modTex);
  // center right
  modTex.y += pixelSize;
  blurColor += 0.122 * tex2D(diffuseMap_small, modTex);
  // center
  modTex.x -= pixelSize;
  blurColor += 0.332f * tex2D(diffuseMap_small, modTex);*/
  // center left
  /*modTex.x -= pixelSize;
  blurColor += 0.122f * tex2D(diffuseMap_small, modTex);
  // lower left
  modTex.y += pixelSize;
  blurColor += 0.045 * tex2D(diffuseMap_small, modTex);
  // lower center
  modTex.x += pixelSize;
  blurColor += 0.122 * tex2D(diffuseMap_small, modTex);
  // lower right
  modTex.x += pixelSize;
  blurColor += 0.045 * tex2D(diffuseMap_small, modTex);
  

  f_out.color = blurColor;

  return f_out;*/
}

#ifdef WIN32
}
#endif

