uniform sampler2D Color0;
uniform sampler2D Color1;
uniform sampler2D Position;

//////////////////////////////////////////////////////////////////////////
// method to pack a f32 into an rgba8 from gamedev.net forums
//
// http://www.gamedev.net/community/forums/topic.asp?topic_id=463075
//
//////////////////////////////////////////////////////////////////////////

const vec4 bitSh = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);//

void main()
{
  // recover position from gbuffer
  //float depth  = 2000.0 * ( dot( bitSh, texture2D( Position, gl_TexCoord[0].st ) ) );//

  // darken effect
  //vec4 color = min( texture2D( Color0, gl_TexCoord[0].st ), texture2D( Color1, gl_TexCoord[0].st ) );
  
  // glow and std
  gl_FragColor = texture2D( Color0, gl_TexCoord[0].st ) + texture2D( Color1, gl_TexCoord[0].st );

  // glow effect
  //gl_FragColor = texture2D( Color1, gl_TexCoord[0].st );//color;//mix( color, texture2D( Color0, gl_TexCoord[0].st ), 0.5 );
  //
  // super out of focus
  //gl_FragColor = vec4( texture2D( Color1, gl_TexCoord[0].st ).xyz - texture2D( Color0, gl_TexCoord[0].st ).xyz, 1.0 );
  // punch up the warmth
  //gl_FragColor.rg *= vec2( 1.0, 1.0 );

  // just std!
  //gl_FragColor = texture2D( Color0, gl_TexCoord[0].st );

  // minimal glow and std
  //gl_FragColor = texture2D( Color0, gl_TexCoord[0].st ) + 0.3 * texture2D( Color1, gl_TexCoord[0].st );

 
  // focus power
  //gl_FragColor = vec4( texture2D( Color0, gl_TexCoord[0].st ).xyz - texture2D( Color1, gl_TexCoord[0].st ).xyz, 1.0 );
  
  /*
  // dof hack 
  float depth  = 20.0 * ( dot( bitSh, texture2D( Position, gl_TexCoord[0].st ) ) );
  depth = min( depth, 1.0 );
  //depth *= depth;
  vec4 glow = texture2D( Color1, gl_TexCoord[0].st );
  vec4 blur = vec4( glow.xyz - texture2D( Color0, gl_TexCoord[0].st ).xyz, 1.0 );
  gl_FragColor = mix( glow, blur, depth );
  //end dof hack
  */
  
  /*
  // dof hack pushed for edgeblurring? 
  float depth  = 30.0 * ( dot( bitSh, texture2D( Position, gl_TexCoord[0].st ) ) );
  depth = min( depth, 1.0 );
  depth *= depth;
  vec4 glow = texture2D( Color1, gl_TexCoord[0].st );
  vec4 blur = vec4( glow.xyz - texture2D( Color0, gl_TexCoord[0].st ).xyz, 1.0 );
  vec4 innerblur = mix( glow, blur, depth );
  gl_FragColor = vec4( glow.xyz - innerblur.xyz, 1.0 );
  //end dof hack
  */

  /*  
  //sharp to luma plus blur
  float luma = dot( vec3( .299, .587, .114 ), texture2D( Color0, gl_TexCoord[0].st ).xyz );
  vec4  glow = texture2D( Color1, gl_TexCoord[0].st );
  gl_FragColor = vec4( luma + glow.xyz, 1.0 );
  */

  /* 
  //sharp to luma plus blur
  float luma      = dot( vec3( .299, .587, .114 ), texture2D( Color0, gl_TexCoord[0].st ).xyz );
  vec4  greyscale = vec4( luma, luma, luma, 1.0 );
  vec4  glow      = texture2D( Color1, gl_TexCoord[0].st );
  vec4  standard  = texture2D( Color0, gl_TexCoord[0].st );
  // grey scale
  //gl_FragColor = greyscale;
  // nice sharp darks
  gl_FragColor = (greyscale + standard) * 0.5 + standard + luma * glow;
  // excessive glow???
  //gl_FragColor = 1000.0f * ( luma * luma * luma ) * glow + greyscale;
  */


}