SepiaShader.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. console.warn( "THREE.SepiaShader: 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 alteredq / http://alteredqualia.com/
  4. *
  5. * Sepia tone shader
  6. * based on glfx.js sepia shader
  7. * https://github.com/evanw/glfx.js
  8. */
  9. THREE.SepiaShader = {
  10. uniforms: {
  11. "tDiffuse": { value: null },
  12. "amount": { value: 1.0 }
  13. },
  14. vertexShader: [
  15. "varying vec2 vUv;",
  16. "void main() {",
  17. " vUv = uv;",
  18. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  19. "}"
  20. ].join( "\n" ),
  21. fragmentShader: [
  22. "uniform float amount;",
  23. "uniform sampler2D tDiffuse;",
  24. "varying vec2 vUv;",
  25. "void main() {",
  26. " vec4 color = texture2D( tDiffuse, vUv );",
  27. " vec3 c = color.rgb;",
  28. " color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );",
  29. " color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );",
  30. " color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );",
  31. " gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );",
  32. "}"
  33. ].join( "\n" )
  34. };