PixelShader.js 995 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. console.warn( "THREE.PixelShader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
  2. /**
  3. * Pixelation shader
  4. */
  5. THREE.PixelShader = {
  6. uniforms: {
  7. "tDiffuse": { value: null },
  8. "resolution": { value: null },
  9. "pixelSize": { value: 1. },
  10. },
  11. vertexShader: [
  12. "varying highp vec2 vUv;",
  13. "void main() {",
  14. "vUv = uv;",
  15. "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  16. "}"
  17. ].join( "\n" ),
  18. fragmentShader: [
  19. "uniform sampler2D tDiffuse;",
  20. "uniform float pixelSize;",
  21. "uniform vec2 resolution;",
  22. "varying highp vec2 vUv;",
  23. "void main(){",
  24. "vec2 dxy = pixelSize / resolution;",
  25. "vec2 coord = dxy * floor( vUv / dxy );",
  26. "gl_FragColor = texture2D(tDiffuse, coord);",
  27. "}"
  28. ].join( "\n" )
  29. };