In my previous tests with the PhysX 3.2(.4) SDK (see the PhysX 3 plugin WIP thread), I couldn’t simulate a cloth (a simple mesh grid) on GPU with more than 33×33 vertices otherwise the simulation fell back to CPU. I was a bit suprised because I already created clothes with 50×50 or even 100×100 vertices with PhysX 2.8 SDK (see the PhysX test of MSI Kombustor). I also had some problems in CPU simulation with more than 60×60 vertices: the cloth was destroyed…
Yesterday I updated the PhysX 3 plugin for GLSL Hacker with the latest PhysX 3.3 beta 2 SDK because this new SDK brings many bugfixes and improvements for all PhysX modules including the cloth one (by the way, PhysX 3.3 has many API changes compared to PhysX 3.2 so you have to update many parts of your code, a simple compilation is not possible).
Here is the section of PhysX 3.3 beta 2 release notes related to the cloth module:
- Improved GPU cloth performance significantly with new parallel solver.
- Added tether constraints, which allow minimum amount of cloth stretching even for large gravity scales. See PxClothFabric.
- Added support for dynamic addition and deletion of collision primitives. See PxCloth::addCollision* and PxCloth::removeCollision*.
- Added triangle mesh collider support. See PxCloth::setCollisionTriangles.
- Added support for self collision and inter-cloth collision. See PxCloth::setSelfCollision*() and PxScene::setClothInterCollision*().
- Added direct access to CUDA particle data for graphics interoperability, see PxCloth::lockParticleData()
- Added PxRegisterCloth to reduce binary size by stripping unused code on platforms where static linking is used.
- Added methods setWakeCounter/getWakeCounter() (see the corresponding API documentation for details).
- It is illegal to call wakeUp/putToSleep/isSleeping() on a PxCloth that has not been added to a scene.
- Cloth solver does not use fibers any more. See PxClothFabric for changes in fabric API.
- Moved PxCooking.cookClothFabric() to extensions. See PxClothFabricCooker and PxClothFabricCreate.
- PxClothMeshDesc has been moved to extensions and now supports both triangle and quad representations. See PxClothMeshDesc.
- The scaling of damping and stiffness coefficients has been separated from the solver frequency and can now be set indepedently using PxCloth::setStiffnessFrequency().
- PxCloth::setInertiaScale() has been split into linear, angular, and centrifugal components. See PxCloth::set*IntertiaScale.
- Drag coefficient has been split into linear and angular coefficient. See PxCloth::setLinearDragCoefficient and PxCloth::setAngularDragCoefficient.
- Renamed PxCloth::lockClothReadData() to lockParticleData(). Added supports for update operations on the returned particle arrays.
- PxCloth::wakeUp() does not have a parameter anymore. Use setWakeCounter() instead to set a specific value.
I took my simple cloth demo and set the vertex density of the flag to 60×60 vertices and… that worked! Now the cloth simulation works fine in GPU and in CPU:
– Cloth simulation running on CPU (60×60-vertex mesh grid):
– Cloth simulation running on GPU (60×60-vertex mesh grid):
And here is a test with a flag made up of 100×100 vertices simulated on the GPU:
Good work NVIDIA PhysX team, now I can finish the PhysX plugin for GLSL Hacker…