TechnicolorShader.js 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Technicolor Shader
  3. * Simulates the look of the two-strip technicolor process popular in early 20th century films.
  4. * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm
  5. * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html
  6. */
  7. const TechnicolorShader = {
  8. uniforms: {
  9. 'tDiffuse': { value: null }
  10. },
  11. vertexShader: /* glsl */`
  12. varying vec2 vUv;
  13. void main() {
  14. vUv = uv;
  15. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  16. }`,
  17. fragmentShader: /* glsl */`
  18. uniform sampler2D tDiffuse;
  19. varying vec2 vUv;
  20. void main() {
  21. vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );
  22. vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);
  23. gl_FragColor = newTex;
  24. }`
  25. };
  26. export { TechnicolorShader };