Search Unity

Physics Obi Particle Based Physics (Cloth, Rope, Fluid) thread

Discussion in 'Tools In Progress' started by arkano22, Jun 30, 2015.

?

Performance vs compatibility

Poll closed Oct 9, 2015.
  1. I don't care about performance, keep my data intact please.

    0 vote(s)
    0.0%
  2. I don't care if I have to re-do some stuff, as long as it runs faster.

    14 vote(s)
    100.0%
  1. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
  2. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I tried messing arounnd the the mass of the particles. While it makes a difference to how the cloth behaves in general, it doesn't seem to affect the cloth explosion that I'm getting unfortunately.

    I tried setting up something similar with your trench coat guy in the test scene and it worked fine, so it is possible. There must be something different about my setup :\
     
  3. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I have discovered that I only get the problem when "Simulate In Local Space" is checked. If I uncheck it, the cloth does not explode when I go into ragdoll mode, and behaves normally.

    Unfortumately I really need to simulate in local space to get any sort of stable results.

    Does this information give you a clue as to what might be going on?

    Also, when in ragdoll mode, the cloth particals are pushing the rigidbodys around a bit. This causes everything to just vibrate, even when the partical mass is turned down extremely low. Is there a way to have the cloth be affected by the rigidbodies, but not affect them back at all?
     
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Zomby!

    My guess then is that there is some sort of feedback loop going on. Make sure your particles aren´t affecting a rigidbody in your character's root object (or more precisely, the object where your solver resides). This would cause the particles to move the reference frame in which they are simulated, causing energy feedback (and eventually making things explode). In world-space mode, the reference frame is fixed, so this feedback disappears.

    There's currently no way to make a non-kinematic rigidbody affect particles but not the other way around. We´ll think about allowing it.
     
  5. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Ah ha! Now it's starting to make sense. I have the solver in the character's pelvis bone in order to dampen the movement when the character is doing flips and stuff, and this bone also has a rigidbody so what you're saying could be true.

    I'll experiment with it tonight.

    I would very much be in favor of a mode where the cloth cannot affect other rigidbodys. I guess that that mode alone would fix my problem.
     
  6. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Ok so the plot thickens. If I put the ObiSolver in a new object, in the root of the scene, totally independent from the character, the cloth STILL explodes when I go into ragdoll mode (with simulate in local space checked).

    UNLESS the ObiSolver object's transform is exactely 0,0,0 position, 0,0,0 rotation and 1,1,1 scale. Then it doesn't explode. I understand that this makes "local space" equivalent to world space.

    If I move it by a mere 0.1 meters then the cloth will explode.

    I'm not sure what this all means, but I'll continue to experiment.
     
  7. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Sorry for the tripple post.

    I've actually got it to crash with your trench coat guy sample scene now. It goes like this:

    Open the sample scene
    Expand the guy's hierarchy
    Game Object > 3D Object > Ragdoll...
    Assign all the correct joints to the correct fields > Create
    Re-add all the joints to the Obi Collider Group that were in there before
    Disable Animator component in Man_trenchcoat
    Press Play

    This will always crash for me. If I turn off "Simulate In Local Space" then it does not crash, but the behavior is very bad.

    Can you test if this also crashes for you?
     
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Zomby,

    Yes, this bug has been reported a couple weeks ago, and fixed in the development code since then. An update is about to be released that fixes this and other issues.

    PD:There's a much easier way to reproduce it: just disable the character' root object, and re-enable it. BOOM. I don´t know how this obvious bug has been lurking around for so long.

    PD2: However the behavior described in your previous post (the one where you need to keep the solver at the origin) seems to have little to do with this. I´ll try to reproduce it and get back to you.
     
  9. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    arkano22 likes this.
  10. eyier

    eyier

    Joined:
    Aug 29, 2016
    Posts:
    6
    Hi! arkano22
    Obi Cloth is great!
    I'd like to consult about CharacterCloth with rapid animation.
    For example when I covered a person with a simple tunic.
    When playing the rapid animation on which I embark at the front, the part of the body sticks up.
    I adjusted the radius, but cloth particles sinks into a ball...

    I would be grateful if you could give me some advice.
    Thank you.
     
  11. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Hi Arkano,

    I'd like to request a new constraint. I'd like to be able to have the vertices be pulled gently back towards their skinned positions. I know there is the skin constraint, that lets the vertices move basically within a ball centered on the skinned position, but I would like some force that tries to pull them back to the center of the ball.

    Basically a spring attached to the skinned position I suppose. Would something like this be possible?

    Also, I'd really like that mode where the cloth cannot influence other ridgid bodies please. Is this likely to happen?
     
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Zomby,

    Such effect is already implemented. Use "skin stiffness" < 1 and "skin radius = 0". This will basically make the skinned particles spring back to their skinned position whenever they exceed the skin radius (with skin radius == 0, that means always). A larger skin radius will let particle move freely within the radius, and only spring back once they get outside of it.

    About the "particle kinematic rigidbodies", we are implementing it :). So it will happen for the next release.
     
  13. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Interesting! I'll try that out tonight.

    And good news about the"particle kinematic rigidbodies"!
     
  14. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi there!

    It depends on what your setup is, if you're using skin constraints or not... I assume you are. In this case, make sure your ObiSolver interpolation mode is not set to "Interpolate", because that will introduce a 1-frame delay in simulation with respect to animation.

    If you need to give more details about your setup, write to our support email or raise a question at Taiga (you´ll find both in the "contact" section of our webpage)
     
  15. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi all,

    I´m proud (and relieved) to announce that ObiCloth/ObiRope/ObiFluids 3.1 are about to be released. There are tons of improvements: better friction model, super-stable pin constraints, greatly reduced memory consumption, support for triggers, skinned volume constraints, per-particle layer property... but in this post I wanted to focus on a very popular request: compatibility with Final IK and Puppet Master (and the like).

    ObiSolver now lets you decide where to update the simulation: during FixedUpdate, after FixedUpdate, or in LateUpdate. This last option implements an adaptive target frequency scheme to eliminate jittering due to variable timestep, enabling us to simulate physics outside of FixedUpdate.

    Video or didn't happen? :) Here, a soft tummy simulated using cloth on a character with IK:
     
    Deckard_89, ElectroMantis and jmjd like this.
  16. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Using the skin constraint the way you suggest sort of works, but it seems to be much more powerful than I was hoping for.

    Even with stiffness turned all the way down to zero on both the constraint and the individual particals, and SOR factor turned down to 0.1 (minimum) and just one interation, it's still REALLY powerful. I want a much more subtle effect.

    To be honest I'm not even sure if the stiffness makes any difference at all.
     
  17. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Yes, skin stiffness runs in a pretty tight range.

    We'll make sure to widen the range in the next update for use cases like yours. In the meantime: if you're in a hurry and don't really mind having to re-initialize your cloth, go to ObiCloth.cs and look around line 392 for something that looks like this:

    Code (CSharp):
    1. ObiSkinConstraintBatch skinBatch = new ObiSkinConstraintBatch(true,false);
    change it to this, and re-initialize:

    Code (CSharp):
    1. ObiSkinConstraintBatch skinBatch = new ObiSkinConstraintBatch(true,false,0,0.02f);
    That should yield a much wider stiffness range, and at about 0.5 stiffness you should already notice quite a big difference. (let me know if otherwise!)
     
  18. tinyant

    tinyant

    Joined:
    Aug 28, 2015
    Posts:
    127
    Hi,I wonder that if it's possible to bake cloth simulation data(Like Bake cloth animations) by the Obi Physics into animation file or other format file. Next time i just play the animation without runtime simulation ? I am using This cool Obi cloth make a CG film. I want make pre physics solver for cloth.The artist can choose the best solver for play certain animation.

    Thanks for reply @arkano22

    I Made an issue on taiga.
     
  19. tinyant

    tinyant

    Joined:
    Aug 28, 2015
    Posts:
    127
    youtube.com/watch?v=rXaiO3wm5NM

    Something like this in IClone 6.

    Bake cloth animation when simulate the cloth physics each frames.
     
  20. kenamis

    kenamis

    Joined:
    Feb 5, 2015
    Posts:
    387
    To do this, even if you're able to create the Topology object before runtime but creating a skinnerMeshRenderer at runtime, won't you still need to initialize or call GeneratePhysicsRepresentationForMesh after adding the obiCloth component to the renderer?
     
  21. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    @arkano22 I just saw your post explaining that we can now set the simulation order to LateUpdate() so we can now use Final IK & Puppet Master. For me, that's massive. Good job! :)
     
    arkano22 likes this.
  22. RyanDunne

    RyanDunne

    Joined:
    Mar 30, 2017
    Posts:
    13
    Can't find Obi rope on forum, but clicking "Add pin constraint" isn't doing anything.
     
  23. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi,

    You need to select at least one particle to add the constraint to. See:
    http://obi.virtualmethodstudio.com/tutorials/pinconstraints.html

    To enter particle edit mode (and be able to select particles), click on the "Edit particles" button in the rope inspector.
     
  24. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi there!

    Well, not if you use a prefab. If you are instantiating a skinnedMeshRenderer at runtime, and you know what mesh it will be using at edit time, nothing stops you from simply creating a prefab out of it all (skinnedMeshRenderer + preinitialized ObiCloth). This works even if you are reassigning bones at runtime or stuff like that.

    As long as the topological data of the mesh doesn´t change (add or remove vertices, alter triangle ordering, etc) you don´t need to re-generate the topology or call GeneratePhysicsRepresentationForMesh().

    When calling GeneratePhysicsRepresentationForMesh(), obi generates a list of particles and several lists of constraints that represent your mesh. These lists are serialized by Unity, so they will be saved together with the prefab and no setup/initialization of any kind will happen upon instantiating it.
     
  25. kenamis

    kenamis

    Joined:
    Feb 5, 2015
    Posts:
    387
    okay thanks. What about if the scale of any of the bones is different than when setting up the prefab at edit time? It appears the cloth simulation doesn't take that in to account on a skinnedmesh. I can see that would throw a wrench in the calculations for a lot of the contraints.
     
  26. tinyant

    tinyant

    Joined:
    Aug 28, 2015
    Posts:
    127
    When My complex cloth vertexes is about 25000, The cloth simulation is too slow.How can I Optimize that?@arkano22
     
  27. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    @arkano22 I see that 3.1 is live. Does it contain all the alloc-fixes that you sent me over PM?
     
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Anders!
    Yes it does. :)
     
    AndersMalmgren likes this.
  29. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi,

    Distance, bend and volume constraints all rely on trying to keep a "reference" value: in case of distance constraints, a rest distance between particles. If altering the scale of a cloth in realtime, this would require to essentially re-create all constraints each time the scale changes.

    To adapt to different import-time scales, the ObiMeshTopology class has a "scale" parameter, that allows you to generate the topology of a mesh at any given scale.

    So unfortunately the only way to scale cloth simulation at runtime in the traditional sense of the word is to scale the space the simulation is taking place in.

    In Obi's case, this means: setup the solver for local space simulation, then change the solver's scale. All simulations taking place in the solver's space will be scaled with it. In the general case where you have a character with bones that can be all independently scaled, it would require using a separate solver for each bone, and separate cloth pieces for each one. I´d say it could be done with a lot of effort, but would probably be quite unpractical.
     
  30. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi there,

    25000 cloth vertices in a single mesh is simply way too much for realtime use. Game characters usually have less than 5000 simulated vertices in them, even in extreme cases. Depending on your exact setup, you could:

    - Use the "Optimize" option to get rid of fixed particles that do not contribute to the simulation.
    - Reduce the amount of constraint iterations in the solver.
    - Use cloth proxies and a simpler simulation mesh.
    - Use a larger timestep.
     
    tinyant likes this.
  31. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Good news everyone! I just gave the new version a go. I attached Obi Rigidbody components to the rigidbodys in my ragdoll and it has both stopped the constant jiggling and cured my exploding mesh problem altogether!

    There is still one problem however. It looks like both the ragdoll colliders and the cloth particals cannot push each other. I was hoping that the ragdoll parts would still be able to push the cloth particals, but not visa versa. This creates a situation where, if I activate ragdoll mode while my character is jumping though the air, she will freeze in place, suspended by her own clothing, which is in turn suspended by her, and they will very slowly sink down to the ground.

    This is only really a problem when simulating in world space. I assume that it sill happens when simulating in local space, but becuase the cloth automatically moves with the character it is much much less noticeable. Seeing as I intend to simulate in local space anyway, this might not really be a problem...

    At any rate, this is by far the most useable version so far so I am pretty happy!
     
  32. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    I´m glad it solved your problems, Zomby!

    You can try adding the ObiRigidbody component to your rigidbodies, and activate "kinematic for particles". This way the particles won´t apply any impulses on the rigidbodies, but the rigidbodies will be able to move the particles around.
     
  33. bcv

    bcv

    Joined:
    Sep 1, 2012
    Posts:
    34
    Hello, thanks for the quality work on the obi plugins. I bought obi rope and cloth. Was wondering what's the best way to smoothly translate an obi rope instantly ?

    I tried creating a prefab which includes an obi rope and upon instantiation I move the prefab into place an the rope goes crazy as if the act of translation is affecting the physics, is there a way to move the rope without affecting velocities ?


    Thanks
     
    Last edited: Jun 14, 2017
  34. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    That is exactely the way I set it up.

    I agree that the particles don't apply impulses on the rigidbodys, and I agree that the particles collide cannot move through the rigidbodys, so in a sence the rigidbodys can move the particles. But still, the rigidbodys will sit on top of the particles in the air and sort of hover there. At least when simulating in world space. Does it matter what layer the particles are on? I tried all three different "Simulation Order" settings.
     
  35. tinyant

    tinyant

    Joined:
    Aug 28, 2015
    Posts:
    127
    Thanks very much!
     
  36. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Get this error after 3.1 update

     
  37. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Pleasde check on 5.5 alot of compile errors
     
  38. AKQJ10

    AKQJ10

    Joined:
    Feb 9, 2012
    Posts:
    33
    Hi, @arkano22 Thanks a lot for this awesome tool!
    I have used the ObiBone component on a ponytail hair braid. It works but seems the hair braid can't hold its original shape. With gravity applied, the hair braid ends up hanging downwards like a rope. Any way to add the elastic factor (0-1), so the obiBone can lerp between its original shape and the simulation driven by the particles?
    Thanks in advance.
     
  39. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Anders,

    3.1 requires at least Unity 5.6 (says so in the store). Won't compile as-is on 5.5, since a few API changes were made to take advantage of new 5.6 stuff.
     
  40. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Thats sad to hear, alot of effort for us to move to 5.6 so was hoping to delay that for a while
     
  41. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    If you're still using 5.5 and Obi Rope 3.0, I´d say wait until Unity 2017 comes out as we´ll probably have to change more stuff in Obi for compatibility. 3.1 does include improvements for pin constraints and some other things, but maybe it is not worth it to upgrade your entire project to 5.6 just for this if things are working ok for you.
     
    hopeful likes this.
  42. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    thanks,

    The solver is working slow on the Ryzen platform, but maybe its no change with 3.1?
     
  43. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I brought my project home to work on it over the weekend, and now I see this in the error console:

    Anyone got any idea as to why? My work machine has a Quadro K4200 on Windows 7 and my home machine has a 980ti on Windows 10 if that helps.
     
  44. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    What Unity version are you using at home? UnityStandardCoreBackfaces is basically a copy of UnityStandardCore, with minus sign added on one line. There's no reason for this error to pop up if the Unity version is 5.5 or up (Obi 3.x)
     
  45. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    No, there are no Ryzen-specific optimizations in 3.1.
     
    AndersMalmgren likes this.
  46. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi all,

    Just wanted to let you know that we´ve opened our own forum:

    http://obi.virtualmethodstudio.com/forum/

    This will let us organize topics better, since having a single thread here in the Unity forums for all Obi assets is far from ideal (and quite confusing for those starting out). I will gradually turn my attention to our forum and be less active in this thread, so my advice is: if you own Obi or are planning to get it, join us! ;)

    cheers
     
  47. Andre220v

    Andre220v

    Joined:
    Mar 17, 2016
    Posts:
    1
    Hello everyone, I am new to the Unity forum and need help with the Obi Cloth Plugin.
    In fact, I have a good result on the Pc platform using the asset when it comes to collisions. In other words, the collision works well in the Unity editor. My problem is when I try to run the application on Android smartphones, the cloth effect works fine but no collision. Has anyone gone through something similar or do you know why there are different results between PC and mobile?

    Obs: I'm sorry for the bad english, i really not good with it
     
  48. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I just assigned all my objects around my Obi rope object to a new layer, and suddenly, despite me having an Obi collider group, the rope falls through the floor (still attached at the ends, though). What did I miss?
     
  49. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi roberteker,

    If you're using 3.1, it introduced the concept of per-particle layers. This means that if you move an already initialized rope from one layer to another, the particles themselves will keep the layer they were created on (you can enter edit particle mode to change layer on a per-particle basis, so half of the rope can be on a layer and the other half in a different layer for instance).

    If you just want all particles in the rope to be in the same layer as the rope itself, click on "Set particles to layer" in the rope inspector.

    cheers,
     
  50. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Hi Andre,

    What Android/Unity/Obi versions are you using? Also, what Android device are you running this on?