//by soulkito http://www.reddit.com/r/gamedev/comments/271ljs/how_do_i_achieve_a_sin_city_look_using_a_hlsl/
precision mediump float;

varying vec2 vTexCoord;

uniform sampler2D u_texture;

uniform float smoothness;
uniform float sensitivity;

void main(void)
{
  vec4 inputTexture = texture2D(u_texture, vTexCoord.xy);

  float notRed = (inputTexture.g + inputTexture.b);
  float threshold = smoothstep(notRed - smoothness, notRed + smoothness, inputTexture.r);

  // Compare the threshold with the sensitivity
  if(threshold > sensitivity) 
  {
      // output red
      gl_FragColor = vec4(inputTexture.r, 0.0, 0.0, 1.0);
  }
  else 
  {
      // output gray
      float grayscale = inputTexture.r * 0.299 + inputTexture.g * 0.587 + inputTexture.b * 0.114;  
      gl_FragColor = vec4(grayscale, grayscale, grayscale, 1.0);
  }
}