Pages

Thursday 19 November 2015

High Resolution Cloth Simulations

Here I will describe the method I have been using to create high resolution cloth simulations, based upon low resolution pre-vis cloth. This method is derived from the work of David Knight - thanks David!

1. First, create a medium resolution poly mesh which we will use to create the low res sim.



In my example I have created a mesh with 80 x 160 faces. The mesh MUST be proportionate to the number of faces (i.e. 2:1 in my case) this is because nCloth works better with square faces.

2. Duplicate the mesh. We will use this second mesh to 'pull' the cloth around the scene. Select around 5% of the faces from the leading edge of the Puller mesh. Invert the selection and delete the other faces. We should be left with a narrow strip of faces which exactly overlap the leading edge of the cloth.
 These are the faces we want to keep


3.  Make the original mesh a nCloth.

4. Select the vertices of the nCloth that correspond to the Puller object and then shift select the Puller mesh and create a Point to Surface nConstraint.


5. We want the nConstraint to have low strength, so that the puller gently guides the cloth through the scene. I have used values:
Strength = 0.05
Tangent Strength = 0.0.5

6. We want to animate the Puller mesh now. You can attach it to a motion path or just keyframes, it doesn't matter really. Remember that the faster the cloth moves through the scene, the more sub-frame samples you will need to keep the cloth behaving nicely. If the motion is too jerky the cloth will go crazy. Keep the animation as smooth as you can.

7. Add some noise to the cloth. No cloth will behave perfectly in reality, so add some noise to your simulation. One way to do this is to add a texture deformer to the Puller mesh.

8. Select the Puller mesh. Create a Texture Deformer. Set the deformer's Direction to Normal. In the Texture slot, assign a Noise texture.

9. We don't want to have the Texture Deformer to act on the Puller mesh at the start of the simulation, but rather have it gradually ramp up to full strength over, say, 25 frames. To do this, key the Envelope attribute on the Texture Deformer.


10. Set the Texture Deformer's Offset to be half of it's strength, but in the opposite direction. This will keep the Puller mesh 'centered'. To do this, apply an expression:

textureDeformer1.offset=textureDeformer1.strength*-0.5

 11. Set an expression in the noise texture Time attribute:

noise1.time=time

This will make the noise texture flow over time.

12. Add some wind, gravity or other forces if you like. Now simulate!

13. Now we have a low resolution mesh. We need to make a high resolution version, but with extra details.


14. First thing to do is to apply a Smooth to the low res mesh. Mesh > Smooth, and give it 2 divisions. In my example, this gives me a mesh with ~200,000 faces.

15. Export this mesh as an alembic cache. Pipeline Cache > Export Selection to Alembic. This is quite slow! Save your scene as LowRes.

16. I recommend that you do the next steps in a fresh scene. Not only will this be faster, lighter and easier to organise, but it will be much easier to go back to the Low Res scene at any time and re-export any changes you need to make really easily. Once re-exported, you can very easily re-import the Alembic Cache file in the High Res scene, without any fuss.

18. In a new scene, import the Alembic cache. Duplicate it. Make the duplicate a nCloth object.

19. Constrain the nCloth to the Alembic mesh. Select the cloth, then the Alembic mesh and then create an Attract to Matching Mesh nContsraint.

20. Again, we want the constraint to 'guide' the cloth, rather than drag it too strongly. Here are the settings I use, but, of course, it will depend on the scene scale, and what you want the cloth to do.


Notice the Strength Drop Off ramp. This allows the cloth to move freely when it is near to the Alembic guide, but the constraint kicks in as the cloth moves away from the guide.

21. Now simulate this High Resolution cloth. Hopefully you will see that is follows the Alembic guide quite closely, but will also have some extra details. I have not changed any nCloth attributes apart from self-collision width. All the motion is made with the constraints.


Here is one I made earlier


High Resolution nCloth test from Daniel Sidi on Vimeo.