Skip to content

Commit

Permalink
Merge pull request #47 from takuma-hmng8/dev
Browse files Browse the repository at this point in the history
useBlendingのdodgeColorを修正
  • Loading branch information
takuma-hmng8 authored Dec 26, 2023
2 parents 08d2469 + 3024d88 commit 52c345f
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 94 deletions.
26 changes: 22 additions & 4 deletions .storybook/stories/UseBlending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useBlending,
useFxTexture,
useNoise,
useFluid,
} from "../../packages/use-shader-fx/src";
import {
BlendingParams,
Expand All @@ -22,7 +23,6 @@ const setGUI = (gui: GUI) => {
gui.add(CONFIG, "mapIntensity", 0, 1, 0.01);
gui.add(CONFIG, "min", 0, 1, 0.01);
gui.add(CONFIG, "max", 0, 1, 0.01);
gui.addColor(CONFIG, "color");
};
const setConfig = () => {
return {
Expand All @@ -42,18 +42,36 @@ export const UseBlending = (args: BlendingParams) => {
});
const [updateFxTexture] = useFxTexture({ size, dpr });
const [updateNoise] = useNoise({ size, dpr });
const [updateBlending] = useBlending({ size, dpr });
const [updateFluid, setFluid] = useFluid({ size, dpr });
const [updateBlending, setBlending] = useBlending({ size, dpr });

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

setFluid({
density_dissipation: 0.92,
velocity_dissipation: 0.99,
velocity_acceleration: 12.0,
splat_radius: 0.015,
curl_strength: 5.0,
pressure_iterations: 4,
fluid_color: (velocity: THREE.Vector2) => {
const rCol = Math.max(0.0, velocity.x * 150);
const gCol = Math.max(0.0, velocity.y * 150);
const bCol = Math.max(0.1, (rCol + gCol) / 2);
return colorVec.set(rCol, gCol, bCol);
},
});

useFrame((props) => {
const bgTexture = updateFxTexture(props, {
textureResolution: CONSTANT.textureResolution,
texture0: bg,
});
const noise = updateNoise(props);
const fluid = updateFluid(props);
const fx = updateBlending(props, {
...setConfig(),
texture: bgTexture,
map: noise,
map: fluid,
});
fxRef.current!.u_fx = fx;
updateGUI();
Expand Down
Loading

1 comment on commit 52c345f

@vercel
Copy link

@vercel vercel bot commented on 52c345f Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.