Cloth simulator improvements

Can anyone give me some idea of appropriate values or ranges to use in the various settings field to get different effects? I’m having a hard time getting materials that don’t freak out, or are’t too smooth like rubber. There’s so many combinations of settings and it takes so long to experiment, and so many combos just cause it to act strangely.

New cloth is very good (and yes the cache is huge pain). Thanks Luca_Rood for your work.
Btw. some people mentioned this python numpy cloth https://youtu.be/yHGz7nEI23E?t=1040. It is quite fast partially because numpy uses vectorized math operations (operating on whole arrays of data at once).
@Luca_Rood - does blender cloth sim uses this vectorization thing?
AFAIK C+ has some libraries, for working with vectorized data just like python has numpy lib, so It may be one way to speed things up.
And some test:
Blender28

5 Likes

@Luca_Rood I can´t remember exactly but I think I had a wrong value set and it was my fault :smiley: Your cloth improvements are great and what @JoseConseco did is awesome! How do you achive the wrinkles while sewing cloths?..

@Luca_Rood hi, thanks for your efforts! Are there any news about internal pressure? I work in archviz field and would be great to get high quality pillows out of Blender cloth sim.

Thanks!

1 Like

Next on the improvement list looks to be far better collision detection.
https://developer.blender.org/D3712

More accurate, less buggy, multithreaded, the works (not committed yet, but it will likely be in 2.8 very soon). :smile:

2 Likes

@File_xor, do you mean like edge bevel weights? Currently Blender stores two of these properties on edges, namely the bevel weight, and the crease, both of which have specific purposes, and thus could not be used for cloth without clashing with other features. As much as this is an invaluable feature, I’m afraid it cannot be implemented until we have some form of generic weighting for edges, similar to what we have for vertices. And implementing such system is not as trivial as it might seem, as it has deeper implications within Blender.

@Ascalon, unfortunately we can’t provide any recommendations here without knowing your specific case. The cloth implementation is sadly still very dependent on many variables, such as mesh density. There is no specific set of parameters that will work every time (in that case we wouldn’t need parameters at all :smiley:). Could you provide more specific information about what you want to achieve, and Ideally a .blend file? Then everyone will be more able to help with your issues.

@JoseConseco, very nice result you got there! Regarding Rich’s Python cloth implementation, yes, I am aware of it. In fact I have even met with him before, and we shared our thoughts on simulation techniques.

While vectorization can indeed significantly improve computation time, the actual reason for the speed of his simulator, is the time integration method. He is using explicit time integration, which has the advantage of very cheaply computing the next step, but on the other hand, it has several disadvantages. It is very sensitive to stiffness, requiring smaller and smaller time steps to maintain stability when increasing stiffness. It has poor global convergence, with propagation speed being proportional to the step size, meaning that any motion takes a long time to travel through the cloth, unless you use tiny time steps (this gets worse the higher the density of the mesh).

With those limitations in mind, it is obvious why most real-time cloth demos have only very stretchy cloth, as any higher stiffness causes instability or the need for many sub-steps, causing it to no longer be real-time. The implicit time integration in Blender doesn’t have any of those limitations, and provides full global convergence on every step, but the trade-off is that a big system of equations has to be solved every time, which is much more expensive to compute. So in the end, implicit simulation will give more realistic results, while explicit simulation can be fast for low-density and relatively stretchy meshes.

I think that his simulator has a lot of potential as an interactive tool, to generate static meshes (which seems to be his intention as he applies the simulation to a shape key), while the Blender simulator focuses on getting good dynamic results for animation and VFX. I guess my point with all this rambling is to say that even with vectorization Blender’s cloth will not be as fast as an explicit simulator (though Blender can also do real time at the resolutions of most of these kinds of demos). But yes, vectorization would benefit some of the computations we are doing, however I do not plan to implement this within the current simulator, but I do have some big plans for the next several months, so keep an eye out for some updates in the future, but don’t hold your breath :stuck_out_tongue:

@VjaceslavT, a general tip for getting nice wrinkles is to use high tension/compression stiffness, and also relatively high shearing. The defaults are actually a bit low. For most materials I would turn tension/compression up to about 200~250, while shearing can be more flexible, anywhere between 0.5 to values close to those of tension/compression in certain materials. Just keep in mind that higher tension/compression/shearing stiffness generally leads to more wrinkles, while higher bending stiffness reduces wrinkling.

@marcoG_ita, I will implement it shortly.

@Ace_Dragon, still far from perfect, but it should bring a definite quality improvement, and is much faster! :slight_smile:

3 Likes

Thanks for the response. I’ll give more details:

I’m doing a test with a shirt on character who is raising one arm and lowering the other. I have been able to get some good results, but I have not been able to achieve some of the effects I’m after, and some settings seem to behave strangely.

Topology (before subsurf)

First problem is that if I use a low amount of quality Steps, then it often just implodes. Here’s the same settings with 20 Steps and 5 steps (mostly default settings. 50 tension and compression, 1 shear and bending, 0 damping, 1.0 mass.)

image

Second is damping. Using a bunch of it makes the mesh break out in spikes! I used a lot here so it’d be easily visible, but it seems to happen at lower amounts too. (Used 50 damping for each, otherwise same settings as above.)

I don’t have pictures for the third, but it seems that if I use Tension or Compression stiffness above 100, then the whole thing freaks out and explodes. I can get some nice results if I keep stuff below that, but I can’t get good stiffness. I’d like the collar to be stiff enough to hold itself up. Right now it is pinned, but that means it doesn’t respond to collisions itself. I want to have the shirt be fairly wrinkly, but the collar stiff.

I originally made this shirt in Marvelous Designer (its been retopologized) and there I could set the collar to be a stiff material like leather, and the shirt to be silk or cotton, so it worked. That’s the effect I’d like to get in blender. I assume i’m supposed to use the stiffness scaling fields to give different settings to different areas, but since I can’t get any stiff material at all, I haven’t had much luck.

Here’s a file with the body and shirt (please do not redistribute): https://drive.google.com/file/d/1XR55T7-VN_J-5SRol_i_VfDCSOMDoAkC/view?usp=sharing

I also thought your answer to JoseConseco about how the different cloth sims work is interesting. Do you know how it works in Marvelous Designer? That’s the best cloth sim experience I’ve had, although I haven’t tried Maya cloth.

Thanks for your hard work, and for the help!

2 Likes

Indeed 5 steps is much too low to get any reasonable results, I should probably change that default. 20 is about as low as you can go to get decent sims. At 20 steps, I had a hard time getting your cloth to an unstable state, thus I assume the unstable tests you showed were the ones with 5 steps, right? I would simply recommend that you keep the steps at 20 or higher.

Setting damping to 0 is generally a bad idea, as it will allow the cloth to oscillate indefinitely and can lead to instability (think a car suspension with only springs but no dampers). And besides, in the real world cloth has significant damping as well.

That example you gave with the spikes is a classic example of bending instability. Due to some characteristics of the Blender simulation system it was unfortunately not possible to solve the bending forces implicitly, thus they suffer from the same issue as explicit solvers. The good news is that bending springs aren’t as unstable as linear springs, so at usual values this isn’t too much of a problem. The rule of thumb is to generally keep damping of each component below it’s corresponding stiffness value.

With the bending being computed explicitly, the bending stiffness/damping values are the main factors determining how high you should set the quality steps. With higher values requiring more steps. Consider that the simulation is especially sensitive to bending damping. That said, with your simulation at just 20 steps, I went as high as 50 for the bending stiffness without any instability (keeping damping at 2).

I think this should give you some guidelines as to how you can get started. Oh, and a little note on leather is that it is an isotropic material, so for that you want to set shearing to the same value as tension, while for cloth, shearing should generally be much lower, due to it’s significant anisotropy. Just as a starting point, I used these values on your mesh, with decent results: stiffness: 50, 50, 3, 2; damping: 5, 5, 5, 2; And I scaled both shearing and bending on the collar to 50. These values are quite close to default, so I dind’t do much… You can play around much more to get the results you want. The main thing here is that I set the steps to 20.

Lastly, besides bending, collisions are also very sensitive to the amount of steps, and if you are having trouble with collisions you might have to turn the steps up. Also, keep in mind that the new collision system will be merged soon, so that should help with your simulation.

Regarding Marvelous Designer, I don’t know. They don’t have any documentation on that, as far as I can tell. Though they focus on static cloth generation, which is very different from dynamic cloth, and although it can do that as well, you don’t see it used much in films…

2 Likes

Thank you! Just to clarify, I was using 20 steps except the one time I noted that I had used 5. But now i’ve turned the steps up more, and I’m using better damping and shear/bending values. It’s working much better! I think I am finally saved from the problems of importing new cloth poses from Marvelous Designer (and all the topology restrictions that comes with that…)

EDIT: Is there any documentation that goes into detail on some of these other settings, like Impulse Clamping? And does the Collision Quality field also affect self collision?

‘cloth-improvement-branch’ (ceddd2b ) merged with ‘master’ (0a96851 , with sm_2x support restored)
win64 build: https://drive.google.com/open?id=1DHX_AIzKkCy_BfOZ6PVCGltaWpFB-are

@drgci, while I did make new build last Sunday, because I’ve noticed two new commits in branch, I am planning to do one last 2.79 build, just before ‘master’ and ‘blender2.8’ merge together (probably in October, or whenever the merge happens)
After that, we can probably safely switch to 2.8 alpha/beta builds, thanks to Luca’s porting work :stuck_out_tongue:

1 Like

https://twitter.com/LucaRood/status/1044979412683436032

15 Likes

Man, it’s hard to believe we’re in an era of many of Blender’s longstanding issues just melting away. If this keeps up, then 2.8x is going to start a golden age for Blender.

I say 2.8x because the original release will not yet have the new VFX and parametric capabilities promised by Everything Nodes. Now if they can produce some massive optimizations for editmode.

6 Likes

Fantastic job ,i will say again blender 2.8 will be a revolutionary release
The numbers of features and improvements is outstanding

With the collision changes having landed in 2.8, I am deeming the cloth implementation in Blender 2.8 sufficiently complete to drop support for the cloth-improvements branch. The branch will no longer be updated, and I strongly advise everyone to use Blender 2.8 instead. There are several critical issues in the cloth-improvements branch, that were fixed when porting to 2.8, and it is not practical to back-port them. Also note that there has been a huge improvement to the collision system when porting to 2.8.

I will continue replying here to any issues regarding cloth in Blender 2.8. I will also port the remaining features to Blender 2.8 as soon as I can.

Thanks @xrg, for posting this update. Note that more details about the 2.8 cloth port can be found here: https://developer.blender.org/T56596

Thanks for the positive comments, everyone!

@Ascalon, 20 steps should generally suffice for your mesh (for most material settings). I suspect you might be running into some collision bugs in the cloth-improvements branch, so I would advise you to try it in Blender 2.8, and I expect you will get better results. I will write documentation once I have more time. And yes, the collision quality affects both object and self collisions, and I think this is more clear now in the new Blender 2.8 UI.

@Sim_Piko, it is best to switch to 2.8 for any cloth work already, as the implementation there is already much better than the one in the cloth-improvements branch. Simulations done in 2.8 can always be imported back into 2.79 if necessary for production, so the workflow shouldn’t be much different than using the cloth-improvements branch anyway.

13 Likes

@Luca_Rood
Aye Aye, Captain! No more 2.7x Win64 builds from me then.
(I’ve already figured out how to build 2.8 with sm_21 support, so I’m ready for 2.8x.)

Congrats on porting clothsim to 2.8 so far, and good luck on writing the missing stuff. :slight_smile:
Now excuse me, I need to figure out all those parameters the new clothsim has now.
(that is, until the documentation is made)

1 Like

congrats on having your hard work landing on the master branch.

Will be there some kind of documentation how to use the new cloth system ?

Well Luca only just said so. Maybe you missed it…:

Great work, Luca!

greetings, Kologe

congrat luca!
and thanks for your work :slight_smile:

After some testings, I found high bending stiffness/dumping makes cloth very unstable and even maximum quality steps (80) cannot stabilize it.

I also found an issue which users may encounters; Users will probably assumes self collision distance should be less than minimum edges length, but actually it should be less than half of minimum edges length.

Thanks for the nice comments.

@Sim_Piko, haha, alright. And thanks for providing builds for all this time! It really helped people to test and report issues, accelerating the progress of the simulator :slight_smile:

@File_xor, yes, high bending stiffness, and especially damping, do cause instability. This is due to some limitations in the way cloth is handled in Blender, not allowing the use of implicit integration for bending. Bending being computer explicitly, means that the higher the values, the more “Quality Steps” will be necessary. Note that 80 is just a soft limit, and you can still type in higher values.

Also, the stiffness levels you are testing are most probably beyond reasonable levels for most types of cloth. For most garments, I generally am able to get good results at 50 steps or lower (up to 100 on rarer cases). On the other hand, if what you are intending to simulate is something more stiff, like thick paper, or even sheet metal, that’s definitely possible, but will likely require steps in the hundreds (I have gone up to 250 steps for some really stiff simulations).

And regarding the self collisions, yes, half the minimum edge length should give you stable results (actually often a bit less than half, more like 40%, due to collision triangulation). This comes from the distance being computed for both sides of the cloth. However, usually it is undesirable to use such distances, and you would actually want something much smaller. Unless there is a specific thickness desired for the cloth, the rule of thumb would be to use as small a collision distance as possible that still keeps collisions reliable.

1 Like