// Blur vertical and mix with tex1 (which contains original drawing)

struct VertOut
{
	float4 pos : POSITION;
	float4 col : COLOR0;
	float2 tc0 : TEXCOORD0;
};

struct FragOut
{
	float4 col : COLOR;
};

FragOut main(VertOut vin,
	uniform sampler2D tex0   : TEXUNIT0,
	uniform sampler2D texOrg : TEXUNIT1
      )
{
  FragOut fOut;

  float2 BlurOffset1    = float2( 0.00125,0 );
  float2 BlurOffset2    = float2( 0,0.0016667 );

  //float2 BlurOffset1    = float2( 0.0125,0 );
  //float2 BlurOffset2    = float2( 0,0.016667 );

  float PixelWeight[8] = { 0.2537, 0.2185, 0.0821, 0.0461, 0.0262, 0.0162, 0.0102, 0.0052 };
  float scaleTex=1.0;
  float stretchX=1.0;
  float stretchY=1.0;

  //float4 colorT = tex2D(tex0,vin.tc0);

  float4 color=0;

  for( int j = 0; j < 8; ++j )
  {
    color += tex2D(tex0, vin.tc0 + ( BlurOffset2 * j *stretchY) ) * PixelWeight[j]*scaleTex;
    color += tex2D(tex0, vin.tc0 - ( BlurOffset2 * j *stretchY) ) * PixelWeight[j]*scaleTex;
  }

  // Mix with original
  float4 colorT=tex2D(texOrg,vin.tc0);

  float4 baseCol=color*5.2+colorT*1.0;

  // Expose for HDR-like exposure control
  float exposure=-0.8;

  baseCol=1.0-exp(baseCol*exposure);

  fOut.col=baseCol;

  return fOut;
} 
