Skip to content

Commit

Permalink
Added blend prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Nov 15, 2024
1 parent 12ead7f commit 9ee033c
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions src/nodes/display/BlendModes.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import { Fn, vec4 } from '../tsl/TSLBase.js';
import { mix, min, step } from '../math/MathNode.js';

export const burn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
export const blendBurn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {

return min( 1.0, base.oneMinus().div( blend ) ).oneMinus();

} ).setLayout( {
name: 'burnBlend',
name: 'blendBurn',
type: 'vec3',
inputs: [
{ name: 'base', type: 'vec3' },
{ name: 'blend', type: 'vec3' }
]
} );

export const dodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
export const blendDodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {

return min( base.div( blend.oneMinus() ), 1.0 );

} ).setLayout( {
name: 'dodgeBlend',
name: 'blendDodge',
type: 'vec3',
inputs: [
{ name: 'base', type: 'vec3' },
{ name: 'blend', type: 'vec3' }
]
} );

export const screen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
export const blendScreen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {

return base.oneMinus().mul( blend.oneMinus() ).oneMinus();

} ).setLayout( {
name: 'screenBlend',
name: 'blendScreen',
type: 'vec3',
inputs: [
{ name: 'base', type: 'vec3' },
{ name: 'blend', type: 'vec3' }
]
} );

export const overlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
export const blendOverlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {

return mix( base.mul( 2.0 ).mul( blend ), base.oneMinus().mul( 2.0 ).mul( blend.oneMinus() ).oneMinus(), step( 0.5, base ) );

} ).setLayout( {
name: 'overlayBlend',
name: 'blendOverlay',
type: 'vec3',
inputs: [
{ name: 'base', type: 'vec3' },
Expand All @@ -65,3 +65,33 @@ export const blendNormal = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
{ name: 'blend', type: 'vec4' }
]
} );

// deprecated

export const burn = ( ...params ) => { // @deprecated, r171

console.warn( 'THREE.TSL: "burn" has been deprecated. Use "blendBurn" instead.' );
return blendBurn( params );

};

export const dodge = ( ...params ) => { // @deprecated, r171

console.warn( 'THREE.TSL: "dodge" has been deprecated. Use "blendDodge" instead.' );
return blendDodge( params );

};

export const screen = ( ...params ) => { // @deprecated, r171

console.warn( 'THREE.TSL: "screen" has been deprecated. Use "blendScreen" instead.' );
return blendScreen( params );

};

export const overlay = ( ...params ) => { // @deprecated, r171

console.warn( 'THREE.TSL: "overlay" has been deprecated. Use "blendOverlay" instead.' );
return blendOverlay( params );

};

0 comments on commit 9ee033c

Please sign in to comment.