2D and 3D GPU implementations of Jos Stam's infamous Stable Fluids paper using compute shaders in Unity.
- For the 2D implementation see
StableFluids2D.cs
andStableFluids2D.compute
. - For the 3D implementation see
StableFluids3D.cs
andStableFluids3D.compute
, as well asVolume.shader
for the custom shader responsible for volume rendering the 3D fluid.
Download this repository, open with Unity 2022.3 or later, and proceed to either of the two demo scenes in the Assets/Scenes
folder. The scenes and their respective controls are as follows:
2D Stable Fluids simulation rendered directly to the screen.
- Left Click: Stir fluid
- Right Click: Add dye
- R: Reset simulation
3D Stable Fluids simulation rendered inside the bounds of a cube.
- Left Click: Rotate camera
- Right Click: Zoom camera
- R: Reset simulation