Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Cloth Folding
#1
Hello, I am thinking about changing over from unity cloth to Obi Cloth.
I hope to use Obi Cloth and later Rope for the "classic" sail cloth use case.

I think it should all work, but one thing I could not find any info about, except here on the forum where the founder has said that Obi Cloth cannot be scaled.

With Unity Cloth, scaling the transform will actually fold(albeit awkwardly) the cloth. Is it possible to simply fold an Obi Cloth the same way?

Say I have a square sail cloth hanging down.
I want to pull the bottom particles up (1 fold)and then I want to pull the middle particles up(second fold) and then pull up the particles between middle and top for the final (third fold).
Best case scenario(what im trying to achieve): The sail looks packed up and not catching any wind.

First off is it possible to modify particles like that at run time? And second is it possible to set this up for a ship with 30 sails? And finally have you ever tested how many sails can be simulated at once? Would you think 200 sails(outlier max case in my game) is performant maybe I can set the simulation iterations to 2 instead of 1 as I saw in your YT tutorial thats the main "performance slider" for obi cloth.


Thanks a lot!
 I hope these assets can bring my game to life! I already have a lot of work done and a build demo but with Unity Cloth it just isnt it right now.

Cheers
Reply
#2
(04-10-2022, 09:27 PM)obitwokenobi Wrote: I think it should all work, but one thing I could not find any info about, except here on the forum where the founder has said that Obi Cloth cannot be scaled.

With Unity Cloth, scaling the transform will actually fold(albeit awkwardly) the cloth. Is it possible to simply fold an Obi Cloth the same way?

Hi!

Yes, you can just scale the transform that the cloth is attached to. This can be the cloth transform itself, just like Unity's cloth.

The limitation of "not being able to scale ObiCloth" is the same as with Unity's built-in cloth: scaling the cloth will scale the attached points, instead of making the cloth physically smaller. If you want to make the cloth smaller at runtime, you need to scale the solver component instead.

(04-10-2022, 09:27 PM)obitwokenobi Wrote: Say I have a square sail cloth hanging down.
I want to pull the bottom particles up (1 fold)and then I want to pull the middle particles up(second fold) and then pull up the particles between middle and top for the final (third fold).
Best case scenario(what im trying to achieve): The sail looks packed up and not catching any wind.

Yes, this will all work fine.

(04-10-2022, 09:27 PM)obitwokenobi Wrote: First off is it possible to modify particles like that at run time? And second is it possible to set this up for a ship with 30 sails? And finally have you ever tested how many sails can be simulated at once? Would you think 200 sails(outlier max case in my game) is performant maybe I can set the simulation iterations to 2 instead of 1 as I saw in your YT tutorial thats the main "performance slider" for obi cloth.

"Amount of sails" isn't really a valid metric, since we don't know how complex each sail is or how often they're updated. It all depends on the spatial resolution of your sails and the spatial resolution of your simulation.

Assuming "normal" resolution, 30 sails per ship sounds like a lot, 200 is downright impossible. Let's assume each sail is 20x20 (400 vertices/particles per sail, which is rather conservative). That would mean 400*200 = 80000 particles. Using 2 iterations per frame would mean 80000x2 = 160000 particle updates per frame. No CPU-based physics engine will be able to handle this much, and most GPU-based ones will have a very hard time. And this is considering a single ship in your entire game!

If you really need that huge amount of sails, I would advise to animate them procedurally since simulation isn't really an option no matter the engine you choose.

kind regards,
Reply
#3
Thanks a lot for your detailed reply!

You gave me a lot of enthusiasm to get this done with Obi.

I want to just clarify, right now my square sails only have 144 vertices/particles, thats the same for big and small ones, So I can optimize the smaller ones down to less even.

Anyway 30 sails is probably the max amount of sails ill have on the biggest ship in game. And I could bring it down to 20 or 18 even for the biggest ships if needed.
Then having 5 of those in a scene at once will be a very rare outlier case (180 sails at once, divided over 5 ships)(almost 200)
An "average" scene could have anywhere from 10 sails total to 100 sails total, multiple smaller, medium ships etc.
After all the smallest ship can do with just 1 or 2 sails total.

Anyway 200 * 144 = 28.800 ( But thats too high because the smaller sails have less than 144)
28.800 * 2 = 57.400 particle calculations per fixed update... on the rare outlier case
29.000 particle updates on an average scene.

What happens when a cloth is torn? Do some particles get "simulated out", does the cloth become more performant as it loses particles?
And finally my last question, since its all using Burst and Jobs, do you think 40-50k particle updates per fixed update is performant or what would you think is about the max particles per fixed update, even if its just a very rough estimate?

Again thanks!

Cheers
Reply
#4
(05-10-2022, 01:21 PM)obitwokenobi Wrote: Anyway 200 * 144 = 28.800 ( But thats too high because the smaller sails have less than 144)
28.800 * 2 = 57.400 particle calculations per fixed update... on the rare outlier case
29.000 particle updates on an average scene.

29.000 is doable, depending on your hardware.

(05-10-2022, 01:21 PM)obitwokenobi Wrote: What happens when a cloth is torn? Do some particles get "simulated out", does the cloth become more performant as it loses particles?

Quite the opposite: tearing generates additional particles, the more you tear a cloth the costlier it gets to simulate it. I fail to see how tearing could possibly result in less particles/vertices, that's usually what happens when you merge vertices (the opposite of tearing) or collapse edges in a mesh. Taking particles out would simply open gaping holes in the mesh, which is not what you'd usually refer to as "tearing".

(05-10-2022, 01:21 PM)obitwokenobi Wrote: And finally my last question, since its all using Burst and Jobs, do you think 40-50k particle updates per fixed update is performant or what would you think is about the max particles per fixed update, even if its just a very rough estimate?

Very much depends on your target hardware, your quality requirements, etc. Here's a detailed performance analysis:
http://obi.virtualmethodstudio.com/performance.html

9 * 2552 = 22968 particles, 1 substep, 2 distance iterations @ 17 ms/frame with collision and self collisions, which is roughly 60 fps just for the cloth. Without collisions/self collisions performance would improve enough to hit 30000 particles in the same time per frame. Still, unless sail simulation is absolutely paramount for your game's mechanics I'd go the procedural animation route.

kind regards,
Reply