uniform sampler2D Color0;

const float offsetx = 1.0 / 1024.0;
const float offsety = 1.0 / 768.0;

void main()
{
  vec3 c0 = texture2D( Color0, gl_TexCoord[1].st ).rgb;
  vec3 c1 = texture2D( Color0, gl_TexCoord[2].st ).rgb;
  vec3 c2 = texture2D( Color0, gl_TexCoord[3].st ).rgb;
  vec3 c3 = texture2D( Color0, gl_TexCoord[4].st ).rgb;
  /*vec3 c12 = texture2D( Color0, gl_TexCoord[5].st ).rgb;
  vec3 c20 = texture2D( Color0, gl_TexCoord[6].st ).rgb;
  vec3 c21 = texture2D( Color0, gl_TexCoord[7].st ).rgb;
  vec3 c22 = texture2D( Color0, gl_TexCoord[0].st + vec2( offsetx, offsety ) ).rgb;*/

  vec3 sx = c0 - c3;
  vec3 sy = c1 - c2;

  // convert to grey scale
  vec3 se = abs(sx) + abs(sy);
  float sef = dot( se, vec3( .299, .587, .114 ) ); 
  vec3 color = texture2D( Color0, gl_TexCoord[0].st ).rgb;
  // scale
  float scale = 0.25;
  sef = scale * sef;
  //color += vec3( sef, sef, sef );

  gl_FragColor = vec4( color, 1.0 );
}
