26-01-2021, 03:04 PM
(This post was last modified: 26-01-2021, 03:11 PM by josemendez.)
(26-01-2021, 01:38 PM)Merch137 Wrote: I was hoping it wasnt that expensive as its advertised as very efficient.
Cloth is expensive enough that you should consider whether to use it or not, if it's only for visuals.
(26-01-2021, 01:38 PM)Merch137 Wrote: I also read this is being done onĀ [/size][size=small]cpu not gpu which causes concern for the performance as well.
GPU simulations scale better with larger workloads, but they generally have a higher base cost than CPU implementations. Even a very simple cloth takes 1 ms to simulate in the GPU, but several larger cloths cost just 1.2-1.3 ms. By comparison, a simple cloth can take 0.2 ms in the CPU, and several large ones can take 20 ms. This means that if you have just a handful of units, it would be considerably faster to use the CPU.
Also, copying data from the GPU back to the CPU is a big no-no, as it's extremely slow. This is required for two-way coupling with rigidbodies, as Unity's rigidbody physics engine works in CPU. So GPU cloth means no rigidbody interaction. Copying is also required for any custom rendering that does not involve compute shaders to build the mesh or vertex/fragment shaders that take input as structured buffers, so you get less rendering flexibility too. Those are the main reasons that made me opt for a CPU implementation instead of a GPU one: I wanted inexpensive cloth for simple effects, that could interact with rigidbodies, could be easily scripted, and could be used with any custom shader/material.
We're working on a GPU backend for Obi. However it will come with many limitations, and will only make sense for games where cloth is the main feature. You can see some early work here:
https://www.youtube.com/watch?v=BQzZzQMl7x8