Bubbleᴴ, A Soap Film Solver

Bubbleᴴ, A Soap Film Solver

in

A couple years ago I’ve read a great paper that I’ve thought would be a great addition to houdini. The paper is named “Double Bubbles Sans Toil and Trouble: Discrete Circulation-Preserving Vortex Sheets for Soap Films and Foams” by Fang Da et al. and made it first appearance in Siggraph 2015.

It is a great article that uses a multi-material surface tracker to solve volume preserving soap film surfaces. The best part is it accomplishes mesh splitting and merging, so user is not limited to a fixed level of detail.

Until a month ago I was still searching for a solution in Houdini to simulate soap bubbles that has ability to merge and split, but most of the solutions were either approximations or some kind of hacks to simulate the separating plane that you can observe between two bubbles. Then I’ve stumbled upon the github repository of the said paper and saw they already have an implementation.

My initial idea was to implement the whole repository in a houdini node with hdk but that required converting the third party, Los Topos geometry library that soap film repository uses. So I’ve decided to write a wrapper around the surface tracker to convert the houdini geometry to a LosTopos mesh, solve the soap film surface and convert it back to houdini geometry back.

You can find the BubbleH repository here: https://github.com/sergeneren/BubbleH

Integration of SoapFilm3D in Houdini

To convert the soapfilm3D to BubbleH, first I’ve stripped down all the unnecessary classes that are related to opengl and rendering. What I was left with is the surface tracker and the core forces. Then I wrote a new MeshIO class that would act as a translator between the Houdini geometry and the LosTopos mesh.

Another problem with writing a houdini node was that the new sop node class was to set in it’s own scope rather than the main scope. In the original repository many objects were used as global or static variables. Everyone of them are converted to class specific variables that would live until the scope goes out of the node.

One example of these global variables is the surface tracker vs3d class. The main solver lives under this class and in the original repository it was created in the main loop and retained under executable is terminated. For a houdini node it is not possible to make a new surface tracker that is a global variable, so I had to create a new one every time the node cooks. That also meant I had to find a way to transfer the solver specific attributes like gamma from the previous frame. And to top it all, the translator class is clearing and redrawing the houdini geometry from scratch every frame.

So I’ve decided to create temporary array attributes to hold the previous matrix type objects with linearization and copied them back to the geometry in the Houdini to LosTopos conversion. This allowed me to carry the information from the previous frame. But this is only valid for explicit stepping and more work is needed for implicit stepping algorithms.

Problems & Bugs

Currently BubbleH has couple problems that need addressing. One of the biggest challenges was to convert the houdini geometry to LosTopos mesh because houdini is a left handed system and the LosTopos is a right handed one. Intersection algorithms sometimes find phantom collisions and interactions if the mesh is very detailed or during a remeshing step.

Another problem is the memory allocation bugs that are usually arise during mesh translation steps. The geometry is converted back and forth using std::vector types and the translator may sometimes try to grab a memory location that it shouldn’t.

If you see an issue or another type of problems please open an issue in the github repository.

Future Plans & Code Path

I have many plans to make this repository a stable soap film solver inside houdini. One of my initial goals is to remove the third party dependencies and rewrite the whole geometry tracking and solvers using houdini classes. Another milestone would be to divide the whole solver into steps and create a Soap Film solver in DOP network.

There are also many optimization and bug fix plans that you can see in the repository code path project here.

I will be working on this project on my free time and plan to maintain it as long as I can. If you happen to use it in a project please let me know.

Thank you for stopping by. See you on next projects.