Looping cloth

Hi guys, I’ve been tasked with making an animated GIF from a larger animation project. Basically I have to extract a flag with a company logo for use on their Intranet. The baked flag looks good but doesn’t loop without a jump where the end joins the start. Also, an excerpt from the finished animation is not suitable for this as the viewpoint moves too much so I’m going to redo it all using the original model and textures and a static viewpoint. Can anyone suggest a strategy for making this seamless after a number of frames?

Paul

Here’s one workflow for looping cloth. You’ll need to be comfortable keyframing shapekeys. I’ll outline it in broad strokes. If you need more explicit step by step, I can probably whip something up. The key to using this method is understanding that the mdd format saves the animation as a series of keyframed shapekeys, one for every frame.

  1. In user prefs, add-ons, import/export enable: ‘Import Lightwave Objects’ as well as ‘export: NewTek MDD Format’
  2. Create your flag object, I used a cloth sim and a force field wind sim with vertex pinning. Do your scaling of the flag in edit mode.
  3. With your animated flag selected, export it as Lightwave Point Cache (.mdd) and give it a filename.
  4. Delete the cloth sim from the flag. Delete the wind sim.
  5. With flag selected, import Lightwave Point Cache (.mdd) and select the file you just saved.
  6. The timeline should be filled with keyframed shape keys. You should have as many shapekeys as you have frames.
  7. Scrub the timeline to find a frame where the flag is at a high point in it’s flap cycle. I’ll call this startframe. Change the timeline ‘start’ to start on this startframe.
  1. Scrub the timeline to find another frame where the flag is just below the top of one of it’s flap cycles, and preferably looks very similar to the deformity in startframe. I’ll Call this frame endframe.
  2. In the dope sheet delete all key frames after endframe
  3. In the shape keys, delete all shape keys after (frame_endframe -1) The shapekeys are named “frame_00x” and are off-by-one to the blender frames they represent.
  1. Move timeline to endframe. Keyframe the shapekey from startframe at 0 value. The shapekey will be named something like “frame_077”
  2. Go to a few frames after endframe. Maybe endframe+3.
  3. At keyframe+3: Keyframe endframe shapekey at value 0. Keyframe startframe shapekey at value .7 – If you keyframe it at 1, then your first and last frames will identical and it will stall briefly.
  4. Change timeline end to endframe+3.
  5. Run animation and see if it’s seemless. You can mess with the shapekeys if it’s not.
  6. Render it as stills, use the stills to create a large animated gif.

Note. Gif doesn’t do transparency well so, you’d be smart to make the background of your render the html page background, and bake it into the images. It will look better. Again if you need things spelled out more, let me know.

2 Likes

Wow. That’s a touch more complicated than I expected. I’m glad the weekend is nearly on us, I’m going to use it to try and get up to speed with this method. Thank you for going to this much trouble to document it. It is appreciated. I’ll report back with how I get on and/or more questions. Thanks again.

Yeah, there’s probably an easier solution. But that’s the only one I know of that is interpolated, you’ll have to ask the community if there’s something simpler.
You could just use the existing animatiom and try to find a start and end frame that are very similar and then in photoshop or gimp create a frame or two of fudged interpolation. It sort of depends on how “wildy” the flag is flapping.

once you have the animation, duplicate it then reverse it and tack it on the end of the original, depending on frame rate you will have to delete the odd frame or so but thats the easist way I know to make it seemless

That will make it seamless, of course the flag will start waving in reverse.

I’ve tried the reversing method but ended up giving after testing a lot of frame ranges. It just looks wrong. The ripples in the cloth move in the wrong direction. I’ll give you method a try, Blenderallday, and report back.

Yeah it sort of sounds worse than it is. Basically you find two frames that are similar and create a few interpolated bridge frames. using the shape keys. Feel free to ask any questions or if you’re really stuck post the packed blend.

As there is really no modeling, it can be done pretty quickly.

There’s probably some other, possibly trivial, solutions to this too. Be interested if anyone has one. If there was a way, for instance, to remove the animation from certain frames, you could ‘apply as shape key’ the startframe, run the animation again, ‘apply as shape key’ to the endframe. Run the animation agaian, then remove the animation data from after the endframe and interpolate a few frames using the keys. Without going through all the mdd hassle.

You can do that. You need to make 2 copies the flag and wind source and put them on separate layers. Use the original flag to scrub the timeline and find a beginning frame and end frame that are similar. Use the first copy and go to the beginning frame and in the modifier panel apply the cloth modifier as a Shape key. Do the same with the second copy of the flag at the end frame. Then select the 2 copies and in the Shape keys panel click on the black triangle and select Join as shapes (make sure the shape key values are set at 1 first), now you have the flag with 2 shape keys corresponding to the beginning and end of the flag animation.
Hope this makes sense.

I think alank is on the right track, but to my understanding when you ‘apply as shape key’ you lose the animation data. Now I could see doing it with 3 flags on 3 layers, applying the shapekey on the first for the startframe, the second for the endframe, and using the third with animation data retained. The only problem is, on the third layer, I don’t how to remove the animation data for only those frames after the endframe, as they interfere with your 3 or so interpolated frames. If you know how to do that, then you can skip the mdd craziness.

You will have to render out the animation of the flag with the cloth physics intact starting one keyframe after where the beginning shape was taken and finishing one frame before the end shape was taken. You will then have to render the shape key animation (probably only 3 or 4 frames) going from end shape to beginning shape and then combine the two animations in the video editor, i.e add the shape key animation to the end of the cloth animation.

That would work.

Still wish there was a way to either apply the shape key without removing the physics – or a way to remove the physics from certain frames, like a keyframe. Even better would be if the cloth had the option, like an ocean sim, of time which could be keyframed.

Yes, I don’t know why there is no option to save shape key as separate mesh. Perhaps it is not as easy as it sounds; if I try to duplicate a mesh with a cloth sim on it it crashes Blender.

Yeah, overall I’d say alan’s method is easier to pull off. But…

The mdd method has one added advantage. You can watch the whole animation loop in real time in blender and see if it looks seamless. Just because the deforms look natural frame by frame, doesn’t mean they feel right in real time. With .mdd you can make tweaks to it and watch the results instantly. You can render it all out in one pass and not have to stitch the clips together in post. Anyway, we seem to have lost the OP here, so maybe I’m just barking at the moon.

Nope, I’m still here lurking in the background … Trying to catch up with my understanding of this stuff in order to have a go at your method described above. Thanks for all the input. I’ll report back when I’ve had chance to work on it.