HalftoneShader.js 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @author meatbags / xavierburrow.com, github/meatbags
  3. *
  4. * Colour halftone shader
  5. */
  6. THREE.HalftoneShader = {
  7. uniforms: {
  8. "tDiffuse": {value: null},
  9. "radius": {value: 5},
  10. "rC": {value: Math.PI * 0.25},
  11. "rM": {value: Math.PI * 0.33},
  12. "rY": {value: Math.PI * 0.66},
  13. "shape": {value: 1},
  14. "width": {value: 1},
  15. "height": {value: 1}
  16. },
  17. vertexShader: `
  18. varying vec2 vUv;
  19. void main() {
  20. vUv = uv;
  21. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  22. }`,
  23. fragmentShader: `
  24. varying vec2 vUv;
  25. uniform sampler2D tDiffuse;
  26. uniform float radius;
  27. uniform float rC;
  28. uniform float rY;
  29. uniform float rM;
  30. uniform float width;
  31. uniform float height;
  32. float rand(vec2 seed){
  33. return fract(sin(dot(seed.xy, vec2(12.9898,78.233))) * 43758.5453);
  34. }
  35. vec2 gridReference(vec2 coord, float step, float rotation) {
  36. return vec2(0, 0);
  37. }
  38. void main() {
  39. vec4 color = texture2D(tDiffuse, vUv);
  40. gl_FragColor = color;
  41. }`
  42. };