Sunday, March 26, 2023

3D *Simi* Dual Mesh with Compute Shader in Unity

Last year we got somewhat stuck with the upgrade of the 3D Dynamic Foam program in Julia (Voro-X) to a more performant 2.0 version. The reason is that there is no CGAL version (yet) for Julia to use as the backbone. 

So I decided to explore if a Compute Shader might be an option, because shaders use the full power of GPU's and can significantly increase the speed of simulations.

As such I got in touch with Polish developer Przemyslaw Zaworski to see if it was possible to get the Dynamic Foam model running with a Compute Shader in Unity.

The result is a *semi* 3D Dual Mesh simulator with a Delaunay Triangles/Tetrahedrons basis out of which a Semi-Voronoi-Mesh is distilled using the Jump Flooding Algorithm (JFA):

It is a *Semi* mesh because the Voronoi mesh is only a pixel/voxel-mesh and not a 'real' mesh made out of a conglomerate of points, edges and faces. As such it cannot be used to setup the interaction model between the two complimentary dual meshes (Delaunay/Voronoi). Perhaps in the future an actual Voronoi mesh can be extrapolated from the semi-Voronoi-mesh.

Here's a compilation video with more examples of the simulator:

An other option worth exploring might be Mesh-shaders