This project was something I put together for a game team project I worked on called Remanence. The goal was to make several looping cloth simulations that worked well in Unreal 5. They had to be fairly optimized as we were struggling with performance issues at the time. The in engine cloth simulations were proving to be performance heavy and unreliable so I had to come up with a better solution.
Cleaning Up the Mesh
The first step was to make take a plane that I had previously been using for in engine cloth sims and bring it into Houdini. While I could have simply recreated the plane in Houdini I chose to reuse the old asset as it already had textures created for those specific UVs.
To create a more natural looking cloth sim I remeshed the plane. This idea came from working in marvelous designer and noticing that it always creates semi random triangulated meshes for its geometry as that tends to fold more naturally than a grid of polygons.
The next step was to set up vellum constraints and a pin group of a few points on the top of the mesh so it wouldn't simply fly away once I started simulating wind.
Vellum Wind Simulation
Here is one of the base simulations that I ran on the plane. It clearly doesn't loop but it achieves the windswept look I was going for. I ended up simulating about 800 frames so I could pick a part of the simulation that looked the best. This was also so that I could trim out the beginning of the animation as the simulation was still ramping up. Next I picked 200 of the best looking frames from the middle and cached them out.
Blending the Beginning and Ending of the Simulation
The next step was to use the retime node set those 200 frames to start at frame one. After that I used a time shift node to make the animation loop and offset it backwards by 50 frames. I then duplicated that time shift node and offset the animation forward by 50 frames.
After that it was as simple as keyframing blend shapes to slowly blend between the two offset versions of the animation. This meant that by the time the first version was about to jump back to its start the animation would have switched over to the second version which was right in the middle of its loop and so on.
This resulted in a seamless looping cloth simulation that was ready for export!
Importing into Unreal and Making Materials
I ended up saving the animation out as an alembic file. When used to drive large simulations with lots of points this is not particularly performant but since this mesh is pretty light it didn't seem to impact performance to any noticeable degree.
Once the animation was imported into Unreal I built this simple material for it. The opacity mask was painted in Substance painter but everything else was built im unreal. The logo on the flag was an alpha I pulled from my asset library.
This allowed for quick iteration and the ability to swap out what is on the flag very easily depending on what our art director wanted.
Final Product
And voila, looping flag animations!
I ended up repeating this process a number of times so we could have different flags flapping at different speeds and with varying wind directions depending on where they ended up getting placed into the level.
This was super a super fun problem to solve and this tutorial from Peter Peter Quint was instrumental in helping me figure it out.