No magic it is just a vertex animation via texture. A couple of years ago I had experimented with vat Vertex Animation texture compression . I was successful in creating a workflow but it wasn’t at it’s full potential as instancing was missing. The gist of how it works is that a physics wind simulation was added to the flag for animation then each vertex position in the animation was encoded to a texture (xyz > rgb) each row of pixels is a frame of animation. The flag model then has 2 sets of UV’s one for displaying textures and the other is setup to align with each pixel in a row of pixels. The model and texture are brought into defold then a material/shader is created and in the vertex shader the second set of uv’s is used to read/set position for each vertex by sampling at the center of the texels. The uv set is then animated to move up the V axis and as it moves up it reads and sets the new positions for each vertex animating the model. Vat animation is quite an amazing technique and used for some really cool effects.
*edit the only thing missing for smoothly interpolating from vertex positions is bilinear filtering.