//
// Bloom - basic functions
// RvG, 11-3-09
//

float4 BloomCombineMaps3_Colin(sampler2D bloomMap1,sampler2D bloomMap2,sampler2D bloomMap3,float2 tc)
//float4 BloomCombineMaps3(sampler2D bloomMap1,sampler2D bloomMap2,sampler2D bloomMap3,float2 tc)
// Takes 3 maps and combines the bloom.
// Returns the resulting mixed bloom color
// This one separates red/green/blue a bit to get an oldschool video look
{
  // Bloom additive
  //const float offset=0.00234375;
  const float offset=1.0/512.0;
  //const float offset=0;
  float4 bloom1,bloom2,bloom3,bloomColor,bj1,bj2,bj3;
  bj1=tex2D(bloomMap1,tc-offset);
  bloom1.r=bj1.r;
  bj1=tex2D(bloomMap1,tc);
  bloom1.g=bj1.g;
  bj1=tex2D(bloomMap1,tc+offset);
  bloom1.b=bj1.b;
  bloom1.a=bj1.a;

  bj2=tex2D(bloomMap2,tc-offset);
  bloom2.r=bj2.r;
  bj2=tex2D(bloomMap2,tc);
  bloom2.g=bj2.g;
  bj2=tex2D(bloomMap2,tc+offset);
  bloom2.b=bj2.b;
  bloom2.a=bj2.a;

  bj3=tex2D(bloomMap3,tc-offset);
  bloom3.r=bj3.r;
  bj3=tex2D(bloomMap3,tc);
  bloom3.g=bj3.g;
  bj3=tex2D(bloomMap3,tc+offset);
  bloom3.b=bj3.b;
  bloom3.a=bj3.a;
  
  //bloomColor=(bloom1+bloom2+bloom3)*0.5f;
  bloomColor=bloom1*1.0 +bloom2*2.0+bloom3*3.0f;
//  return bloom3;
  
  return bloomColor;
}

float4 BloomCombineMaps3(sampler2D bloomMap1,sampler2D bloomMap2,sampler2D bloomMap3,float2 tc)
// Takes 3 maps and combines the bloom.
// Returns the resulting mixed bloom color
{
  float4 bloom1,bloom2,bloom3;
  bloom1=tex2D(bloomMap1,tc);
  bloom2=tex2D(bloomMap2,tc); 
  bloom3=tex2D(bloomMap3,tc); 
  
  float4 bloomColor=bloom1*1.0+bloom2*1.0+bloom3*1.0;
//return bloom1;
  return bloomColor*33.33333;  // *0.5
}

float4 BloomMix(float4 sceneColor,float4 bloomColor)
// Mixes bloom in scene
{
  // Additive
  return sceneColor+bloomColor*bloomFactor;
}
