Skip to content

Latest commit

 

History

74 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPU Fluid Simulation

A highly optimized, particle-based GPU fluid simulation written in Rust and Vulkan, featuring an octree-accelerated neighbor search and Slang compute/mesh shaders.


Demo

GPU Fluid Simulation Demo

💡 Click the image above to watch the simulation in action on YouTube.


Features

  • 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.

Code Organization

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
Loading

Prerequisites

Ensure you have the following installed and supported on your system:

Software

Hardware Requirements

  • 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).

Getting Started

Slang shaders are compiled automatically during the Cargo build and embedded into the final executable. Slang is automatically fetched if not detected locally.

Run

Run the simulation with the default configuration (1,000,000 particles, colliding-blocks preset):

cargo run --release

Note: The simulation launches in a paused state. Press Space to start or pause.

Command-line Options

You can configure particle count and initial presets via CLI flags:

cargo run --release -- --num-particles 250000 --preset double-dam-break

Display all available flags and options:

cargo run --release -- --help

Available Presets:

  • colliding-blocks (Default)
  • double-dam-break
  • rotating-block

Controls

Input Action
Space Start / Pause simulation
Left Click + Drag Rotate camera
Right Click + Drag Pan / Move camera
Mouse Wheel Zoom in / out

Performance

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

Testing & Benchmarks

Run unit and integration tests:

cargo test

Run simulation benchmarks:

cargo bench

References

About

GPU fluid simulation in Rust, Vulkan, Slang

Topics

Resources

Stars

12 stars

Watchers

0 watching

Forks

Contributors

Languages