In traditional Unity setups, Cloth physics runs solely on the CPU, along with all other processes. This often leads to significant performance bottlenecks. So, what's the solution? Utilizing the power of the GPU! While this doesn't mean that calculations are entirely offloaded to the GPU, the process leverages both the CPU and GPU for optimal performance. The GPU Cloth Physics tool aims to maximize quality while optimizing performance. For detailed information, please visit the Inspector page, where every aspect of the tool is described.
Go to file
Schaken 2480317ade Update Readme.md
Updated it to match the wiki
2025-01-31 20:48:45 -05:00
Readme.md Update Readme.md 2025-01-31 20:48:45 -05:00

Why GPU Cloth Physics?

In traditional Unity setups, Cloth physics runs solely on the CPU, along with all other processes. This often leads to significant performance bottlenecks. So, what's the solution? Utilizing the power of the GPU! While this doesn't mean that calculations are entirely offloaded to the GPU, the process leverages both the CPU and GPU for optimal performance. The GPU Cloth Physics tool aims to maximize quality while optimizing performance. For detailed information, please visit the Inspector page, where every aspect of the tool is described. Below is the index map of this Wiki. GPU Cloth Physics

What is so special about this??

Optimized Collision OPTIMIZATION! While trying to push as much as possible to the GPU, that is not where it stops! A part of the process is the details. Creating a weight map creates a sub mesh which is a cutout of the part of the mesh which has physics, reducing the amount of information needing computed.

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! >Weightmap Design

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:

Tutorials:

Other:

Credits