Skip to content

Commit

Permalink
Nodes: Add SepiaNode (#28961)
Browse files Browse the repository at this point in the history
* add SepiaNode

* add node to export

* fix

* condense sepia into tslFn

* remove SepiaNode from Node.js

* Update SepiaNode.js

---------

Co-authored-by: Michael Herzog <[email protected]>
  • Loading branch information
cmhhelgeson and Mugen87 authored Jul 26, 2024
1 parent bfe65cd commit 76920df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
21 changes: 21 additions & 0 deletions src/nodes/display/SepiaNode.js
Original file line number Diff line number Diff line change
@@ -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 );

0 comments on commit 76920df

Please sign in to comment.