/SPHFluid

Interactive 3D Fluid Simulation based on SPH

Primary LanguageASPMIT LicenseMIT

SPH Fluid Simulator on GPU
Apr. 47th
Yang Zhou (yzhou4)

0. Overview
This is a real-time fluid simulation application using smooth particle
hydrodynamic method[1]. The application is made in Unity. Just play it to have
some fun!! Youtube Video: https://youtu.be/gWqLvkn-wLY

The executable is in Release/ folder

1. Contribution
-1.1 We implemented a GPGPU version of SPH simulation in HLSL / Direct Compute.
Since the nature of SPH is parallel. This is much faster than the original CPU
version, it enables us to simulate a huge number of particles in realtime.

-1.2 We implemented a GPGPU version of Marching Cube algorithm to visualize the
fluid simulated based on the first chapter of GPU Gem 3 [2]. Again, this is much
faster than the original CPU version. The precomputed table is available from [2].

-1.3 We wrote a simple water shader (transparent, reflective (cube map)) to
render the fluid. This is done in Unity's ShaderLab/Cg shader language.

We DID NOT implement rasterization, texture importing, or model importing,
as Unity did these for us. The skybox is a free asset from Unity's asset store.
(but we made the app icon......)


2. System / Compatibility
This application can only run on Windows (7 or higher). Also, the system must
support shader model 5.0 or higher to run it (because we are doing lots of stuffs
on GPU).

3. Parameter
-3.1 There are a lot of parameters you can tweak before simulation. The most obvious
two are particle number and mesh resolution. The higher the mesh resolution is,
the finer the marching cube grid will be (and also the slower it would be).
-3.2 Change time step will allow the simulation go faster (but not so precise).
-3.3 We have two different grid size levels in 3 dimensions to allow you to
switch between a larger world and a smaller world.
-3.4 The remaining parameters are mostly fluid properties. Please refer to the
original paper to see their meanings.

4. Control
Arrow Key: Camera moving
Right mouse button: rotate Camera view direction
Ball interaction: Add some fun by moving a ball and let it collide with fluid!
(see screen for controls)

5. Performance
Interestingly, our bottleneck does not come from SPH or Marching Cube, but
actually comes from the data transfer from GPU to CPU after generating the final
mesh triangle data. We have to do so because we need to fill those data to Unity
's mesh data structures. If we turn off visualization, we can simulate more than
30k particles in 60 fps. However with visualization, we can barely run 10k with
acceptable framerate. (This is tested on a GTX 745).

Reference:
[1] Müller, Matthias, David Charypar, and Markus Gross. "Particle-based fluid
simulation for interactive applications." Proceedings of the 2003 ACM
SIGGRAPH/Eurographics symposium on Computer animation. Eurographics Association
, 2003.
[2] Geiss, Ryan. "Generating complex procedural terrains using the GPU." GPU
gems 3 (2007): 7-37.