# Creating looping cloth animation for sprite

Helllo!

For a project that I am doing, I need to render the my model to a sprite sheet. This is all fine, except that the model has a cloak, which uses a cloth animation. I need to smoothly transition from the end of the cloth simulation to the start, so it doesn't just jerk back, but I can't find any way of doing this.

Thanks in advance.

• Is reversing a possibility? – Reaper Nov 3 '17 at 8:00
• @Reaper That would probably work. I just don't know how to do it. – V F Nov 3 '17 at 8:09

## 1 Answer

You can use a similar solution to that described in Create Seamlessly Looping Animated Displacements to fake a fluttering cape that loops seamlessly by using the True Displacement feature along with generated Sine waves to produce the effect of rippling cloth. To add variation we can add in multiple waves of differing strengths, frequencies and direction to produce a more effective motion.

Here's the material :

Note that apart from the nodes at the top right (for the shader) the material essentially consists of three repeated structures - one for each Sine wave - each one consisting of a Mapping node to allow the wave direction to be adjusted, some maths to set the Frequency (the first multiply node), the Sine function to generate the wave, and a Multiply to set the amplitude. The results of the three waves are combined using Add and passed into the Displacement node (set to True Displacement 'experimental' feature set).

Note the nodes to add in an Offset generated from the Value node - this should be varied from 0 to 1.0 over the course of the animation. Ensure the F-Curve is set to Linear interpolation and set its range to one frame longer than the desired animation (so, say, Value varies from 0.0 at frame 1 to 1.0 at frame 51 - and we'll use frames 1 to 50 for the looped animation (since frame 51 should be the same as frame 1)).

To ensure the Sine functions all return to the start point at the end of the animation ensure all of the frequency Multiply nodes are set to a multiple of 2*pi (since there are 2*pi radians in a full cycle).

Note also that the top line of nodes includes a Subtract node based on the Z coordinate for the amplitude multiplier so that the displacement increases from top to bottom of the "cloth".

Here's the final result :