posterization.fs 601 B

1234567891011121314151617181920212223242526272829
  1. #version 100
  2. precision mediump float;
  3. // Input vertex attributes (from vertex shader)
  4. varying vec2 fragTexCoord;
  5. varying vec4 fragColor;
  6. // Input uniform values
  7. uniform sampler2D texture0;
  8. uniform vec4 colDiffuse;
  9. // NOTE: Add here your custom variables
  10. float gamma = 0.6;
  11. float numColors = 8.0;
  12. void main()
  13. {
  14. vec3 color = texture2D(texture0, fragTexCoord.xy).rgb;
  15. color = pow(color, vec3(gamma, gamma, gamma));
  16. color = color*numColors;
  17. color = floor(color);
  18. color = color/numColors;
  19. color = pow(color, vec3(1.0/gamma));
  20. gl_FragColor = vec4(color, 1.0);
  21. }