Pages

Monday 18 May 2015

Blending nCloth caches using Blendshapes


With many thanks to David Knight, nCloth guru, I present his method for blending two nCloth caches on a per vertex basis. You can have one half of a nCloth following one cache and the other half following a different cache.



1. Create two simulations for your cloth sim. Use a copy of the mesh for each sim. If the meshes do not match exactly (same number of vertices) then this method of blending will not work.

In my example I have one wide simulation and one which is narrow.


2. Cache your simulations.

3. Make another copy of the mesh, label it 'blendMesh'

4. Select the two nCloth meshes and finally shift-select blendMesh. Create a Blend Shape deformer (Create Deformers > Blend Shape)

5. In the Blend Shape attributes, set the weights for each input to 1.0



6. Assign weights per vertex. To do this open the Paint Blend Weights Tool (in the Edit Deformers menu). Do not manually paint blend weights because the sum of blend weights on each vertex must be equal to 1.0. Painting will not allow fine control. You can edit blend weights per vertex  manually in the Component Editor, but it is also possible to use an image set weights.

7. I have created some ramps in photoshop and saved them as TIF files. First I created the blengMap_H ramp, then I inverted the image (ctrl-I) which will subtract the value of each pixel from 1.0. That inverted image becomes blendMap_H_inverted. This will ensure that when the two ramps are added together the result will equal 1.0



I followed the same procedure to create the vertical ramps. The version of the ramp you need to use will depend on the orientation of your simulations. It's useful to have any combination of ramps saved in a library.

8. Apply the blendMap ramp to the Blend Shape deformer. Choose one of the Targets on the Blend Shape node and then under the Attribute Maps section, press Import and browse to where the blendMap ramps are stored.



Once the blendMap is assigned to the first target, chose the second target and assign the inverted blendMap to it.

That's it. You should now have a mesh which one end follows one cache and the other end follows a different cache.




No comments:

Post a Comment