/*
 * Posterize Shader
 * http://www.geeks3d.com/20091027/shader-library-posterization-post-processing-effect-glsl/
 * 
 * textureId (sampler2D): 	the texture id buffer.
 * numColors (float): 		number of tone regions. 	Default=8.0
 * gamma (float): 			gamma factor. 				Default=0.6
 */
uniform sampler2D textureId; // 0
uniform float gamma; // 0.6
uniform float numColors; // 8.0
void main (void)
{ 
  vec3 c = texture2D(textureId, gl_TexCoord[0].xy).rgb;
  c = pow(c, vec3(gamma, gamma, gamma));
  c = c * numColors;
  c = floor(c);
  c = c / numColors;
  c = pow(c, vec3(1.0/gamma));
  gl_FragColor = vec4(c, 1.0);
}