9
9
useBlending ,
10
10
useFxTexture ,
11
11
useNoise ,
12
+ useBrightnessPicker ,
12
13
useFluid ,
13
14
} from "../../packages/use-shader-fx/src" ;
14
15
import {
@@ -44,6 +45,7 @@ export const UseBlending = (args: BlendingParams) => {
44
45
const [ updateNoise ] = useNoise ( { size, dpr } ) ;
45
46
const [ updateFluid , setFluid ] = useFluid ( { size, dpr } ) ;
46
47
const [ updateBlending , setBlending ] = useBlending ( { size, dpr } ) ;
48
+ const [ updateBrightnessPicker ] = useBrightnessPicker ( { size, dpr } ) ;
47
49
48
50
const colorVec = React . useMemo ( ( ) => new THREE . Vector3 ( ) , [ ] ) ;
49
51
@@ -55,8 +57,8 @@ export const UseBlending = (args: BlendingParams) => {
55
57
curl_strength : 5.0 ,
56
58
pressure_iterations : 4 ,
57
59
fluid_color : ( velocity : THREE . Vector2 ) => {
58
- const rCol = Math . max ( 0.0 , velocity . x * 150 ) ;
59
- const gCol = Math . max ( 0.0 , velocity . y * 150 ) ;
60
+ const rCol = Math . max ( 0.0 , Math . abs ( velocity . x ) * 150 ) ;
61
+ const gCol = Math . max ( 0.0 , Math . abs ( velocity . y ) * 150 ) ;
60
62
const bCol = Math . max ( 0.1 , ( rCol + gCol ) / 2 ) ;
61
63
return colorVec . set ( rCol , gCol , bCol ) ;
62
64
} ,
@@ -68,12 +70,15 @@ export const UseBlending = (args: BlendingParams) => {
68
70
texture0 : bg ,
69
71
} ) ;
70
72
const fluid = updateFluid ( props ) ;
73
+ const picked = updateBrightnessPicker ( props , { texture : fluid } ) ;
71
74
const fx = updateBlending ( props , {
72
75
...setConfig ( ) ,
73
76
texture : bgTexture ,
74
77
map : fluid ,
78
+ alphaMap : false ,
75
79
} ) ;
76
80
fxRef . current ! . u_fx = fx ;
81
+ fxRef . current ! . u_alpha = 0.0 ;
77
82
updateGUI ( ) ;
78
83
} ) ;
79
84
0 commit comments