2
0

RGBShiftShader.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. console.warn( "THREE.RGBShiftShader: 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/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author felixturner / http://airtight.cc/
  4. *
  5. * RGB Shift Shader
  6. * Shifts red and blue channels from center in opposite directions
  7. * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
  8. * by Tom Butterworth / http://kriss.cx/tom/
  9. *
  10. * amount: shift distance (1 is width of input)
  11. * angle: shift angle in radians
  12. */
  13. THREE.RGBShiftShader = {
  14. uniforms: {
  15. "tDiffuse": { value: null },
  16. "amount": { value: 0.005 },
  17. "angle": { value: 0.0 }
  18. },
  19. vertexShader: [
  20. "varying vec2 vUv;",
  21. "void main() {",
  22. " vUv = uv;",
  23. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  24. "}"
  25. ].join( "\n" ),
  26. fragmentShader: [
  27. "uniform sampler2D tDiffuse;",
  28. "uniform float amount;",
  29. "uniform float angle;",
  30. "varying vec2 vUv;",
  31. "void main() {",
  32. " vec2 offset = amount * vec2( cos(angle), sin(angle));",
  33. " vec4 cr = texture2D(tDiffuse, vUv + offset);",
  34. " vec4 cga = texture2D(tDiffuse, vUv);",
  35. " vec4 cb = texture2D(tDiffuse, vUv - offset);",
  36. " gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
  37. "}"
  38. ].join( "\n" )
  39. };