Skip to content

Commit 8baf67f

Browse files
author
takuma-hmng8
committed
add alphaMap to useBlending
1 parent 3024d88 commit 8baf67f

File tree

12 files changed

+129
-77
lines changed

12 files changed

+129
-77
lines changed

.storybook/stories/UseBlending.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
useBlending,
1010
useFxTexture,
1111
useNoise,
12+
useBrightnessPicker,
1213
useFluid,
1314
} from "../../packages/use-shader-fx/src";
1415
import {
@@ -44,6 +45,7 @@ export const UseBlending = (args: BlendingParams) => {
4445
const [updateNoise] = useNoise({ size, dpr });
4546
const [updateFluid, setFluid] = useFluid({ size, dpr });
4647
const [updateBlending, setBlending] = useBlending({ size, dpr });
48+
const [updateBrightnessPicker] = useBrightnessPicker({ size, dpr });
4749

4850
const colorVec = React.useMemo(() => new THREE.Vector3(), []);
4951

@@ -55,8 +57,8 @@ export const UseBlending = (args: BlendingParams) => {
5557
curl_strength: 5.0,
5658
pressure_iterations: 4,
5759
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);
6062
const bCol = Math.max(0.1, (rCol + gCol) / 2);
6163
return colorVec.set(rCol, gCol, bCol);
6264
},
@@ -68,12 +70,15 @@ export const UseBlending = (args: BlendingParams) => {
6870
texture0: bg,
6971
});
7072
const fluid = updateFluid(props);
73+
const picked = updateBrightnessPicker(props, { texture: fluid });
7174
const fx = updateBlending(props, {
7275
...setConfig(),
7376
texture: bgTexture,
7477
map: fluid,
78+
alphaMap: false,
7579
});
7680
fxRef.current!.u_fx = fx;
81+
fxRef.current!.u_alpha = 0.0;
7782
updateGUI();
7883
});
7984

0 commit comments

Comments
 (0)