//
// Fragment shader for HDR mirror
// HDR -> LDR, no bloom
// 10-08-10: Created
// 06-01-11: Added color grading
// (c) 2010-2011 Cruden B.V.
//

#include "../common/constants.cg"
#include "../common/hdr.cg"
#include "../common/utils.cg"
#include "bloom.cg"
#include "common_fs.cg"

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

struct FragOut
{
  float4 col : COLOR;
};

FragOut main(
  VertOut vin,
  uniform sampler2D tex0     : TEXUNIT0,
  uniform sampler3D gradeMap : TEXUNIT6,
  uniform float exposure
)
{
  FragOut fout;
  float4 color;
  
  color=tex2D(tex0,vin.tc0);
  
  // HDR -> LDR tonemap
  //fout.col=Desaturate(ToneMapHDR(color,exposure),0.2);
  color.rgb=ToneMapHDR(color,exposure);
  
  color.rgb=ColorGrade(color.rgb,gradeMap);
  
  fout.col=color;
 
//fout.col=0.5f;
  return fout;
} 
