Home C++ Lua GitHub Games Math Myself Contact

GPU Fluid Simulation

This is Jos Stam's Real-Time Fluid Dynamics for Games paper put to the GPU. I'm sure people have since written papers on GPU implementations, most likely specifically modelled after Jos Stam's CPU-based paper here. I was too lazy to seek them out myself. Besides, that would take all the fun out of making one up myself.

Supports float and fixed point precision. I'm having issues with using certain bitsized fixed-points and certain field sizes with the velocity field calculations. Somehow drift gets added in there. Tokyo Drift, that is. Also, my old card doesn't support bilinear filtering with the float textures (which Stam's implementation can take advantage of) so without that you're doing those calculations in shader code.

Right now it's a repeating texture. You could change that. Just throw some clamp()'s in next to any field texture dereferences. I am slowly adding in an option to paint in boundaries. Right now it just zeroes velocity at boundaries rather than conserving energy. I've also added a field visualization. This won't be so cool without some source emitters -- and while there is support for source emitters there is no means to paint them into the scene. More on that later.

Note: I have been getting reports on some machines of seeing nothing but a black screen. I'm still in the process of tracking this bug down. It might be a while 'til I fix it, seeing as how I can't recreate it on my own machine.

Download the Script Here
Source Code Dependencies OpenGL Lua Shell