Alex Dunn - Fluid Dynamics


I present my implementation of a eulerian fluid simulation, running in realtime using DirectX 11 hardware. The entire effect is computed across multiple compute shaders, and can be divided into two distinct parts; simulation computation and rendering.

With it being a eulerian simulation, the particle data is stored in a fixed grid. This enables me to store all the desirable information in volume textures. Double buffers must be used for; velocity, divergence and pressure, so that one texture can be used as a read target, and the other for writing. For my advection scheme, I have chosen to use the MacCormack method. This is a second-order scheme, and thus, yields improved visual detail over other (lower-order) advection schemes on the same resolution grid. To solve the pressure in the system, I use an iterative Jaccobian method. This allows the system to converge quite comfortably, with pleasing visual results, within around 10 to 20 iteratons. Which is well within bounds for realtime application. When using a lower number of iterations the visual result isn't nessecarily bad, but the detail in the indivdual whisps of flames and smoke is severely reduced. In the demo below, you can tweak the iteration value, and see the results for yourself.

Many ways to render fluids exist, I have implemented two, and you can switch between them in the demo below. The two methods I have implemented are fairly similar, the first, Maximum Intensity Projection. MIP rendering is commonly used in medicine, it's a way of visualizing 3D data sets, I think it's quite a good representation of the visual aspects of smoke, but the lack or depth perception is what encouraged me to implement a second method, raymarching. There is a third rendering option worth mentioning, geometry shader marching cubes. The major benefit of this method, is that a final depth composition pass isn't required to embed the 3D data in the world, however, it is very expensive compared to the approach I present here.

Features: