Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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. VictoryWorks

    VictoryWorks

    Joined:
    Oct 2, 2015
    Posts:
    7
    Perfect, thank you.
     
  2. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    305
    I'm thinking about using Obi Rope to create interactive patch cables in VR. Is there any way to use the available constraints so that when the end of a rope pinned (with a handle or otherwise) to the jack, it sticks out along the axis of the jack's input? Maybe also a way to stiffen the first few particles that are closest to the jack?
     

    Attached Files:

  3. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    @arkano22

    Have you seen this video? The first minute is very impressive. I would love to see this with your cloth system!
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Yes he has and did an answer too just a few page ago :D
     
  5. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    When pressing "Generate" on my ObiMeshTopology, I keep getting this error. It seems to depend on the mesh I'm using as the input. Just by changing a few polys on the mesh it can change it from working to getting this error and visa versa.

    IndexOutOfRangeException: Array index is out of range.
    Obi.ObiMeshTopologyEditor.UpdateBordersMesh () (at Assets/Obi/Editor/ObiMeshTopologyEditor.cs:171)
    Obi.ObiMeshTopologyEditor.UpdatePreview () (at Assets/Obi/Editor/ObiMeshTopologyEditor.cs:47)
    Obi.ObiMeshTopologyEditor.OnInspectorGUI () (at Assets/Obi/Editor/ObiMeshTopologyEditor.cs:78)
     
  6. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    @arkano22
    Any thought on possibly getting your idea up-and-running? :) I know the guy making the GPU Cloth Tool is coding something similar.
     
    Last edited: Feb 25, 2017
  7. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    I saw that, thanks!
     
  8. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    How do you install Obi 3.0? After I download it from the asset store and install it, I keep getting the "Welcome to Obi" window with the install button at the bottom. Every time I click it I get an "Installation Fail" window, saying that "Obi could not be installed automatically. You can try manually moving..." Is there a better way to install it? The demo scenes all seem to be working fine, it's just that Welcome window keeps popping up. I'm running Unity 5.5.0f3. Thanks.
     
  9. OnlyVR

    OnlyVR

    Joined:
    Oct 5, 2015
    Posts:
    55
    I still canot replicate this simulation. The issue is the cloth goes through the body (MeshCollider). It slow down the cloth and deform it just a little bit. Actually, I cannot reproduce even the first scene from your youtube demo video. I've tried to use EthanBody (I added Mesh Collider) and ClothSheetHD - the same issue. Increasing Collision Constraint doesn't help realy.
    Could you add/upload the scene with Ethan or probide the key settings?
     
  10. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Well, quoting the install window: you can try manually moving "/Obi/Gizmos" and "Obi/Editor default resources" directly under Assets. ;). That's all that is required to install Obi. The sample scenes will work fine even if you skip this installation step, but none of the custom editors (particle editor, skin editor) will work.
     
  11. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    I already implemented a full multigrid solver (following this: http://matthias-mueller-fischer.ch/publications/hpbd.pdf) and discarded it during testing. The problem with cloth multigrid is that you need several meshes at different levels of detail for the solver to work. Usually you´d want the user to provide the highest level of detail mesh and automatically generate the lower levels, and that's what I did.

    The problem with this is that generating high-quality simplified versions of an arbitrary mesh is not trivial at all. Most algorithms I tried (including the one described in the paper) have problems dealing with self-intersections and symmetry, and it is not possible to control the output mesh topology, so each level ends up having very different topological features. Adding this to the fact that position-based dynamics in its non-continuum form is not topology independent, means that the resulting cloth has "patches" of different perceptual stiffness, depending on the topology of the underlying levels.

    In plain english: the cloth is stretchy in some parts while excessively rigid in others, causing a rough, non-smooth looking surface. Also working with less than 100% stiffness gives weird results, for this same reason.

    So I decided to leave it out of 3.0. Maybe in the future I´ll come back to it, but it is not a drop-in replacement for the current solvers as I had hoped, and having to deal with multiple constraint levels adds steepness to the already steep learning curve -specially when it comes to scripting custom stuff on top of Obi-.

    Edit: here's a video of it in action. As you can see the regular solver gives much smother results, and while just a couple multigrid iterations help a lot in achieving less stretchy cloth, the result is just ughh...ugly.
     
    Last edited: Feb 26, 2017
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    No chances of that happening, at least not in the near future :). Actually the underlying solver and math for that video and Obi are pretty much the same, however his is implemented in the GPU, while Obi is CPU only. Also there's a ton of stuff that a100% GPU cloth system cannot do, one of them is two-way interaction with Unity's rigid bodies (you'd have to involve the CPU for that, and GPU-CPU memory transfer can get pretty expensive). That's the main reason why I developed Obi, so it makes no sense to switch to GPU right now.
     
  13. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Can you provide the mesh that causes this error? I´d like to take a look at it and see what's wrong.

    cheers!
     
  14. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    You can take advantage of bend constraints. Instead of pinning/fixing just the last particle to the jack, fix the last two. This will allow Obi to measure bending at the end of the cable and keep it straight where it meets the jack.
     
  15. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hello,
    I give up. I try Obi 3.0 with skinned meshes and still Unity crashes:

    Unity Editor [version: Unity 5.5.1p4_f10174ef3e2d]
    libOni.dll caused an Access Violation (0xc0000005)
    in module libOni.dll at 0033:288de4c5.
    Error occurred at 2017-02-26_221340.
    F:\Program Files\Unity\Editor\Unity.exe, run by User.
    54% memory in use.
    32650 MB physical memory [14786 MB free].
    32650 MB paging file [15968 MB free].
    134217728 MB user address space [134215466 MB free].
    Read from location ffffffff caused an access violation.
    Windows 10 Pro 64-bit, i7-4790K, 32GB RAM, GTX 970 4GB


    My steps generating crash:
    1. New scene
    2. Adding character to scene
    3. Adding empty game object and adding to it Obi Solver script
    4. Creating Mesh topology from skinned mesh (skirt, Vertices: 3552, Edges: 10736, Faces: 6912, Total Area: 0.4616659, Total Volume: 0.04826963, Closed: False
    5. Adding Obi Cloth script to Skinned Mesh Renderer (skirt) in character object tree
    6. Adding to Obi Cloth created in step 3 Solver
    7. Adding to Obi Cloth created in step 4 mesh topology
    8. Initialize Obi Cloth (button Initialize) - everything look good - Status: Initialized
    9. Click on play ... and crash ?

    What I'am doing wrong?
    This is hard to try your asset with constantly crashes and without actual documentation. On your page most of tuts are for 2.0 version.
    Can you make a actual tutorial for create cloth for skinned meshes ?

    Thanks.
     
    Last edited: Feb 27, 2017
  16. OnlyVR

    OnlyVR

    Joined:
    Oct 5, 2015
    Posts:
    55
    Arcano, could you provide the key settings of the first scene from youtube video with Ethan?
     
  17. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    As typical, I can't get it to go wrong now :p

    Next time it goes wrong I'll be sure to send it to you.
     
  18. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    305
    Do I need to manually add bend constraints to particles? Or are they automatically created? I don't think I'm seeing a difference when I adjust the parameters on the bending constraint component in the inspector. What is the range of values that should be used for Max Bending?

    Also, I'm trying to "Fix" the end particles in code, rather than with the editor tool so I can do it at runtime. However I can't seem to get them to stay... the code seems to suggest that the "Fix" button just changes the particle's mass to Mathf.Infinity and then also its inverse mass to the inverse, but that seems like that would just make an extremely heavy particle. I must be missing something?

    Would it be possible to make the particles more stiff near the jack so that it gradually bends?

    Thanks.
     
  19. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi Aaron,

    All constraints except for tether and pin constraints are automatically created. If your rope has very high resolution (above 0.5) and/or is very long, you´ll have to increase the amount of iterations spent in bending constraints in the solver, as the default (3) is very low.

    Max Bending should be in the range of <0, 0.1>, more or less. 0 means the constraints will try to avoid any bending (how successfully depends on the amount of iterations you let them perform), larger values will allow more bending.

    A particle of infinite mass is impossible to move, collisions or constraints won't affect it . Which is just what we want in a fixed particle :). Also, you´ll need to set their velocity to zero, since inertia does not magically disappear just by setting the mass.

    And, most importantly, you need to tell the solver you´ve updated the particles. For performance reasons, all particle data arrays aren´t copied every frame to the solver. You must tell Obi what has been updated and when to perform memory transfers. To do this, just call actor.PushDataToSolver(ParticleData.INV_MASSES); when done fixing particles trough code.

    cheers,
     
  20. Yang_Sir

    Yang_Sir

    Joined:
    Sep 19, 2015
    Posts:
    6
    arkano22:
    Hi,the tear is not useful.I cannot define the shape in which a cloth piece will tear.Why?
     
  21. arkano22

    arkano22

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

    Of course. The most important settings have to do with ensuring proper collision detection:

    - Add an ObiCollider component to the mesh collider, set its collider type to either "Thin One Sided" or "Solid (Thin One Sided yields better quality assuming the collider is static) and slightly increase its thickness (0.05 in my case).

    - Increase the amount of distance constraint iterations to 10-15, depending on your cloth mesh density.

    - Increase the radius of your cloth particles to ensure no gaps are left between them. This is specially important if your collider has "spiky" features that could poke trough holes in the particle representation of the cloth.

    Edit: Oh, also make sure you provide an ObiCollisionMaterial with non-zero friction to either the ObiCollider or the cloth itself. If you don´t provide one, by default collisions will have no friction and the cloth will slide right off the collider :)

    cheers,
     
    Last edited: Feb 27, 2017
  22. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Well, that's not much information. Does the cloth tear at all? Does the cloth tear in a different shape that the one you painted? Does it tear too easily? What values are you painting in the tear resistance channel? Maybe you have a too high or low resistance multiplier?
     
  23. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi Petersx,

    There's a couple tutorials on how to create cloth for skinned meshes in the docs, both of them apply as-is to 3.0:
    http://www.virtualmethodstudio.com/obi/tutorials/unitychanclothing.html
    http://www.virtualmethodstudio.com/obi/tutorials/proxycharactercloth.html

    Regarding the crash issue you report, I cannot reproduce it with any of the meshes I´ve tried. Can you share the scene (or mesh) that causes it? Also It's hard to tell what's happening, specially without a stack trace. If you could share the full crash log it would be really useful :)
     
    Last edited: Feb 27, 2017
  24. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hi,
    Last crashdump you can download from: here
    Ok - above two examples are ok - but for me are insuffucient. I try to create effect with unitychan model but I can't.
    What are the parameters for unfixed particles ?
    1. mass ?
    2. radius ?
    3. skin radius ?
    4. skin backstop radius ?
    5. skin backstop ?
    6. skin stiffness ?
    I understand that after change above i have to press button with bucket icon ?
    In Obi Distance Constraints (script) I set Stretching Scale to 0.7 and Stiffness to 0.5 (according to tuts) - what about Slack ?
    I will be grateful for any help.
     
  25. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hi,
    Why after some tests of play/stop in particle editor cloth going up ? (see screen)
    Why after play/stop in particle editor character animation is baking into character ?

     
  26. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    1. Mass doesn´t matter here, as no collision with dynamic objects is taking place.
    2. Doesn't matter either, for the same reason as mass.
    3. Skin radius is expressed in world space units, it depends on your character scale. For unity chan at scale 1, should be around 0.5.
    4. Leave at default.
    5. Leave at default.
    6. Leave at default.

    Yes, after setting a value in the property field you have to click the bucket fill icon to apply it to all particles.
    Stretching Scale should be set to the default (1), not 0.7. It is not mentioned anywhere in the tutorial.
    0.7 is for compression stiffness, slack isn't mentioned either, leave at default (0). But it really depends on the effect you're after.
     
  27. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    According to your instruction - no success - cloth isn't blocked by legs :( (of course cloth is on another layer)


    Maybe Obi3.0 not working with Unity 5.5.1p4 ? This is a clear new project - only Obi and Unitychan packages.
     
    Last edited: Feb 27, 2017
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Obi works fine in 5.5.1 p4, actually it's the version I develop in. Have you added colliders to the legs, then added them to the ObiColliderGroup? Are collisions enabled in the solver?

    Edit: I´d prefer if you wrote to the support email or raised a question in our Taiga page, as that way we won´t clutter the forum with customer support ;)
     
  29. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hi,
    Where in your tutorial with unitychan character is written something about colliders ?
    You wrote:
    "To wrap up, this is everything we did:
    • Create an ObiMeshTopology asset and feed it our cloth mesh.
    • Add an ObiCloth component to our cloth object, which must also have a SkinnedMeshRenderer.
    • Add an ObiSolver component to any object in the scene.
    • Feed both the solver and the topology asset to our ObiCloth, and initialize it.
    • Tweak stuff (unfix particles, paint particle properties, adjust constraint parameters, etc).
    "
    If you don't prepare a good tutorial you have to reckon with newbie questions ;)
     
  30. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Ok - with collider added to legs - it's finally working
    Added capsule collider to empty object childed to each leg. Then in Shirts object added Obi Collider group (you didn't mention this) and then add collider from legs. Next in the solver we must add Collider Group (in this case Shirts(ObiColliderGroup).

    But I don't understand for what reason are skin parameters (skin radius, skin backstop etc.) if we must use colliders to achieve that effects ?
     
  31. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Collisions aren't involved at all in the tutorial, that's why they aren´t mentioned. The tutorial relies on skin constraints to prevent the cloth from deforming beyond its rest skin state -the skirt doesn´t collide with the legs at all, since skin constraints prevent the cloth from deforming beyond its rest state-. Btw collisions are explained in-depth in the collision section: how to set them up, how to choose their solver parameters, and how to use collision materials:
    http://www.virtualmethodstudio.com/obi/tutorials/collisions.html

    You're confusing collisions (which of course need colliders to work, not just in Obi, but in Unity in general) with simulation/animation blending, which is what skinning and skin constraints provide. If you have non-zero skin radius and zero skin backstop (the default values are 0.1 and 0 respectively), the skirt will not even touch the legs but rather partially follow the animation. I followed myself the unity-chan example step by step, using Obi 3.0 freshly downloaded from the store in Unity 5.5.1, and arrived at the intended result.

    When working with character cloth in realtime detecting and resolving collisions with the character body can get very expensive, and generally does not work well with very fast animations where limbs basically teleport from one position to a completely different one between consecutive frames. That's why skinning and simulation are blended in this way, this is not a concept I invented or something, just the industry standard. ;)

    Edit: Also, if you wish to talk about this more in depth, please write to support. I´m the one that usually answers all support questions, so we´ll just continue the conversation there instead.
     
    Last edited: Feb 27, 2017
  32. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hi,
    Thanks for your explanation.
    Did you perhaps explain the reason crash Unity from my example ?
     
  33. friuns3

    friuns3

    Joined:
    Oct 30, 2009
    Posts:
    307
  34. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Would the rope solver work in the WebGL player? It's completely CPU so I would think so? Do the ropes work by skinning arbitrary meshes? I assume so, but the Asset Store page doesn't state it outright.
     
  35. arkano22

    arkano22

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

    The crash happens at a point in the code where a mesh that should have a certain amount of vertices, has actually less. So there's a mismatch between the reported size of the mesh and the actual vertex array length. I´d need to see the actual mesh to be able to tell why is this happening. If you could share it with me i´d be most grateful!
     
  36. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Yes, we will add Android support once we upgrade ObiRopes to 3.x.
     
  37. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Ropes work in one of two ways:
    1.- Completely section-based procedural mesh. You can control the amount of section subdivisions and the overall shape the section.
    2.- Instance-based chain generation. You can provide one or more prefabs to act as chain links, and they will be instanced and updated along the rope.

    Custom arbitrary meshes are not supported, because ropes lack twist (orientation along their axis), that would be needed for accurate skinning. This use case is better supported by ObiCloth, anyway.

    Haven´t tried any of Obi's assets in WebGL, but we do have this task in our priority list. If anything, loading an external plugin (the actual physics library) is the hairy spot of the problem, if it loads correctly then I´m pretty confident it will work fine.
     
  38. LYMaifm

    LYMaifm

    Joined:
    Feb 28, 2017
    Posts:
    3

    Attached Files:

  39. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Good to know.

    Could you test a WebGL build and compare the size of the build with a WebGL build without Obi rope? That would be incredibly beneficial.
     
  40. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hi,
    I confirm I have the same cases. After initialize mesh and start editing particle - cloth escapes ;)
    I test the same meshes with native Unity cloth component and seems be ok.
    I would like to work Obi with meshes that working ok with native cloth Unity component.
     
  41. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi petersx,

    If you could please share one of the meshes that give this problem, or the crash, it'd be great. Without a way to reproduce the issue I cannot do anything to fix it.

    cheers!
     
  42. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi!

    Make sure the skinned mesh renderer transform is centered at <0,0,0> (not the root bone's transform, or the whole character transform), and that the scale of the mesh and the topology match.
     
  43. arkano22

    arkano22

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

    I´ve uploaded an update to ObiCloth (v 3.0.1) which mainly contains bug fixes. The only major change is that proxies now support skinned meshes as a target too. Once the asset store publishes this update, make sure to download it!
     
    Zomby138 likes this.
  44. Yang_Sir

    Yang_Sir

    Joined:
    Sep 19, 2015
    Posts:
    6
    oh,it is my wrong.The tear is ok,thanks!
     
  45. abatcat

    abatcat

    Joined:
    Feb 8, 2015
    Posts:
    70
    Would it be possible, or sensible, to use obi cloth for making solid armor pieces and using it as a rigid body simulator? Have clunky armor pieces bounce around while the character moves, and perhaps even deform on collision with heavy clubs and what not?
    Sometimes in vfx cloth is used to simulate deformable metal.things
     
  46. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    239
    Hi,
    I found interesting free asset which automatically creating colliders to characters.
    It can create convex colliders too - a pity that can not use it as colliders :(
    You can find it here.
     
  47. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Convex colliders are perfectly useable, as far as they don´t deform (because Unity doesn't support deformable mesh colliders anyway). :)
     
  48. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Would be possible, however the amount of iterations needed to achieve good bending resistance would be too high for most realtime uses unless your geometry is very, very simple, or your game is completely centered around this and has got not much else to pay attention to. In a VFX setting however, it's totally doable.

    For realtime, shape matching is a much better fit for this kind of task.

    - Regular cloth, using bend constraints: absolute deformability (is that even a word...?), but requires lots of solver iterations to achieve a semi-rigid look.
    - Shape matching: much better bending resistance (things look genuinely rigid out-of-the-box), less deformation range .

    We want to use shape matching in the future for a new asset, but still in the "some day" list.
     
  49. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    I have an error in 3.0.1

    Code (CSharp):
    1. Assets/Obi/Scripts/Actors/ObiActor.cs(20,41): error CS0840: `Obi.ObiActor.ObiActorSolverArgs.Solver.get' must have a body because it is not marked abstract or extern. The property can be automatically implemented when you define both accessors
    2.  
    Any suggestions?
     
  50. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Which Unity version are you using? In 5.5.1, the exact same code doesn´t give any errors.
    Edit:Anyway I suppose adding both accessors, as the error suggests, will fix it. Like this:
    Code (CSharp):
    1. Solver{get;set;}
     
    Last edited: Mar 3, 2017