This shows the velocity of the vertices of a 128^3 lattice cube. (2M points). The simulation is done on the gpu and takes only around 3ms on my ati hd5850. At 192^3 (7M points) it still renders in < 10ms (without visualization). The visualisation takes a lot longer: between 7ms for small points and a long time for larger ones, so the system is fillrate limited. This is not very surprising considering every vertex is drawn as a pointsprite, and looking trough the cube results in every pixel being drawn > 100 times.
The simulation is very straightforward: 2 2D textures are used for data storage:
1: vector4 containing position and a “static”-flag (which is used for the cube borders)
2: vector4 containing velocity and pressure;
The simulation is done in one pass and renders to 2 rendertargets at the same time.
Velocity is updated by sampling the positions of the 6 most direct neighbors. Pressure is stored in the 4th channel by adding the distance to the neighbors minus the “relaxed” distance. The pressure channel can be used in de visualization pass, but this is not shown in the videos. When sampling the neighbors, the texture-coordinates needed are converted from 3d to 2d, because the position and velocity textures are 2D. I am using xna so i can’t render to 3d rendertargets.
The velocity is influenced by mouse-pointer position and velocity.
The videos show the same system with some parameters tweaked differently:
you won’t miss anything skipping trough them.