Sepia.js 572 B

123456789101112131415161718192021222324
  1. import { dot, Fn, vec3, vec4 } from 'three/tsl';
  2. /**
  3. * Applies a sepia effect to the given color node.
  4. *
  5. * @tsl
  6. * @function
  7. * @param {Node<vec4>} color - The color node to apply the sepia for.
  8. * @return {Node<vec4>} The updated color node.
  9. */
  10. export const sepia = /*@__PURE__*/ Fn( ( [ color ] ) => {
  11. const c = vec3( color );
  12. // https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/sepia.js
  13. return vec4(
  14. dot( c, vec3( 0.393, 0.769, 0.189 ) ),
  15. dot( c, vec3( 0.349, 0.686, 0.168 ) ),
  16. dot( c, vec3( 0.272, 0.534, 0.131 ) ),
  17. color.a
  18. );
  19. } );