Skip to main content
edited tags
Link
Became Hot Network Question
Tweeted twitter.com/StackMma/status/1327672646461509632
Source Link
flinty
  • 25.9k
  • 2
  • 22
  • 92

Smoother jelly / water effect on an image

I'm trying to achieve a jelly / water surface effect. I'd like it to be a bit smoother. Here I am taking a triangulated rectangle and perturbing all points by a little random noise for each frame. This warps the polygons and stretches the texture so it looks like it's a turbulent liquid surface:

img = ExampleData[{"TestImage", "House"}];
mesh = TriangulateMesh@Rectangle[{0, 0}, {1, 1}];
coords = MeshCoordinates[mesh];
cells = MeshCells[mesh, 2];
texture = Texture[img];

Table[With[{newcoords = coords + 0.01*RandomPoint[Disk[], Length[coords]]},
   Rasterize[
    Graphics[{texture, 
      GraphicsComplex[newcoords, cells, 
       VertexTextureCoordinates -> coords]}]]
   ], {30}] // ListAnimate

water ripple image effect

To make this better and less jumpy I think I need to accumulate the small random disturbances of the coordinates of the mesh. But I don't want any point on the mesh to drift and deform its polygon so much over time that it becomes highly distorted with extreme self-intersections. Any ideas how I can do this and not push up computation time?