Cloth simulator improvements

It is true.
I tried to animate disabling of self-collision. But it was not really an acceptable option. Although piece of cloth was small, the animation was finishing by a bounce with the four corners obviously intersecting themselves to take place of the opposite one.

So, I had to animate all material and damping settings to limit number of wrinkles that was increasing while cloth was shrinking.
Less wrinkles means less collisions due to them.

Finally, it would not be a bad thing to have an automatic adaptation to preserve the same wrinkle size.

Well for missing features directly under cloth category, there is always ā€œcloth tearingā€ which is missing.

If we are talking in general about blender cloth combined with physical simulations; blender cloth doesnā€™t support rigid body collisions. But of course thats outside your scopeā€¦ and into Lukasā€™s territory.

@zeauro, Iā€™m glad to hear it was indeed the self-collision (I was afraid there was something really bad going on :P), though ideally the self-collisions would perform equally when shrunk, Iā€™ll take a look at that part of the code, to see if I can improve the performance (to at least get linear performance across scales). About the wrinkling, afaik there shouldnā€™t be an increase in wrinkling at smaller sizes, though I might have overlooked something about mass recalculation when implementing the dynamic mesh feature, Iā€™ll investigate (There should be no need to compensate properties, as they should already be proportional to edge length, but like I said, I might have missed something about mass).

@yii7, tearing is indeed quite compelling, and theoretically quite straight forward. However, it raises several implementation issues, for instance, dynamic splitting might be the obvious choice, but the resulting variable vertex count makes compatibility with things such as motion blur much more complicated. On the other hand if we go with a pre-split mesh, there is the issue of how to pre-compute the splits, or having to propagate them throughout the frames when it happens, or even having user-defined split locations (which to me seems a bit boring). Those, and probably other things, have to be discussed before even starting to work on an implementation, however I am willing to give the tearing thing a shot, as it is indeed quite an exciting feature. I might open a design task at developer.blender.org, to get some feedback on what people think would be the best implementation. Regarding rigid-body collisions, Iā€™m not sure what you mean. You can activate collision on top of the rigid-body, however only the cloth would react to the rigid-body, and not the reverse (Applying cloth forces to rigid body would really straight forward to code, if only the solvers werenā€™t totally independent, making it pretty much impossible to have their time-steps interact).

@ZedDB, today Iā€™ve played around a bit with implementing a rudimentary cloth solver in python/numpy, and I can say pretty certainly that it would be almost inevitably impractical to get any respectable performance out of it, even with the plainest of explicit solvers. You can copy the mesh data into numpy really quickly, however the processing for the simulation itself is what kills it, as there are just too many operations that simply can not be performed with the efficient vector/matrix functions that numpy provides (implemented in C). I can only assume that Rich Colburn used something like cython to get the performance showed in the video.

Now, regarding the general status of my cloth developments: I am looking into implementing a more proper air resistance model, as the current ā€œair dampingā€ just applies a uniform resistance force to the vertices, while it should at least be applying forces dependant on the projected area of the faces onto a plane perpendicular to the motion vector (That is, short of implementing a full fledged aerodynamic model).

I am also looking into some papers on better implicit cloth solvers and collision models, which though being quite some work, if implemented, would fix the main issues of the current simulator (bad collisions, performance, and bending). Though I might initially try to do some external implementation (addon) through a python/cython/c interface.

Finally, I would like to say that though I am actively working on improving the cloth simulator, donā€™t expect new features to be ready really soon, as I have taken this on just as a side project, and canā€™t work on it all the time. But Iā€™m sure weā€™ll slowly move towards having the greatest cloth simulator of all :evilgrin:

coool!
I like Blender cloth sim and I use it a lot, I also made a demo.

After I sperimented a lot, the most missing feature is a way to reproduce elastic fabric, something that shrink until get a collision point. like spandex or stretch denim

ofcourse, dynamic subdivision fo the mesh while simulationg etc would be amazing, but maybe too much right? 8)

thankyou!

I played a bit with the cloth sim to ā€œfitā€ clothes to 3d models and havenā€™t managed yet to get believable results. How did you manage to make this, in detail? Have you already made a tutorial about it?

What I meant with was exactly the problem you mentioned (2 different solver making a combined effort for a complex situation), so the problem its not only in cloth but in rigidbodies too. For example like a trampoline effect; where the force of the rigidbody is counter applied because of cloth stretching properties.

Also for things like rubber bands or similar effects where a rigidbody is attached to the one end of a rubber band / rubber tube and the stretching forces drive the attached rigidbody. Ofcourse these can be faked and maybe they should be faked since they make the simulation too complex.

Anyway it was just and ideaā€¦


while looking at that cloth shrink youtube,ā€¦ still its not ideal, its hard to get real good looking clothes.
as for the shirt, some areas reach the body stop shrinking while other parts dont, sides should shrink to.
Maybe some tool to symetrically shrink shape till collision (aply able link a paint brush).
The things i asked for earlier where about the same thing, its pretty hard to design believable correct clothing.
the problem part is perhaps more the tools/ways we have for shaping clothes.

iā€™ve used skin modifier etc and other methods, but its quite complex to create, something real realistically.
while the youtube looks nice, its not how my shirt fits my body while looking nice, it isnā€™t even close to the real thing.
So maybe if you wnt to improve clothing simulator, think of ways /tools of how we could better create realistic clothing.

@MmAaXx, first of all, nice demo you got there! About the shrinking feature, itā€™s already there, and you even have several different options. First, under the ā€œSewing Springsā€ panel (not sure why), you have min and max shrinking properties. There is also the ā€œRest Shape Keyā€ feature, which allows you to make the mesh conform to some arbitrary shape once the simulation starts. An finally you can now also use the ā€œDynamic Meshā€ feature (available in the daily builds), to animate the clothā€™s rest shape throughout the simulation.

Regarding dynamic subdivision, it is another one of those features (like cloth ripping), that is theoretically somewhat straight forward, but in practice has several implications. First of all, dynamic subdiv would only actually make sense with triangulated meshes, so it would probably be wise if I implemented some sort of delauney triangulation (like some people suggested), before looking further into the subdiv stuff. Now, what actually makes dynamic meshes problematic is not so much their implementation, but how they are interpreted later, so like I said about cloth tearing (in my previous post), meshes with changing poly count make things like motion blur a lot more complicated. There is also the issue that I have no idea how the Blender point cache handles dynamic meshes, so to implement something like this I would have to read up quite a bit (I should probably look into how fluid sim is handled in that regard). So as this deals with many of the same issues as cloth ripping, it might be a good idea to throw these into the same bucket, and tackle them somewhat together, however Iā€™ll only get to trying to implement these features after I tackle some more pressing issues.

@yii7, yeah, I get your point. I would like to note, that this kind of interaction does not really make for overly expensive simulations, and shouldnā€™t be much more expensive than the ā€œusualā€ collision computations, as it is quite simple to apply the forces to the rigid body after the collision is computed. However it is really not feasible unless the solvers are integrated. And it would indeed be too great of an undertaking for me to integrate all the required stuff (unless I get hired to work with on the Blender physics full time ;)).

@Razorblade, ā€œtools of how we could better create realistic clothingā€ is not very specific. However Iā€™m taking note of all the suggestions and my own ideas, and compiling some kind of a ToDo list. Of the features that would improve realism, I have mentioned my intention to implement a better air resistance model, and even the the possibility of replacing the current implicit solver (again). If you have some concrete observation on a specific behaviour of the cloth sim that you think should be improved, I would be glad to look into it.

I would like to note to all, that I am looking into your suggestions and their feasibility, and will update the feature list (in the original post), with more planned features, once I am more certain of what goals I can actually achieve here.

thanks for the reply!
about the shrink I noticed it now! thanks!

About realism, I had a discussion with angavrilov on iirc.
I was saying that we should have a better precision for Minimum and Repel Distance parameter of cloth collision.
It must be equal or higher than one-thousandth of piece of cloth. So, for a piece of cloth of one meter, we have gaps of several milimeters where there is none in reality.
He explained to me that it would lead to too many computations and that should not be a problem if we use a solidify modifier considering simulated surface as outer shell of our cloth.
In reality, there is no distance between cloth sides of a fold.
I have the feeling that if we had one more digit of precision, a collision margin expressed in tenths of milimiter instead of milimeters; we could use simulated surface as the middle reference for cloth thickness. Solidify modifier will add thickness equally on both sides. This would results in sides of folds that could touch themselves.
IMO, the result would be more realistic.

Hi.
Could someone provide a sample .blend showing the correct way to use the new Dynamic Mesh?
Thanks.

@zeauro, the way that collisions are currently calculated is actually really bad, and the margin and repel parameters should not even exist, but are required for the current method. With small margins the collisions become less and less reliable, so just reducing the minimum margins is not really practical (and even if I did that, such patch would in all likelihood not be accepted into blender). However, implementing a completely different and better collision system is on my ToDo list, but is actually something quite complicated, so it will take some time.

@YAFU, I have attached a little demo here. Note that I have left the cloth modifier invisible, so you can see just the animations on the mesh first, then you can view the (already backed) cloth simulation by just enabling the visibility of the cloth modifier. It is really simple, any animation applied to the mesh before the cloth modifier will affect the dynamic mesh cloth simulation, so in the demo I have added a shape key animation, an armature animation and an animation with the ā€œSimple Deformā€ modifier (any deformation modifier can be used, provided it is before the cloth modifier). Note that the subsurf modifier is positioned after the cloth modifier, and thus has no effect on the cloth sim.

Attachments

DynamicMesh.blend (1.77 MB)

@Luca Rood, thank you very much, right at this moment was discovering how to do it.
You must scale the mesh containing the cloth modifier. I had thought that somehow scaling was automatically copied. Here I used Copy Scale Constraint and I can see the effect.
Cloth Dynamic Mesh.zip (229 KB)
I will study your example too.

So, what happens when the mesh becomes too big and not enough geometry/vertex so that the simulation result correct and consistent? Is there any way to dynamically subdivide the mesh?
Edit:
I will read the whole thread again, maybe youā€™ve already answered that.

@YAFU, glad you got it working. Yeah, only deformations on the actual cloth mesh are taken into account. Note also, that you can do much more than just scaling (see my demo above for that). Also, nice that you used a constraint, I didnā€™t think of that, and didnā€™t even know it worked :stuck_out_tongue:

About the resolution of the geometry, that can indeed be a problem when using very extreme deformations. Indeed, dynamic subdivision would resolve that issue. See my thoughts on dynamic subdiv in my reply to MmAaXx in post #28 (second paragraph).

yes yes, just talking about scaling because it is what I was trying to achieve since Iā€™d seen your video in first post :slight_smile:

Iā€™ll do more tests. Thank you.

Hey everyone,

Today I bring a new (minor) feature, I have implemented the ā€œfriction scalingā€ I had mentioned in my first post. You can find the patch here.

But I also have bigger developments, in the form of a major cloth UI redesign proposal, which can be found here (Includes patch for testing purposes).

I intend to provide (linux) builds for people to test these changes, however, it is super late here right now, so Iā€™ll try to do that tomorrow.

Anyway, I just wanted to give you guys a quick update, so I guess thatā€™s it :slight_smile:

IĀ“m so happy to see development in this area, Thanks Luca! UI changes look good to me :slight_smile:

@Luca, It seems like Rich Colburn posted an update on the cloth sim on his youtube channel:

As it says ā€œPreview of tools to be demonstrated at the blender conference.ā€ Iā€™m guessing that he will be at the blender conference this year too. If you are also going to be there, maybe you two can figure something out to collaborate on the blender cloth system. I donā€™t mean that you have to help him with his cloth simulator, only that you could perhaps try to figure out what you can work on so you donā€™t try to improve stuff that will be replaced if his cloth sim is merged into blender (Or vise versa).

Here are the promised test builds (Linux):

@BrilliantApe, thanks for the support, Iā€™m glad you liked the UI (now you can test it with the build above, if youā€™re on Linux)

@ZedDB, like I said in my previous posts, I am a bit sceptical about Richā€™s work, considering it has been a year since his Bcon talk, and we have seen no code released by him whatsoever. He claims that he has to finish some things (apparently indefinitely) before release. Also note that ā€œPreview of tools to be demonstrated at the blender conferenceā€ doesnā€™t sound much like a code release to me either, and I wonder how long heā€™ll be ā€œdemonstratingā€ things without actually giving us anything (BTW, I also donā€™t see him on the presentation list this year). On the plus side, I will be attending the conference this year, so if he is indeed there, I can sure query him about this stuff.

Just saw the timewarp video on the 2.78 RC release notes, nice work! Since youā€™re working on improving Blenderā€™s cloth engine, do you know if anyoneā€™s experimenting with Pixar-style flypapering/collision-untangling, like in their 2003 whitepaper? ( http://graphics.pixar.com/library/UntanglingCloth/paper.pdf ) They developed it for Monsters Inc apparently, itā€™s an algorithm that turns off and flattens collision physics within intersection boundaries detected by flood-fill, to keep clothing from getting stuck on the wrong side of collision and cloth meshes.

Hereā€™s an example scene that deliberately tortures a mesh in the manner solved in that whitepaper: http://pasteall.org/blend/index.php?id=43379