Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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

Discussion in 'Works 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:
    586
    Hi Seith!

    Keeping the cloth intact when importing an updated version of the mesh is simply impossible to do, because vertex ordering might have changed and there's no way to map the old ordering to the new one.

    Even if mapping old vertices to new ones was possible, most simulators re-order constraints during cloth generation and group them in sets so that they can be updated in parallel for maximum performance (it is not uncommon to have tens of thousands of constraints in a single cloth, so being able to take advantage of parallelization is a must). This requires that no constraint in each set shares a node with another constraint in the same set. Adding just 1 vertex to your mesh (or removing one) can completely change the adjacency graph of your mesh, requiring re-generation of the underlying constraint sets from scratch. (Note: roughly speaking, node = vertex, constraint = edge)

    All realtime cloth simulators that I know of suffer from this limitation, simply because it is a performance -vs- convenience choice. Most choose performance.

    In Obi you can import vertex properties from a texture (painted in photoshop, 3DCoat, ZBrush, whatever). This allows you to keep your setup more or less intact as long as texture coordinates of your mesh haven't changed. However there are certain things that cannot be imported from a texture (such as particles pinned to a rigidbody) and you'd have to manually re-do these.

    Note that it is not currently possible to export values from Obi to a texture (only importing them), so if you plan on following this workflow I recommend to use textures right from the start.
     
    Last edited: Sep 11, 2017
    Seith likes this.
  2. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    705
    Thank you very much for your reply!

    Actually we just found a way to maintain the cloth vertex settings and influences even if the meshes change topology in Maya. That's a relief! I hate doing the same work repeatedly... ;)

    (In case you're curious: we simply export the cloth vertex settings in a file and then reimport them after the changed mesh re-enters Unity. We just don't use vertex indices (since that's of course unreliable) but instead we use the vertices positions. That way the information we import is always accurate. And if a perfect position match can't be found we simply apply the settings of the closest stored neighbor vertex)
     
    Last edited: Sep 10, 2017
    arkano22 likes this.
  3. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Yep, you can do this with positions or with texture coords. Doing it with texcoords is slightly better as you don´t need to write any custom stuff to export/import settings (I believe Maya has a built-in way to export vertex data to textures: ncloth->convertVertexToTextureMap), you can just rely on a simple texture, and you can perform basic modifications quicker (like offsetting, or increasing contrast) in any painting program. Also values are automatically interpolated from the nearest neighbors for new vertices in the mesh.
     
    Seith likes this.
  4. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    200
    Hey there, so I already purchased it. But I'm running into some issues generating the topology. ArgumentOutOfRangeException
    I'm not completely sure, but from looking into it, does it not work with normal mesh renderers? Is it required to be skinned meshes? Is there a simple way to convert a mesh into a skinned mesh without any 3D modeling software?
    Otherwise this solution won't work for me :\
     
  5. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    200
    Also, I'm getting a lot of DllNotFoundExceptions. I'm using Unity 2017.1.1f1
     
  6. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi!

    It works with any kind of mesh renderer. In fact, all sample scenes except for one use regular MeshRenderers. SkinnedMeshRenderer support was added later down the road. Just make sure that your mesh is well formed (e.g., is not non-manifold: doesn't contain edges shared by more than two faces, vertices connecting just two edges, zero area faces, etc). The topology baker will try to give you a warning if it can detect a malformation in your mesh-

    Specifically, make sure that your mesh faces are not duplicated in-place to create a double-sided surface. This is common bad practice among modelers, and creates a *very* non-manifold mesh. Double-sided surfaces must be done using a shader (Obi includes the Standard(backfaces) shader for this purpose)

    Regarding the DllNotFoundException, have you tried restarting Unity after installing?
     
  7. andremusic1997

    andremusic1997

    Joined:
    Oct 21, 2015
    Posts:
    3
    Hello, in fact I need to reset the cloth if some parts "escape" from the collider and go out of place.
    To solve it, I thought I should get the particles and the collider that these particles are colliding with, and reset them.
    Is there a way to get the name of the collider which is colliding with these particles?
    Is it possible for me to reset only a group of particles, or can I only do it with the entire actor?
    Does it have any performance overhead in mobile if I do it?
    Is there any other way to solve it?
     
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi Andre,

    Regarding how to retrieve the collider involved in a contact, see:
    http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html

    (use ObiCollider.idToCollider[contact.other];)

    About resetting particles in an actor:
    http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html

    (use the low-level setters to send the initial particle positions/velocities/etc to the solver. This has a very small impact in all platforms, specially if you don´t do it every frame).
     
  9. Hodoer

    Hodoer

    Joined:
    Oct 12, 2017
    Posts:
    6
    Hi, I'm very new to scripting. Just want to ask how do I get the average transformation of the particles in the actor in order to get a value for the camera to track? Right now my camera isn't following the simulated cloth with the following script:
    public GameObject player;

    private Vector3 offset;

    private void Start()
    {
    offset = transform.position - player.transform.position;
    }

    private void Update()
    {
    transform.position = player.transform.position + offset;
    }
    Please help. Many thanks.
     
  10. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi!

    Basically add all positions together and divide by the mount of particles.

    You have a snippet in the documentation that calculates the actor's center of mass. In case all particles have the same mass, this is exactly the same as the average position. If some particles weight more than others, the resulting position will be closer to the heavier ones. See:

    http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html
     
  11. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    46
    Hello arkano,

    I really appreciate your hard work on your trilogy.
    I have just finished reading whole thread (took more than 5 hours!) and noticed that you have never mentioned anything about the progress regarding shape matching deformation plugin. Is it just in your roadmap or is it under development? Will we have a chance to see Obi Softbody in the asset store maybe by the end of this year?
     
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi there!

    I'm working on shape matching/oriented particles/rods at the same time. This is because all three of them require adding orientation information to the particles (essentially turning them into ellipsoids), so I'm trying to unify them as much as possible.

    Shape matching does not require oriented particles, but it only achieves unconditional stability
    when using them, specially for shapes with few particles.

    In addition to that, I´m working on adaptive distance fields as collision primitives. These will be released first for all three plugins, then rods (twist-aware ropes) will be added to ObiRope, then shape matching & oriented particles will be used for ObiSoftbody (or whatever its final name will be :)). As always I can't give precise time estimations, once it is robust enough I will release it. Releasing by the end of this year is not too far fetched, though.
     
  13. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    46
    Thank you so much for your quick response, arkano.
    Wow, so there will be many things coming in the near future! I cannot miss any one of it.
    I'm gonna be softbody every single object in my scene next year! :)

    Btw, it is getting colder. Take care of yourself!
     
    Last edited: Oct 24, 2017
    arkano22 likes this.
  14. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    200
    Hey,

    So I know I can fix and unfix particles, but is there a way to remove particles completely? Fixing particles seems to pin them so that they don't move. I want the entire mesh to move like cloth but I don't want to calculate THAT many particles. It causes quite a bit of lag. As you can see, the edges have far too many particles.

    Thanks
     

    Attached Files:

  15. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Why don´t you use a proxy? you can use a completely different mesh for simulation (a simpler mesh) and use it to drive this one.

    http://obi.virtualmethodstudio.com/tutorials/clothproxies.html

    Or a even simpler solution (if possible in your case, but i'm sure you have considered and discarded this option already if you went the full-mesh route for some reason) is use a cutout shader to render that irregular border shape using texture alpha. That way you get both faster simulation and rendering, without the need to setup proxies.
     
  16. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    200
    I tried the proxy with a lower poly mesh, and it definitely did not look right. Luckily, with the nature of the poster, I can switch to the lower poly version when using the cloth part because it simply falls to the ground after being clicked.

    My other issue is with the cloth phasing through itself. Is there a particular reason for this?

    Edit: Just some info: My goal is to have the poster fall to the floor. That all works fine. It's just how the poster looks once it has fallen that is the problem.
     

    Attached Files:

    Last edited: Oct 25, 2017
  17. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    If you're simulating a poster, I'd ditch the mesh you are currently using and use a regular homogeneous plane with a cutout texture. There's no need to model all the small details at the edges of the poster using geometry -in fact that's very very bad practice both from a rendering and a simulation point of view-.

    Regarding the poster pasting trough itself: have you enabled self-collisions (checkbox in the ObiCloth inspector)? also, take a look at your particles using the particle editor: select all particles and set the property selector to "radius". Particles can only collide with each other, and your mesh topology looks like it has large gaps between vertices in some zones (trough which particles can pass even with self-collisions on), and large amounts of vertices clumped together in others (which is a waste of resources).

    PD: on a side note, we no longer "officially" give support trough this thread. You should post your questions in the Obi forums: http://obi.virtualmethodstudio.com/forum/index.php
     
  18. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    200
    oh sorry, i didn't know there were forums. I'll switch over there
     
  19. ColtonK_VitruviusVR

    ColtonK_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    130
    Hey @arkano22,

    We are currently using the Unity cloth for the bottom of our knights tabards but it sometimes get stuck behind the leg collider or between the leg and the butt colliders. Do you think ObiCloth will solve this issue? Here are some screen shots of our current setup :

    Here is the starting pose of the knights in edit mode:
    StartingPose.JPG

    Here is an image of the max distance paint:
    Max_Distance.JPG

    Here is an image of one of the issues :
    Issue1.JPG

    The fighting routine is fairly intense for the cloth in terms of movement (spin attacks etc.)

    Cheers,
    Colton
     
  20. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi!

    ObiCloth and Unity's cloth are pretty similar in their approach to character clothing. Also your issue stems from a common problem in realtime physics: tunneling.

    Ways to avoid it (both for using Unity cloth or ObiCloth):

    - Make your cloth topology a bit more homogeneous. You have lots of vertices at knee level, and very few vertices in the thigh area. Keep in mind that only vertices in the cloth are able to register collisions, so having such huge gaps between vertices gives the leg colliders a lot of chances to slip in between vertices and get tangled in the cloth.

    Also, a beneficial side-effect of more homogeneous topology is better cloth deformation!

    - Decrease the world space velocity/acceleration. This will make your simulation less lively, but also more robust when the character moves around jumping/attacking/somersaulting etc.

    There's no need for you to use ObiCloth to solve this problem, imho.
     
    Last edited: Nov 2, 2017
  21. ColtonK_VitruviusVR

    ColtonK_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    130
    Thanks for the honest reply, I have been messing around with the world velocity/acceleration but never thought that only verticies collide. Ill change the topology, thanks!

    Cheers,
    Colton
     
  22. MarkusGod

    MarkusGod

    Joined:
    Jan 10, 2017
    Posts:
    163
    Hi there! I wasn't playing around very much with obi cloth and as cloth it is trully great, but is it possible to make a "soft body tire" for a car with obicloth?
     
  23. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi!

    No, most likely the softbody model used for ObiCloth is way too imprecise to create a realistic and compelling driving model. For this you should really use a dedicated system, that is specifically designed for tire simulation.
     
    MarkusGod likes this.
  24. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Just wanted to give a heads up on what's happening for Obi in the few next months.

    - We added adaptive distance fields (ADFs) for all Obi assets. These are like MeshColliders, but much faster, and much more robust since they can project particles that lie completely inside of them to the surface. The downside is that they do not support non-uniform scaling, and have a slightly higher memory footprint.

    - ObiRope can now be used to deform any mesh. Meshes can also be instanced multiple times along the rope, and they can be scaled/translated over it. Think Blender's curve modifier, and that's what you'll get.

    - ObiFluid will support anisotropic kernel-based rendering. This means that particles will no longer be perfect spheres, but ellipsoids that adapt better to the shape of the fluid surface. You'll get nicer looking fluids with fewer particles.

    Will make a blog post for each of these as soon as we can. cheers!
     
    SecondBake likes this.
  25. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    45
    Hello @arkano22 ,

    Firstly, register link is broken in your official web-page so I couldnt register to open a new thread and eventually I had to ask my question in here.

    I simply want to know whether using Obi Cloth in a 2D mobile game is wisely. I have never seen any tutorial or topic about use of obi mobile. Obviously we cannot expect you to test it on every device under various circumstances. But I havent seen anything that shows what should we expect from Obi Cloth when it comes to mobile performance.

    In this regard, is there any showcase video (maybe a mobile game using Obi Cloth), tutorial, documentation, data etc. anything tangible ?

    I want to use Obi Cloth as a flag and one sail of my ship. They don't need to be too complex and they just need to react against colliders (wall etc.) as one-sided reaction.

    Thank you.
     
  26. andremusic1997

    andremusic1997

    Joined:
    Oct 21, 2015
    Posts:
    3
    Hello kapopixel, first of everything - Sorry by my poor english, it's not my native language.

    About your question, actually i'm using Obi Cloth to simulate a complete cloth (Something like a dress) in Mobile, using Vuforia AR with it, and i'm having some performance issues in some devices, but devices with something around 4 or 8 cores and 2GB ram, work 'Ok' (remembering that i'm running with an AR asset).

    The cloth asset only runs fine in 3D cases, probably in 2D will run better :)

    If you wanna use Obi Cloth for something like the flag and Sail, it will depend of how much vertex each of them will have, and the constrains that you want to use.

    But in the general scenario, will run fine.

    i would love to share my project, but it's an institucional project, so i can't share him ;(

    O/
     
    kapopixel likes this.
  27. VictoryWorks

    VictoryWorks

    Joined:
    Oct 2, 2015
    Posts:
    6
    I have a quick question on cloth and forces.
    Is there a way (either built in or something I can change in the core code) that will allow specific particles in a cloth object to ignore a force applied to them? In the specific circumstances I need the cloth to react to the rest of the cloth movement (so pinned is no use) but for a certain part of it to not receive the force - imagine a large cloth where half of it is hanging over a doorway with a wind blowing in and the other half having a wall behind it.

    I've tried the sphere force in a small area but the effect is not correct for the above example and just creates a spherical bulge, as you would expect from that force generator.

    Thanks.
     
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi,

    There's no built-in way to achieve this specific use case. You can however write your own class derived from ObiExternalForce, and implement the ApplyForcesToActor() method as you see fit.

    In the *very* general case (implementing force "deflectors") would require performing a full simulation of the surrounding atmosphere or at the very least perform visibility queries for every particle, which can quickly become more costly that the cloth simulation itself.
     
    VictoryWorks likes this.
  29. VictoryWorks

    VictoryWorks

    Joined:
    Oct 2, 2015
    Posts:
    6
    Thank you for the reply. The use in question is pretty limited in it's possibilities so I can cache the particle sequence on start up and then "slice off" horizontal and/or vertical rows of particles infrequently as the need arises and use the limited selection as the array used in the AddParticleExternalForce method.

    However.. I have a slight problem from the get go.
    I copy and pasted ObiAmbientForceZone into a new class and simply renamed it ObiAmbientForceZoneExtended. All the code is exactly the same, it just has a new name. I add an instance of the new script to the Wind scene demo using the wind that affects the flag pole, set the same values as the original wind and drop in the solver for the flag on the pole. I disable the original ObiAmbientForceZone script and click play.. and the flag just hangs there!



    I've stepped into the code and it all seems to be running through the ApplyForcesToActor method as I would expect, the console is clear of errors, yet it doesn't effect the flag at all.
    Am I doing something very silly?! o_O
     
  30. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Followed the same steps you describe, worked just fine for me. I see no reason at all why a class with the exact same code but a different name would behave differently.

    make sure that aerodynamic constraints are enabled in your flag! ;)
     
  31. Ibizanhound

    Ibizanhound

    Joined:
    Jun 20, 2014
    Posts:
    2
    Hello @arkano22 and congratulations for your amazing physics solution!
    I was wondering,
    are there any plans to port it to Unreal as well?
    Thank you!
     
    arkano22 likes this.
  32. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    we're on it :)

    Basic stuff already working there, tackling more advanced editor-related stuff now. But man, Unity's documentation is so much better...
     
  33. Ibizanhound

    Ibizanhound

    Joined:
    Jun 20, 2014
    Posts:
    2
    I don't blame you for saying that. I remember trying to understand the Unreal editor back in 2008 when it was really difficult to find help about it online, and I remember it was a nightmarish experience! Really counter-intuitive design back then. Thank you for replying! And good luck with everything!
     
    arkano22 likes this.
  34. OnlyVR

    OnlyVR

    Joined:
    Oct 5, 2015
    Posts:
    43
    Any update?
     
  35. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi there!

    Still working on it. Our self-imposed deadline for this is late january. We are currently working on moving ADF creation over to coroutines and giving some feedback about its progress, as it is a lenghty process (can take minutes on larger meshes).

    Obi Cloth will be updated first, then Obi Ropes, the finally Obi Fluid.
     
  36. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi all!

    We've just upgraded all Obi assets to 3.3. Most notably, we've added support for substepping (which is a big deal performance wise), experimental support for signed adaptive distance fields, and arbitrary mesh support for rope rendering. Here's a post detailing some of the new stuff:

    http://blog.virtualmethodstudio.com/2018/02/obi-3-3-whats-new/

    cheers!
     
    Last edited: Feb 19, 2018
    hopeful likes this.
  37. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,458
    Very impressive! :D
     
  38. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,951
    I'm eager to grab up this asset. Have you updated your tutorials on creating cloth assets? I have separated my mesh objects to ensure that I have pieces that will be cloth driven
     
  39. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    191
    How works SDF (maybe little tut?) - when try to add a mesh to Distance Field topology thereis an error (I tried in Unity 5.6, 2017 and 2018)
     
  40. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Hi petersx,

    I just discovered a very stupid bug in the SDFs:
    Go to line 68 of ObiDistanceField.cs and add a null check, so that the method looks like this:
    Code (CSharp):
    1. public void Reset(){
    2.     nodes = null;
    3.         if (input != null)
    4.         bounds = input.bounds;
    5. }
    That should fix the error. We'll upload a patch asap.
     
  41. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    191
    Thanks. I confirm that it is working now. I will try to test new SDFs.
     
    hopeful likes this.
  42. OnlyVR

    OnlyVR

    Joined:
    Oct 5, 2015
    Posts:
    43
    SDF looks great in video, but how to use it? I guess first step is create New Obi.ObiDistanceField. What are next steps?
     
  43. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,358
  44. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
  45. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Add a ObiCollider component to any collider, as usual. Enable the "use distance field" checkbox in its inspector, then drag and drop the ObiDistanceField asset into it.
     
  46. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,358
    Ops, sorry, didn't know it wasn't available :D
     
  47. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,358
    Some of our players finding out how to operate our obi rope based game mechanics, pretty funny, thought I'd share

     
    theANMATOR2b likes this.
  48. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    3,755
    Is it possible for obi rope to have support for coil type of string?
    I mean like in this, they explain the rational
     
  49. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    586
    Currently not, but working on it for Obi 4.0, using position-based elastic rods.
     
    neoshaman likes this.
  50. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,358
    While you are at it, maybe look at how to simulate cables and wires better?