TechnicolorShader.js 898 B

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