HalftoneShader.js 653 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @author meatbags / http://xavierburrow.com/
  3. *
  4. * Colour halftone shader
  5. */
  6. THREE.HalftoneShader = {
  7. uniforms: {
  8. "tDiffuse": {value: null},
  9. "iSize": {value: 1}
  10. },
  11. vertexShader: `
  12. varying vec2 vUv;
  13. void main() {
  14. vUv = uv;
  15. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  16. }`,
  17. fragmentShader: `
  18. uniform sampler2D tDiffuse;
  19. uniform int size;
  20. varying vec2 vUv;
  21. float rand(vec2 seed){
  22. return fract(sin(dot(seed.xy, vec2(12.9898,78.233))) * 43758.5453);
  23. }
  24. void main() {
  25. vec4 color = texture2D(tDiffuse, vUv);
  26. color.r += rand(vUv) * 0.1;
  27. gl_FragColor = color;
  28. }`
  29. };