diff --git a/src/nodes/Nodes.js b/src/nodes/Nodes.js index b7439ab67a7bce..4e3da7aaa49611 100644 --- a/src/nodes/Nodes.js +++ b/src/nodes/Nodes.js @@ -141,6 +141,7 @@ export { default as BloomNode, bloom } from './display/BloomNode.js'; export { default as TransitionNode, transition } from './display/TransitionNode.js'; export { default as RenderOutputNode, renderOutput } from './display/RenderOutputNode.js'; export { default as PixelationPassNode, pixelationPass } from './display/PixelationPassNode.js'; +export { sepia } from './display/SepiaNode.js'; export { default as PassNode, pass, passTexture, depthPass } from './display/PassNode.js'; diff --git a/src/nodes/display/SepiaNode.js b/src/nodes/display/SepiaNode.js new file mode 100644 index 00000000000000..f4716ce4bd2ddd --- /dev/null +++ b/src/nodes/display/SepiaNode.js @@ -0,0 +1,21 @@ +import { addNodeElement, tslFn, vec3, vec4 } from '../shadernode/ShaderNode.js'; +import { min } from '../math/MathNode.js'; +import { dot } from '../math/MathNode.js'; + +import { property } from '../core/PropertyNode.js'; + +export const sepia = /*@__PURE__*/ tslFn( ( { color } ) => { + + const c = property( 'vec3', 'c' ).assign( color.rgb ); + + // https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/sepia.js + + color.r = dot( c, vec3( 0.393, 0.769, 0.189 ) ); + color.g = dot( c, vec3( 0.349, 0.686, 0.168 ) ); + color.b = dot( c, vec3( 0.272, 0.534, 0.131 ) ); + + return vec4( min( vec3( 1.0 ), color.rgb ), 1.0 ); + +} ); + +addNodeElement( 'sepia', sepia );