-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BlendModes: Added
blend*
prefix (#29897)
* Rename `BlendMode` -> `BlendModes` * Added `blend` prefix * update examples * improve warning message * rename `blendNormal` -> `blendColor` * move 'blendColor' to Porter Duff formula
- Loading branch information
Showing
6 changed files
with
106 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Fn, vec4 } from '../tsl/TSLBase.js'; | ||
import { mix, min, step } from '../math/MathNode.js'; | ||
|
||
export const blendBurn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { | ||
|
||
return min( 1.0, base.oneMinus().div( blend ) ).oneMinus(); | ||
|
||
} ).setLayout( { | ||
name: 'blendBurn', | ||
type: 'vec3', | ||
inputs: [ | ||
{ name: 'base', type: 'vec3' }, | ||
{ name: 'blend', type: 'vec3' } | ||
] | ||
} ); | ||
|
||
export const blendDodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { | ||
|
||
return min( base.div( blend.oneMinus() ), 1.0 ); | ||
|
||
} ).setLayout( { | ||
name: 'blendDodge', | ||
type: 'vec3', | ||
inputs: [ | ||
{ name: 'base', type: 'vec3' }, | ||
{ name: 'blend', type: 'vec3' } | ||
] | ||
} ); | ||
|
||
export const blendScreen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { | ||
|
||
return base.oneMinus().mul( blend.oneMinus() ).oneMinus(); | ||
|
||
} ).setLayout( { | ||
name: 'blendScreen', | ||
type: 'vec3', | ||
inputs: [ | ||
{ name: 'base', type: 'vec3' }, | ||
{ name: 'blend', type: 'vec3' } | ||
] | ||
} ); | ||
|
||
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: 'blendOverlay', | ||
type: 'vec3', | ||
inputs: [ | ||
{ name: 'base', type: 'vec3' }, | ||
{ name: 'blend', type: 'vec3' } | ||
] | ||
} ); | ||
|
||
export const blendColor = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { | ||
|
||
const outAlpha = blend.a.add( base.a.mul( blend.a.oneMinus() ) ); | ||
|
||
return vec4( blend.rgb.mul( blend.a ).add( base.rgb.mul( base.a ).mul( blend.a.oneMinus() ) ).div( outAlpha ), outAlpha ); | ||
|
||
} ).setLayout( { | ||
name: 'blendColor', | ||
type: 'vec4', | ||
inputs: [ | ||
{ name: 'base', type: 'vec4' }, | ||
{ name: 'blend', type: 'vec4' } | ||
] | ||
} ); | ||
|
||
// deprecated | ||
|
||
export const burn = ( ...params ) => { // @deprecated, r171 | ||
|
||
console.warn( 'THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.' ); | ||
return blendBurn( params ); | ||
|
||
}; | ||
|
||
export const dodge = ( ...params ) => { // @deprecated, r171 | ||
|
||
console.warn( 'THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.' ); | ||
return blendDodge( params ); | ||
|
||
}; | ||
|
||
export const screen = ( ...params ) => { // @deprecated, r171 | ||
|
||
console.warn( 'THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.' ); | ||
return blendScreen( params ); | ||
|
||
}; | ||
|
||
export const overlay = ( ...params ) => { // @deprecated, r171 | ||
|
||
console.warn( 'THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.' ); | ||
return blendOverlay( params ); | ||
|
||
}; |