Updated it to match the wiki |
||
---|---|---|
Readme.md |
Why GPU Cloth Physics?
What is so special about this??
This looks Complicated..
I see you noticed! This is because it is. If simple is the goal then you would have never went looking for a different option outside the default Unity Cloth Component. Luckily for you, there is a Discord which I personally maintain, and I will walk you thru anything you need. After doing this a few times and getting familiar with it, then it is pretty easy. It just takes time and practice. In the end, your game players will thank you! | >![]() |
What type of physics is this?
The Position Based Dynamics method (PBD) is basically a method to do physics simulation. Comparing to other traditional methods like mass-spring system, FEM, SPH and FLIP, PBD is not physically accurate because no inner force of the system is calculated from physical laws. But a huge advantage of PBD is that it's very fast, and produces visually plausible simulation results, which makes PBD perfect solution for simulation in games.
In PBD, physics is simulated by inter-particle "constraints", this feature makes PBD quite flexible since we can just keep adding new types of constraints to the system to simulate the physical properties we want.
PBD is originally designed for cloth simulation, but newer PBD methods could supports new types of objects like rigid body and fluid.
Another reason we choose PBD is because it's easy to parallelize so that we could run it on the GPU to accelerate the simulations.
GPU computing in Unity
Unity now supports GPU computing feature by adapting Microsoft's DirectCompute technique into unity. The compute shaders are written in HLSL and can utilize GPU computing in a similar fashion as CUDA: the kernels are defined in compute shaders, you pack and pass data from CPU side through compute buffers, then after compute you read data from CPU side and use it in whatever way you want. To view recorded comparisons, Check this out!
Cloth
The way position based dynamics handles cloth simulation is quite simple: each vertex in the cloth is treated as a particle with various inter-particle "constraints", and the algorithm simply needs to make sure none of the constraints are violated at every frame.
An important thing to note is that none of these constraints are physics based; they are simply introduced to make sure the particles behave a certain way that looks correct. The distance constraint, for example, simply makes sure two connected vertices don't stretch too much beyond their starting distance. The bending constraint makes sure two connected triangles don't bend too much beyond or below a certain starting angle.
Table of Contents
Components:
- BoxColliderHelper
- CapsuleColliderHelper
- GPUClothSimulator (Main component)
- MeshColliderHelper (Not working yet, see Road Map.)
- PlaneCollider
- SphereColliderHelper
- SphereColliderPair
Tutorials:
- Setting up your first GPU Cloth Physics
- Applying GPU Colliders
- Making Weightmaps in Blender and/or Gimp
Other:
- public Structs and Enums
- GPU vs CPU Computing
- Discord
- My Store
- Road Map (Things to do!)