//
// HDR+bloom+motion blur
// Post-processing filter.
// RvG, 11-3-09
//

#include "../common/hdr.cg"
#include "bloom.cg"
#include "motion_blur.cg"
#include "common_fs.cg"

struct VertOut
{
	float2 tc0 : TEXCOORD0;
};

struct FragOut
{
	float4 col : COLOR;
};

FragOut main(
  VertOut vin,
	uniform sampler2D sceneMap    : TEXUNIT0,
	uniform sampler2D velocityMap : TEXUNIT1,
	uniform sampler2D bloomMap    : TEXUNIT2,
  uniform float exposure
)
{
  FragOut fout;

  // Scene texel
  float4 sceneColor=MotionBlur2(sceneMap,velocityMap,vin.tc0,1024.0,768.0);
  // Bloom additive
  float4 bloomColor=tex2D(bloomMap,vin.tc0); 

  float4 color;
  
  color=BloomMix(sceneColor,bloomColor);
  
/*
  // Vignette
  float2 texCoord=vin.tc0;
  texCoord-=0.5;
  float vignette=1.0-dot(texCoord,texCoord);
  //vignette=pow(vignette,2);//determint vignette amount,should take into account FOV,etc.
  vignette*=vignette;
  color*=vignette;
*/
  
  fout.col=ToneMapHDR(color,exposure);

  return fout;
} 
