-
-
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.
* init * removed property call * Update BleachBypassNode.js * Update Nodes.js Clean up. * Update BleachBypassNode.js Use `luminance()`. --------- Co-authored-by: Michael Herzog <[email protected]>
- Loading branch information
1 parent
cd6df9f
commit 5068f70
Showing
2 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { addNodeElement, float, tslFn, vec3, vec4 } from '../shadernode/ShaderNode.js'; | ||
import { min, max, mix } from '../math/MathNode.js'; | ||
import { luminance } from './ColorAdjustmentNode.js'; | ||
|
||
export const bleach = /*@__PURE__*/ tslFn( ( [ color, opacity = 1 ] ) => { | ||
|
||
const base = color; | ||
const lum = luminance( base.rgb ); | ||
const blend = vec3( lum ); | ||
|
||
const L = min( 1.0, max( 0.0, float( 10.0 ).mul( lum.sub( 0.45 ) ) ) ); | ||
|
||
const result1 = blend.mul( base.rgb ).mul( 2.0 ); | ||
const result2 = float( 2.0 ).mul( blend.oneMinus() ).mul( base.rgb.oneMinus() ).oneMinus(); | ||
|
||
const newColor = mix( result1, result2, L ); | ||
|
||
const A2 = base.a.mul( opacity ); | ||
|
||
const mixRGB = A2.mul( newColor.rgb ); | ||
|
||
mixRGB.addAssign( base.rgb.mul( A2.oneMinus() ) ); | ||
|
||
return vec4( mixRGB, base.a ); | ||
|
||
} ); | ||
|
||
addNodeElement( 'bleach', bleach ); |