- Salaar Kohari and Ishan Ranade
- Tested on: Windows 10, Intel Xeon @ 3.1GHz 32GB, GTX 980 4GB
An open-source repository featuring real-time Eulerian fluid simulation and rendering based on SIGGRAPH research, primarily Real-Time Eulerian Water Simulation Using a Restricted Tall Cell Grid. Fluid simulation is performed using discrete Navier Stokes on a collocated MAC grid with marker particles moving through fluid cells. Rendering involves raycasting through a quad tree of particles and shading the result. All parts of the simulation and rendering are implemented on the GPU except the Gauss-Seidel solver and quad tree generation. The simulation calculations alone would take about 10-30 minutes per frame on the CPU, whereas our complete implementation takes 10-30 milliseconds per frame or up to 100 frames per second depending on parameters.
- Tune performance parameters (time step, grid resolution, particle count, solver iterations)
- Tune simulation parameters (viscosity, fluid/air density, atmospheric pressure, external forces)
- Allocate memory for grid cells, pressure solver, and marker particles
- Initialize particle positions with initial scene conditions
- Set cells with marker particles to fluid
- Apply convection using backwards particle trace
- Add external forces (gravity/wind)
- Apply viscosity
- Setup pressure calculations for solver
- Gauss-Seidel to solve for pressure (CPU)
- Velocity fluid/solid extrapolation
- Move marker particles using cell velocity interpolation
When rendered using OpenGL points instead of raycasting, we can simulate 21 million particles in 60fps as shown in the gif above. The graph below shows how the number of particles affects framerate for a 16x16x16 resolution grid.
- Cull particles below the surface and boundaries
- Create quad tree hierarchy for marker particles (CPU)
- Launch ray cast kernel for each pixel
- Check hierarchy for possible water particle collisions
- Compute ray-sphere intersections for those particles
- Color intersections by water height
- Texture mapped normals with Blinn-Phong shading
- Fade color by camera depth
- Display pbo pixel colors using OpenGL
When rendered using accelerated raycasting, we can simulate 33 thousand particles in 60fps as shown in the gif above. The graph below shows how the maximum hierarchy depth affects framerate for a 16x16x16 resolution grid. Note that optimal depth varies between 2-4 depending on particle count.
We used a few different debug coloring views to help us address issues with our simulation. The velocity view helps us debug particle movement continuity and locate regions of jitter. The colors correspond to velocity in each axis (y/green being up).
The pressure view helps us locate regions of extreme pressure and debug boundary pressure conditions. Blue regions have higher pressure.
The intersection view colors green/red based on the relative number of intersections at each pixel, which is directly proportional to the performance cost of each raycast.
To run application:
- cd into the "build" folder in a terminal window
- Run the following, replace DCUDA_TOOLKIT_ROOT_DIR with the path to your toolkit, replace cuda version with any version at least 8.0:
cmake -G "Visual Studio 15 2017 Win64" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.2" -T v140,cuda=9.2 ..
- In the "build" folder you will see a .sln project, open that in Visual Studio
- Real-Time Eulerian Water Simulation Using a Restricted Tall Cell Grid
- Fluid Flow for the Rest of Us: Tutorial of the Marker and Cell Method in Computer Graphics
- Contact us for questions or more references