The Threshold Effect

Thresholding is a common image processing effect for binarizing an image: converting it to one-bit color. It's one of Photoshop's basic image adjustments.

function main()
  ctexture2d(colorTexture, fragmentTexCoord).rgb
  ddot(c, vec3(0.213, 0.715, 0.072))
  if d > 0.5
    gl_FragColorvec4(1.0, 1.0, 1.0, 1.0)
    gl_FragColorvec4(0.0, 0.0, 0.0, 1.0)

If the luminance of the input is greater than some cutoff value, then the output is white. Otherwise, black. This cutoff value can easily be parameterized using a uniform.