TechnicolorShader.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @module TriangleBlurShader
  3. * @three_import import { TriangleBlurShader } from 'three/addons/shaders/TriangleBlurShader.js';
  4. */
  5. /**
  6. * Simulates the look of the two-strip technicolor process popular in early 20th century films.
  7. * More historical info here: {@link http://www.widescreenmuseum.com/oldcolor/technicolor1.htm}
  8. * Demo here: {@link http://charliehoey.com/technicolor_shader/shader_test.html}
  9. *
  10. * @constant
  11. * @type {ShaderMaterial~Shader}
  12. */
  13. const TechnicolorShader = {
  14. name: 'TechnicolorShader',
  15. uniforms: {
  16. 'tDiffuse': { value: null }
  17. },
  18. vertexShader: /* glsl */`
  19. varying vec2 vUv;
  20. void main() {
  21. vUv = uv;
  22. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  23. }`,
  24. fragmentShader: /* glsl */`
  25. uniform sampler2D tDiffuse;
  26. varying vec2 vUv;
  27. void main() {
  28. vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );
  29. vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);
  30. gl_FragColor = newTex;
  31. }`
  32. };
  33. export { TechnicolorShader };
粤ICP备19079148号