[edit: question added] Fluid mesh animation

I’m playing with 2D mesh deformation, I’m trying to reproduce the Photoshop fluidity filter, but animated.
After some days struggling with mesh triangles, I’ve got my first result today that I’m happy to share !


But better in action:


Some more realtime fluid manipulations:


Thanks for the likes.

I’ve got a question now:
I use a mesh to draw the image. To deform it I move the vertices of the mesh. When the deformation becomes important, I split the biggest triangles to keep a smooth aspect. Like that:

The problem is that after some time, I’ve got too many triangles, and the FPS drop.
For the above exemples, I starts with about 20 000 triangles and the FPS starts to drop around 80 000 ~ 100 000 triangles (with the default 60FPS OF setup).

I’m looking for a solution and I’m considering 3 leads:

  1. At some point, grab the currently deformed version of the image and reset the mesh to the original grid.
    This is simple but this is only for still images, and I want to also deform videos or animated content.
  2. Do the calculations in the GPU (for now I do them in the CPU).
    This may help, but I think the problem will still happen at higher triangles number. For example, 750 000 triangles here:
  3. Simplify the mesh over time to reduce the triangle number
    I think this is the way to go.

I could merge adjacents triangles when some of their edges are too small, for example:

In this picture triangles before the merge are black, and red after the merge.

I think I can write some code to make the above 4 and 5 triangles simplification, but this is only one approach of the mesh simplification problem, and it could be other ones. So I’ve started to read about 2D meshes simplification, and this is a wide-ranging topic! So here’s my question: do you know some algorithm that I could use ?

Thank you very much for any input, about the algorithm I’m looking for, or other considerations.