//
// HDR+bloom
// RvG, 10-3-09
//

#include "../common/constants.cg"
#include "../common/hdr.cg"
#include "bloom.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=tex2D(sceneMap,vin.tc0); 

  float4 bloomColor;  
  bloomColor=BloomCombineMaps3(bloomMap1,bloomMap2,bloomMap3,vin.tc0);
//  float4 color=BloomMix(sceneColor,bloomColor);
float4 color=sceneColor;
//color=tex2D(bloomMap1,vin.tc0);

  //const float exposure=1.0;
  fout.col=ToneMapHDR(color,exposure);
//fout.col=tex2D(bloomMap3,vin.tc0);

  return fout;
} 
