Search Unity

Feedback Wanted: Cloth Improvement Plans

Discussion in 'Physics' started by SeanParkinson, Nov 5, 2015.

  1. SeanParkinson

    SeanParkinson

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    17
    Hi All,

    I am working on improving Unity's cloth system and as part of this would like to gather people's thoughts on cloth authoring workflow and features.

    As part of Cloth Improvements requirements capture, I have looked at nine different authoring packages, and they all tend to fall in one of two groups:

    1. Basic cloth authoring and tweaking given a pre made cloth mesh.

    as seen in APEX, Modo, Maya, Syflex, Shroud, Havok
    • Cloth is created using a given triangle mesh, that is rigged with animation bones.
    • Cloth constraint values are set and tweaked by painting them onto the mesh with a brush.
    We should begin our cloth improvements by implementing a brush based approach like this.With the added ability to paint on the cloth whilst it is being simulated in the editor view.

    Quick, easy to use and generally all that is needed for a lot of cloth scenarios.
    We should include:
    • Plenty of examples of usage.
    • Tutorials.
    • Documentation.
    • Testing.
    Whilst early adopters are using this and giving us feedback we can look at the internal side of cloth and work on:
    • LOD'ing.
    • Self collision.
    • Cloth-cloth collision.
    • Adding additional collider types.
    • Generating colliders from a mechanim avatar.
    2. Advanced, garment making style approach.
    as seen in 3ds Max, Marvellous Designer, Optitex
    • Taken from packages used to design real clothing, a sophisticated “Garment making” approach that allows users to assemble clothing from smaller pieces that are “stitched” together.
    • Using a series of custom user interface tools, often with lots of extra helpers to make the process as simple as possible. ( Marvellous Designer is the state of the art for this approach )
    • Much more sophisticated than the first approach, probably overkill for a lot of cases, particularly for low end platforms.
    However as time goes on and technology becomes more powerful, this will ultimately be the way people author cloth.

    This could be a long term improvement to the cloth that we will need some new runtime tech for welding/stitching verts.

    We can work out exactly what we require editor/runtime wise as we implement the first set of improvements.

    Initial requirements capture/task breakdown.

    UI/Workflow improvements

    • Brush based constraint painting. ( I have started looking at the terrain editing tools for this, as they already have the brush like tech we need )
    • Live cloth tweaking in editor.
    • Combine these into a free asset store package for early adopters, or create a custom build, to be decided. Evaluate the best option.
    • Create plenty of examples of usage.
    • Create tutorials.
    • Documentation ( remove old out of date docs and write new ones ).
    • Testing ( make sure we have the right testing framework for cloth )

    Runtime tech side improvements
    • LOD'ing.
    • Self collision.
    • Cloth-cloth collision.
    • Adding additional collider types.
    • Generating colliders from a mechanim avatar.
    Garment making tech
    • Garment making UI.
    • Garment making Runtime - stitching/welding tech.
    • Plenty of examples of usage.
    • Create tutorials.
    • Documentation.
    • Testing.
    Please let me know what you think about this, thanks!
     
  2. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    I love what Marvellous Designer does, but I assume for most games you need an extra baking phase to use the produce clothing assets? Designing in Marvellous is then analogous to sculpting a high poly version, after which you bake all the detailed creases to a retopologized version of the mesh.

    That said, if you think something similar to Marvellous could be used to both author cloth content and simulate it at realtime with other things going on, go for it.

    As for my specific use-case: I'd like to use simulated cloth in Volo Airsport, but due to the high velocities the characters have I have not been able to find a stable setup in the past.
     
    SeanParkinson likes this.
  3. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    hi @Tinus,
    A comment regarding the Airsport cloth:
    Have you experimented with scaling down the .worldVelocityScale or .worldAccelerationScale and use the .externalAcceleration to get the wind direction you want? You (should) just need enough force to inflate the "sails". In my mind you can then apply an ocean-ripple like vertex shader on the "sail" mesh to get the really fast moving turbulence.
     
    SeanParkinson likes this.
  4. hessel_mm

    hessel_mm

    Joined:
    Mar 12, 2014
    Posts:
    44
    I liked that the old cloth with the right pressure settings could be used as soft bodies. Any chance of bringing that functionality back?
     
    tpenney and SeanParkinson like this.
  5. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    I actually used cloth only a few times for testing. My impression was:
    1. very huge performance impact
    2. very vulnerable to fast rotations (then the cloth mesh was twisted and couldn't free itself anymore)
    3. not much influence on it via code (don't know if that really matters, I'm a programmer, not an artist, so this was more for me to check what I can do with it via code).

    My main target platform is mobile, so I guess cloth is not the feature I should use, but I wanted to share my experience with it.
     
    SeanParkinson likes this.
  6. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    My only comment would be on delivery, rather than a custom asset or special build, it should follow the UI pattern and be listed on OSS (as much as is feasible)
     
    SeanParkinson likes this.
  7. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    InteractiveCloth is not coming any time soon, I'm afraid. PhysX 3 removed the module we used for InteractiveCloth in PhysX 2, and I've not heard them working on returning the module back.

    On the other hand, InteractiveCloth was even more expensive than a regular Cloth in terms of performance. If, in theory, InteractiveCloth returns back with the same performance, and pretty much the same issues, would you consider using it again?
     
    SeanParkinson likes this.
  8. hessel_mm

    hessel_mm

    Joined:
    Mar 12, 2014
    Posts:
    44
    Absolutely, it was a nice component to experiment with. It might not be the best solution for (character) cloth, but it could be used very creatively.
     
    SeanParkinson likes this.
  9. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Improve Performance!
    As a goal,
     
    SeanParkinson likes this.
  10. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Can you share a real-world scene with us where you think the performance is below expectations? That can help a lot to put the right questions in front of our contacts at Nvidia.
     
  11. Cal0n

    Cal0n

    Joined:
    Jul 21, 2015
    Posts:
    4
    Thank you for wanting to work more on the Cloth system.
    I have a lot of things to mention here, and it's hard to know where to start, so I'm going to dive right in.

    The most important feature that I would like to see added to the system is the possibility of driving a mesh with a simulated cloth. I see this as the single most important feature of any cloth system. The lack of such a feature forces us to write a lot of different wrap scripts and vertex-parent-constraint scripts to work around the issue.
    You almost always want to have a simplified single-sided cloth mesh (unless you are simulating a sack, but that's not possible without self collision anyway), and you almost always want to have a more complex render mesh with thickness. We're now forced to use our own wrap system written in c# which I'm sure is not as optimized as something you could create over at Unity.

    This leads us to the next issue, the fact that querying the vertices of the cloth in any of the available updates gives us the position of the vertices before they have been modified that frame. Which means that all deformers and constraints we write to drive things with the cloth mesh lags one frame behind.
    And while on the topic of querying; being able to query the vertex normals instead of having to recalculate them on our own would be great.

    Furthermore, the expected behaviour of stretching stiffness 0-1 and bending stiffness 0-1 would be: That on 0 it would be able to stretch in to infinty and bend in whatever way it want, and on 1 it would not stretch at all and not bend at all. That is currently not the case.
    Having these two attributes as globals for the whole cloth system is also very limiting, it would help a lot if we could paint these on the cloth and therefore specify different settings on different parts of the cloth.

    Box colliders would be appreciated.

    Being able to specify a ground-plane would be appreciated and help alot, even though a box collider would serve the same purpose. We currently have to move a ginormous capsule collider around with the character to have the cloth collide with the ground when the character enters ragdoll.

    Self collision would be very appreciated.

    Having a visual representation of the length of MaxDistance and SurfacePenetration per vertex (and being able to toggle it on and off!) would help alot when designing cloth behaviour.

    I think that's all for now. Thanks for listening.
     
    SeanParkinson likes this.
  12. temps

    temps

    Joined:
    Dec 7, 2011
    Posts:
    10
    Hi,

    We use cloth on almost all our characters in our game so we have some feedback for you.

    1. Non-allocating vertices queries
    Quering vertices right now allocates a new array with vertices every frame, this triggers a lot of garbage collects. In 5.3 you add non-allocating physics queries which is great and that would be perfect for this case too.

    2. Reset cloth method
    It would be great with a Reset() method on cloth which resets it to it's default pose. Right now we have to disable it and then enable it the frame after.

    3. Simulate cloth method
    When pooling our characters there is a lot of deactivating and activating going on. When we active a character we set the correct state on it. Position, rotation and animation etc so it can be visible in the right state that frame. Right now we reset the cloth to it's default pose. That means the cloth wont be in it's relaxed state until a few frames later. What I propose is a method that will simulate the cloth and relax it for us in one frame. Much like what ParticleSystem.Simulate does. Maybe something like this: SimululateCloth(float solveCount).

    4. Callback when cloth is finished solving
    Like Gabriel(Cal0n) said when querying the vertices of the cloth it's always one frame behind because the cloth solves after LateUpdate. We use this to make a transform follow the surface of the cloth and it works good the problem is it's one frame behind (and it's allocating). If we had a callback like OnClothSolved or something we could use to move the transform it would help a lot.

    Thanks for listening!
     
    SeanParkinson likes this.
  13. SeanParkinson

    SeanParkinson

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    17
    Hey Cal0n,

    Thanks for your thoughts! Initial work will be on improving the UI and authoring/tweaking of cloth. So visual representation of the length of MaxDistance and SurfacePenetration per vertex (and being able to toggle it on and off!) will be included in this.

    After this further improvements such as new colliders and self collision. As for driving a mesh with a simulated cloth, this could be considered for later on.

    Could you elaborate more on what you would require from this?

    Thanks!
     
    Last edited: Nov 13, 2015
  14. SeanParkinson

    SeanParkinson

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    17
    Hey temps,

    Thanks for your feedback! I should be able to address these in the further cloth improvement work which will also include self-collision and cloth-cloth collision.
     
    temps likes this.
  15. Void24

    Void24

    Joined:
    Oct 15, 2013
    Posts:
    50
    Can I get a re-initialize hook for when a skinned mesh gets vertexes updated at runtime?

    Right now it keeps the old vertex list.
     
    SeanParkinson likes this.
  16. Cal0n

    Cal0n

    Joined:
    Jul 21, 2015
    Posts:
    4
    Hi Sean.
    This is what I would expect such a wrap to do:
    • The green plane is the cloth.
    • The blue strange looking object is the driven mesh.
    • The vertices of the blue object is smoothly transformed according to the vertices of the green object.
    wrapExample.png

    Ideally such a system would be setup by simply providing a target (driven) mesh to the cloth component without having to worry about fallof-settings, distance-thresholds etc.
     

    Attached Files:

    temps and SeanParkinson like this.
  17. Timescar

    Timescar

    Joined:
    Oct 7, 2015
    Posts:
    11
    I do not have much of a feedback to give since I haven't used the cloth component as much.
    But I have encountered a problem which I'm not sure if it is a bug or this is how it should work and I made a thread here
    http://forum.unity3d.com/threads/cloth-physics-constraints.368022/
    If I remove the cloth component but keep the skinned mesh there is no performance issue, but disabling it acts the same way as if it was enabled.
     
    SeanParkinson likes this.
  18. SeanParkinson

    SeanParkinson

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    17
    Hey Void24,

    I will look into this as part of the improvement work.
     
  19. SeanParkinson

    SeanParkinson

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    17
    Thanks Cal0n! I will look into this further for you.
     
    temps and Cal0n like this.
  20. SeanParkinson

    SeanParkinson

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    17
    Hey Timescar,

    This issue is known and being looked at, we should get a fix for this soon.

    Thanks!
     
    Timescar likes this.
  21. MKDev

    MKDev

    Joined:
    Feb 19, 2015
    Posts:
    6
    Hello Sean,

    My email address is info@mary-kyri.com
    I was wondering if you could email me an email address where I can ask several questions about cloth. It is highly confidential and therefore I cannot post it here within the forum. Megan from support advised me to contact you, saying you were happy to answer some questions.
    Thank you
     
  22. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,768
    Having access to the bone info would be handy, also being able to disable the skinnedmeshrenderer and still have the cloth running, I have done my own version of the wrap system mentioned above but cant use it since I have to have the cloth skinnedmeshrenderer running at the same time. Also if you exposed the bone info you are using for the skinned mesh that would save me having to duplicate and calculate it every frame as well.
     
  23. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Any update on performance improvements?
     
  24. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Yes, there were a couple things discovered lately that can potentially help out with performance of Cloth. Do you have something specific in mind?
     
  25. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    No, just wondering when these will be implemented.
     
  26. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    How could i miss this thread o_O ?
    I think what the cloth system lack in unity right now is the authoring part, could be cool if we can author using third party tools ie nvidia cloth authoring tools (standalone or dcc) and unity cloth can import those settings, it could be better for artist workflow since they don't have to go back and forth switching apps when tweaking cloth.
    Using proxy mesh cloth driver / Skin Wrap (3dsmax) like Cal0n describes is a great idea, especially if we don't require a high detailed cloth sim.
    Oh and support for cloth interaction with external force could be great especially wind
    is the garment maker really necessary? just curious. Since that usually hi-poly initial modelling phase.

    Oh btw this is not specific to cloth system, but might be still connected.
    Since you planning to adding brush system for in editor cloth authoring tool, i hope you guys creating a unified and extendable editor brush API which can also used in terrain, object placement, vegetation system, or maybe texture and vertex paint :)
     
    Last edited: Jan 25, 2016
  27. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    The current understanding is that as a first step we're going to invest into our own authoring solution. You're right saying the current one is same as lacking, but look, this could be fixed. One can say APEX has everything ready right now with nothing required to do integration side, but in fact, it's not exactly like that. Especially when it comes to running your assets on platforms (APEX's platforms support is fairly limited), the same goes about the DCC tools and plugins which are harder/impossible to get on OS other than Windows. On top of that, those tools look and feel totally alien to Unity ecosystem. That's why we want to invest into a good UI iteration and to have a look if we could bring our cloth authoring solution up to standards (and, eventually, above).
     
  28. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    I see, alright that should be no problem if you guys can do that. i'm hoping that unity have the same tools for authoring the cloth system. Would be pretty cool if we can isolate only the object that we want to edit.
    Unity could gain advantage of somekind unified painting tools :).
    Can't wait to see what you guys gonna added to unity.
    @yant just fyi arkano already have proxy cloth for obi tho. . . yes it is usefull,
    forum.unity3d.com/threads/obi-cloth-bringing-old-cloth-back-to-unity-5.337322/page-4#post-2496760
     
    Last edited: Feb 10, 2016
  29. kenamis

    kenamis

    Joined:
    Feb 5, 2015
    Posts:
    387
  30. arkano22

    arkano22

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

    Just wanted to tune in to this thread. I´m the lead developer of this: https://www.assetstore.unity3d.com/en/#!/content/81333

    While not using Apex underneath (so we don´t know if certain things would be possible to do w/ Apex), we feel the way we expose many common cloth-related tools in the editor (such as per-vertex editing of cloth properties, generating mesh-mesh skinmap assets to transfer simulation from low-poly meshes to high poly ones, etc) are steps in the right direction.

    Since we've already walked this road for quite some time, I think it would be beneficial for you to take a look at the result of our efforts and see which things work and which don't in terms of usability (there are quite a few rough spots in Obi that could probably be smoothed out with tighter integration in Unity). Hopefully this will help you guys figure out the best way to expose all of Apex's functionality in Unity.

    cheers,
     
    Reanimate_L, kenamis and hopeful like this.
  31. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Any chance of making it possible to deform cloth? Such as rips/tears and holes in the cloth? This would be really cool if it was implemented natively within Unity.
     
  32. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Deformations should be more or less possible right now, but speaking of alterations like tearing -- that has to be implemented in PhysX natively first.
     
    Stormy102 likes this.
  33. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,929
    Have you guys considered using NvCloth instead of Apex?

    Seems to be lower level and though it probably does not support tearing (as it breaks constraint batching, hurting parallelism in the general case and also consumes more memory since you cannot instance constraints) it is certainly simpler and more flexible.

    Could make your life simpler, that is.
     
  34. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Deformation would be a step in the right direction ;)
     
  35. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Actually, we never used APEX Cloth. We were using PxCloth stuff from the core PhysX, that is also used by APEX internally with some modifications. PhysX 3.4 brings NvCloth, which is basically pretty much the same thing as PxCloth. NvCloth is likely to be used in Unity 2018.x.
     
    Stormy102 and arkano22 like this.
  36. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    is this implemented already? in 2018.x.
    I know you guys have a close beta :D
    (FYI : and no i'm not in close beta just in case you are wondering)
     
  37. jamesjxiao

    jamesjxiao

    Joined:
    Mar 1, 2018
    Posts:
    9
    the version unity 2018.3.0 has upgrade physx from 3.3.3 to 3.4.2, which support NvCloth!