A highly optimized, particle-based GPU fluid simulation written in Rust and Vulkan, featuring an octree-accelerated neighbor search and Slang compute/mesh shaders.
💡 Click the image above to watch the simulation in action on YouTube.
- Massive Particle Counts: Simulates over 1,000,000 particles in real-time.
- Octree Neighbor Search: Fast GPU-based dynamic spatial partitioning.
- Slang Shader Pipeline: Shaders are compiled and embedded directly during the build.
flowchart TD
App[App: window and events] --> Session[Session: input and camera]
Session --> Backend[GpuBackend]
Vulkan[VulkanBackend] -. implements .-> Backend
Vulkan --> Physics[ParticlePhysics: simulation]
Vulkan --> Renderer[VulkanWorldRenderer: rendering]
Vulkan --> Resources[VulkanWorldResources: GPU particle data]
Physics -->|updates| Resources
Renderer -->|reads| Resources
Ensure you have the following installed and supported on your system:
- Rust Toolchain: Latest stable Rust (
rustup default stable). - LLVM
- LunarG Vulkan SDK
- A modern GPU supporting Vulkan 1.3+.
- Support for Mesh Shaders (
VK_EXT_mesh_shader). - Support for Subgroup / Wave operations (subgroup arithmetic and extended types).
Slang shaders are compiled automatically during the Cargo build and embedded into the final executable. Slang is automatically fetched if not detected locally.
Run the simulation with the default configuration (1,000,000 particles, colliding-blocks preset):
cargo run --releaseNote: The simulation launches in a paused state. Press Space to start or pause.
You can configure particle count and initial presets via CLI flags:
cargo run --release -- --num-particles 250000 --preset double-dam-breakDisplay all available flags and options:
cargo run --release -- --helpAvailable Presets:
colliding-blocks(Default)double-dam-breakrotating-block
| Input | Action |
|---|---|
| Space | Start / Pause simulation |
| Left Click + Drag | Rotate camera |
| Right Click + Drag | Pan / Move camera |
| Mouse Wheel | Zoom in / out |
| Metric | Result |
|---|---|
| Particle Count | 1,000,000 particles |
| Frame Rate | ~180 FPS |
Benchmark System Specs:
- GPU: AMD Radeon RX 6800 XT
- CPU: AMD Ryzen 5 7600
- OS: Linux
Run unit and integration tests:
cargo testRun simulation benchmarks:
cargo bench- Divergence-free SPH (DFSPH) — Jan Bender, Dan Koschier
- Cornerstone: Octree Construction Algorithms for Scalable Particle Simulations — J. Keller et al.
- Single-pass Parallel Prefix Scan with Decoupled Look-back — Duane Merrill, Michael Garland
