HalftoneShader.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. "rSample": {value: Math.PI * 0.25},
  11. "rC": {value: Math.PI * 0.25},
  12. "rM": {value: Math.PI * 0.33},
  13. "rY": {value: Math.PI * 0.66},
  14. "shape": {value: 1},
  15. "width": {value: 1},
  16. "height": {value: 1}
  17. },
  18. vertexShader: `
  19. varying vec2 vUv;
  20. void main() {
  21. vUv = uv;
  22. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  23. }`,
  24. fragmentShader: `
  25. varying vec2 vUv;
  26. uniform sampler2D tDiffuse;
  27. uniform float radius;
  28. uniform float rSample;
  29. uniform float rC;
  30. uniform float rY;
  31. uniform float rM;
  32. uniform float width;
  33. uniform float height;
  34. float rand(vec2 seed){
  35. return fract(sin(dot(seed.xy, vec2(12.9898,78.233))) * 43758.5453);
  36. }
  37. vec2 gridReference(vec2 coord, float step, float rotation) {
  38. return vec2(0, 0);
  39. }
  40. void main() {
  41. vec4 color = texture2D(tDiffuse, vUv);
  42. gl_FragColor = color;
  43. }`
  44. };