//
// 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 bloomMap1   : TEXUNIT2,
  uniform sampler2D bloomMap2   : TEXUNIT3,
  uniform sampler2D bloomMap3   : TEXUNIT4,
  uniform float exposure
)
{
  FragOut fout;

  // Scene texel
  float4 sceneColor=MotionBlur(sceneMap,velocityMap,vin.tc0,1024.0,768.0);
  
  // Bloom
  float4 bloomColor;  
  bloomColor=BloomCombineMaps3(bloomMap1,bloomMap2,bloomMap3,vin.tc0);
  float4 color=BloomMix(sceneColor,bloomColor);

color=tex2D(velocityMap,vin.tc0);

  //const float exposure=1.0;
  fout.col.rgb=ToneMapHDR(color,exposure);
  fout.col.a=1;

  return fout;
} 
