Tuesday, February 8, 2011

Simulating Cloth in Sections - mini tutorial

A little while ago, I was handed a shot that another TD was having trouble with. In this shot, a character does an action, bends down, comes up incredibly fast then does another action. Rather than key a zillion attributes and force the cloth to work from beginning to end, I decided that I'd make the cloth work from -50 to 119 (where the character was totally out of frame), cache, then I'd sim from 120 - 195 (the end of the shot) and cache this section. After that, I'd combine the two caches.

When it comes to problem shots, simulating cloth in sections can save you a lot of time and hassle. In this post, I'll walk you through that process.

((This tutorial is meant for those who are somewhat familiar with cloth simulation.))

Prep Work

i. Create three folders where ever you like, for example your Desktop. Name them Cache 1, Cache 2 and Final Cache.

ii. Set up the cloth in your scene and save. Make a copy of this scene and rename the copy SceneName_Clean, or something to that effect to let you know that this is your fresh, untouched scene.


1. Simulate your cloth. Get it as good as you possibly can for as long as you can. Make a note of the frame where the simulation starts to fail. For my shot, the cloth started to break at frame 140.

2. Choose your nDynamics menuset and go to nCache > Create New Cache > click the option box. Here, set your Cache Directory to the Cache 1 folder you created.

3. Name this cache Cache 1. For the file distribution option, I like to choose the one file per frameoption. This way, should you ever need to replace certain frames, you can.

4. For Cache time range, select Start/End and set your start frame to your very first frame, mine was -50, and your end frame will be about 20 frames beyond where you really want to end. For example, I knew I wanted my first cache to end at frame 119, so to give myself a buffer and set this cache to end at 139. You'll see why in a moment.

5. SAVE!!

6. The fun part. You can do several things beside this, and I admit this is the most drastic route, but it's the cleanest. Delete all of the animation on your character up to where you wanted your first cache to end. It's a good idea to give yourself a 20 frame buffer. In other words, if you wanted your first cache to end at frame 119, then delete the animation up to frame 99. Note: Sometimes this isn't possible because the animation before that point is what causes your cloth to break.

7. Duplicate that key and set it 20 frames prior. In other words, frames 99 and 79 are identical for me.

8. Go 40 frames back and put your character in his/her "T" pose. Set a key. Go forward 20 frames, make sure your character is still in his/her "T" pose. Set a key.

9. Simulate the cloth for this half. Note: In your Nucleus, under Time Attributes, you can set your Start Frame to your first "T" pose frame for the time being.

10. Go to nCache > Create New Cache > click the option box. Here, set your Cache Directory to the Cache 2 folder you created.

11. Name this cache Cache 2. For Cache time range, select Start/End and set your start frame 20 frames before you want the second cache to start. I wanted my second cache to start at frame 120, so I gave myself a 20 frame buffer and started the cache at frame 100.

12. After your cloth has finished caching, close this file and open the SceneName_Clean file you made. In this file all of your animation is still in tact.

13. Select your cloth and go to the nDynamics menuset, nCache > Attach Existing Cache File... Navigate to your Cache 1 folder, select the .xlm file and press OK.

14. Repeat step 13, this time navigating to your Cache 2 folder.

15. With your cloth selected, go to Window > Animation Editors > Trax Editor. Hit the "f" key for frame everything in the window. You'll see your two caches in these blocks. As you can see, the extra frames you cached at the end of Cache 1 and the beginning of Cache 2 overlap. While they overlap, both caches are active and are blending together. In the case of this example, I dragged the top number (don't drag the bottom number!) forward until my 20 buffer frames overlapped.

Why would you want the caches to overlap here?

Sometimes you'll want this so the cloth doesn't make a visible snap when it transitions from one cache to the other. You can further finesse this by selecting your cloth, going to the attribute editor and clicking on the Cache Blend tab. You can key the first cache from 1 to 0 during the overlapped time, and the second cache from 0 to 1. This way the cloth is slowly segueing from the first to second cache.

In my case, I didn't really need the caches to overlap or blend because the switch was happening off camera, but it's not a bad habit to get into. However, if you want to snap from one cache to the next, all you need to do it drag the end of the Cache 1 track back 20 frames, and the beginning of the Cache 2 track forward 20 frames. (or whatever you set your buffer to be). Be sure you're clicking and dragging on the top number and not the bottom number!

Also, be sure not to have any gaps between your two trax, other wise your cloth will more than likely pop/break for those frames.

16. The two working cache halves will now drive your cloth object [more or less] seamlessly. The only thing left to do now is to combine these caches to make one working cache. Go to nCache > Merge Caches > click the option box.

17. Set the Cache Directory to the Final Cache folder you created.

18. Name this cache Final Cache. For the Cache time range, select Start/End and set your start frame to the very first frame in the shot, the final frame to the very last frame of your shot. Note: Make sure in your nucleus, your Start Frame is the very first frame in your scene. Technically you don't 'have' to do this, since your first cache is active from the first frame, but it's good to put the start frame back to where it initially was in case you have to do more cloth simulation.

19. That's it! You can go to nCache > Delete Cache > click the option box and delete the first two caches if you like (select keep the files just to be safe). You can also select your cloth object, go to the nClothShape tab in your Attribute editor and deselect Enable so the cloth isn't calculating in the background.

The nice thing about this is, you can combine more than two caches. My maximum so far has been 7 for a difficult :35 second shot and it works really well. You can also cache again and merge your combined cache with this new cache. I don't really advise going too insane with this, but the sky's the limit.

Generally, if you're having to combine caches a lot of times on a shot that isn't very complex, you should revisit your sim and try to make it behave better for a longer span of time.


This may sound like cheating but let me make one thing perfectly clear: it is. Don't feel bad, we're all cheating every second we choose to work with animation. These characters and effects and lights and worlds don't exist. We're all faking reality. You should try to make things work the 'right' way, whatever that is, but at the end of the day, you need to do what you have to do in order to get something to work.

I plan to make a video demo on this at some point in time, and type this up and make it available as a PDF, but in the meantime take this for what it's worth.

I hope it helps.



  1. This comment has been removed by the author.

  2. It's funny that you should mention a .pdf. I'm working on one now. I'm just rewriting these steps so that they actually make sense to someone other than me, hehe.

    Thanks for stopping by ^^; Your site is amazing and inspirational.