PhysX 3.4: cloth missing many (documented) features?

Maybe I’m doing something terribly wrong here, but I don’t think so because I’ve poured over the docs and snippets and seem to be doing everything by the book.

I have a bunch of PxCloth actors in my scene. I initialize them the way the cloth snippet shows how to, and then let them do their thing in the simulation. My scene has a ground collider and gravity enabled. I don’t call setTargetPose at all…I just let the cloth actors fall and collide and such. I also enable the eSCENE_COLLISION flag on all my cloth actors.

However, the following settings seem to have issues (and I get the same results for both CPU/CUDA mode):

setLinearDragCoefficient has no effect on cloth, regardless of value. (edit: apparently only works w/setTargetPose)
setAngularDragCoefficient has no effect on cloth, regardless of value. (edit: apparently only works w/setTargetPose)
setting the eSWEPT_CONTACT flag (in combination with the scene eENABLE_CCD flag) causes all collisions to stop working (cloth actors fall through all scene colliders).
enabling inter-cloth collisions (by setting setClothInterCollisionDistance and setClothInterCollisionStiffness to non-zero values) has no effect…no cloth actors collide with each other in a meaningful way no matter what values are assigned. (edit: my rest offset values, solver iterations and inter-collision iterations all needed to be dramatically increased…doing that caused inter-cloth collisions to occur, but lack of point-triangle collisions still makes it an impractical solution for realistic cloth).
enabling self collisions (by setting setSelfCollisionDistance and setSelfCollisionStiffness to non-zero values) seems totally impractical for meshes that aren’t very dense…since it doesn’t seem like any particle-triangle collision tests are performed on the cloth against itself…by the time my collisionDistance is high enough so that particles collide with each other enough to prevent self-intersections, it’s higher than some edge lengths in my meshes which causes lots of jittering. Setting the stiffness lower isn’t a very good solution since then collisions begin to fail.
the various cloth solver frequency settings don’t seem to yield consistent results. For example, increasing stiffnessFrequency has the effect of decreasing all acceleration/velocity in the cloth. A cloth with twice the stiffness frequency will be affected by gravity half as much…so stiffnessFrequency can’t really be used to increase solver accuracy because it changes the nature of the whole sim. Similarly, damping doesn’t seem to be timeStep independent…if I increase the overall number of simulation steps, the effect of damping on the cloth increases as well. The docs seem to suggest damping is dependent on stiffness frequency, and stiffness frequency is defined at a rate per second…so doeesn’t that mean it should be substep independent?

I know PxCloth 3.x is a rewrite of PxCloth 2.x. Is it just in the very early stages of implementation right now? Because unless my setup is very wrong it seems like it’s lacking a lot of core functionality.

Hi Ivanisavich,

I would like to point out that we have a new cloth simulation library called NvCloth. Our engineering effort is currently focused on that. Maybe you can give it a try? It is based on the same solver backend that was used in PhysX 3.3/3.4. You can find it here

The self- and inter-collision features are indeed not using point triangle collision, and might not be a great fit for the problem you are trying to solve. It should be possible to ignore particles when enabling self-collision using PxCloth::setSelfCollisionIndices() which can get rid of the “Edge lengths are shorter than collision distance” issue, especially when the vertices of the cloth are not uniformly spread. Are you trying to do multilayered clothing? Or do you have a different use case?

Flex also has some support for cloth collision. You could look at the samples to see if that might be a viable option.

Changing the timestep of the simulation will always have some effect. Some components are more sensitive to this than others. That is why it is generally recommended to use fixed time steps.

I couldn’t reproduce the change in gravity when changing the stiffness frequency in NvCloth, and I don’t remember there being any changes to that part of the code since branching from PhysX. There might be something else going on here.

Hi mtamis,

I looked into NvCloth, but documentation on it seemed limited. Is it fundamentally different than PxCloth? I guess if it has the same pitfalls as PxCloth then I’ll have to look elsewhere for a solution…my application is tailored for realistic offline simulations, whereas it seems like PhysX cloth in its various forms is designed specifically for games.

As for setSelfCollisionIndices, I looked into that but I don’t think it would suit my purposes. My application allows users to take arbitrary geometry and turn it into cloth, so it would be difficult to programmatically set the indices in such a way that it will work for any arbitrary mesh, and even if I develop some kind of system where I set indices based on distance-to-adjacent-particle info or whatever, then what will be left is a cloth mesh with portions that don’t collide at all, which isn’t what I’m after.

I guess I’ll keep an eye on Physx/NvCloth and hope that eventually point-triangle collisions will be supported. Until then I’ll have to find another solution. :)

NvCloth is based on the low level solver that was used in PhysX and APEX. We did make some improvements, but it sounds like we you will run into similar issues with it as you already mentioned. NvCloth is mainly geared towards realtime applications (like games), so I’m not surprised that it is not doing what you are looking for.
Note that we do have point-triangle collision for cloth vs static meshes. But it is currently limited to 500 triangles (on the static mesh), which is probably not enough for offline simulations.

This thread has been quiet for quite a while now, but I am really hoping to get some answers. Is PhysX/APEX/NvCloth capable of producing multi-layered clothing, cloth on top of cloth that will collide with itself, in real time?

Very specifically, in something like Unreal Engine 4? I don’t mean the Latch to Nearest value, where cloth will drive other cloth… I mean, is it possible for two pieces of cloth to be simulating and still collide with each other?

Example; you have a skirt on a character, and you have another piece of cloth layered on top of that skirt, like a long tunic, or something like that, and have the two pieces of clothing simulating with little to no clipping but rather interacting/colliding with each other.

If something like this is possible, please, tell me what I need to do to make it happen, because I have been trying, without any success, to do it.

NvCloth does have self- and inter-collision features, but I’ve found that they are not very stable. It requires a lot of tuning to get good behavior out of it.

Multilayered cloth can be set up in two ways. Either merge both layer meshes in to a single cloth mesh and enable self-collision or simulate both layers as separate cloth objects inside the same solver with inter collision enabled. I’m not sure if any of these features are exposed in Unreal.

We are doing internal research on improving multilayered cloth for realtime characters, but we can’t make an estimation right now when those improvements will be available in NvCloth.

I will try this, thank you very much for your help.