Search Unity

[RELEASED] Cloth Dynamics

Discussion in 'Assets and Asset Store' started by Nexusmaster, Dec 9, 2020.

  1. lyflike

    lyflike

    Joined:
    Dec 23, 2018
    Posts:
    12
    Hi,

    Before buy this solution I have some questions.
    1. Is this works on webGL ?
    2. In this can we create cloth physics runtime with some kind of preset settings ?
    3. Is this solution provide cloth scaling with physics ?
    4. Is this solution can works with addressable cloth bundle files?
    5. what will be the FPS with 45k vertex of mesh cloth in mobile and web?
    6. What are the plush points compare to Magica Cloth and Obi Cloth ?
    Thanks
     
    Last edited: Aug 9, 2021
  2. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Version 1.6 was just released, did you have a look at the Dynamic Cloth Creator? All the Best, Chris
     
  3. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    1. Currently not, I think the compute shaders are too performance heavy for WebGL and memory is the bottleneck.
    2. There is a "DynamicClothCreator" script in the new version that might help, it uses prefabs, however it's currently experimental.
    3. You mean that you want to scale the cloth during simulation? The distances of the vertices get saved at the beginning, so currently not, you would need to modify the buffer that holds the length data, it's possible but needs to be included extra.
    4. Addressables and asset bundles were not tested yet, so can't say, I think it depends on what you do. Asset Bundles should work when you load all the dependencies together, I think.
    5. Really depends on your mobile hardware and the amount of cloth colliders. I would say 60 fps is possible but this is just a guess. Only primitive colliders work on moblie! No Mesh Collision!
    6. Well it's GPU based, so it should be faster... also I think, it's more user friendly and faster to setup, but you need to try it out yourself .. you can get a refund, no problem.

    Btw. I really don't like it when people get a refund basically for free (other publishers want a reason) and still complain on the review page. If this happens again with the new version I will stop that service. Version 1.6 was tested on Windows and Mac and runs very stable in my opinion. The collision system might not be perfect, but most of the cloth systems have these issues. You can see very clear in the demo build what is possible and what is not, so just download the demo for free.
     
    Last edited: Aug 11, 2021
  4. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    Hi, not yet did you have a documentation about this new feature ?
     
  5. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Not yet, I'm working on it but it also takes time.
     
    Last edited: Aug 11, 2021
  6. lyflike

    lyflike

    Joined:
    Dec 23, 2018
    Posts:
    12
    • I bought updated plugin but not able to find documentation. Could you help me ?
     
    Last edited: Aug 11, 2021
  7. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    There is a folder that says Documentation with a pdf it's from V1.0, but the basics are all there.
    Here is a video with most of the new stuff:


    I missed out on DynamicClothCreator, but in that case, just look at the code, it's very short. It's still experimental so it might change.
    Have a look at the example scenes and how they are setuped. I will soon update the documentation.

    Also when you are using Unity2019 and URP you need to unpack the new shader package in the ClothDynamics folder.
     
    Last edited: Aug 11, 2021
  8. lyflike

    lyflike

    Joined:
    Dec 23, 2018
    Posts:
    12
    Why when i apply GPU Skinning Shader on the skin mesh render , it converts that object into mesh renderer object ?
     
  9. lyflike

    lyflike

    Joined:
    Dec 23, 2018
    Posts:
    12
    Could you provide any video or tutorial to create cloth physics on high poly cloth ?
     
  10. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    The GPUSkinning script ist currently needed to read the skinned mesh data, with the next update you can keep the skinned mesh when you use Unity 2021.
     
  11. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
     
  12. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85

    Hi @Nexusmaster, i update my project with v1.6 and i have strange behaviour with collider size :
    (Left previous version - Right v1.6 , ignore the layout old version is on mac and new on windows)

    upload_2021-8-12_10-15-28.png
     
  13. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
  14. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Try "use nearest vertex" set to true in the Automatic Bone Spheres. You also might have to replace the mesh sources.
     
  15. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    set "use nearest vertex" to true fix the trouble but my "Automatic Bone Spheres" component is add by code and the only way i find to set "use nearest vertex" to true is to update your component code and set the default value to True.

    for example with this code, it's not working :

    var ABS = _avatar.gameObject.AddComponent<AutomaticBoneSpheres>();
    ABS._useNearestVertex = true;

    Is there other option to set _useNearestVertex before adding the component ?

    thanks
     
  16. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    When you use the DynamicClothCreator you can use a Prefab which has a ABS component, or you just set the bool to true in the AutomaticBoneSpheres.cs file as a default value, I can do this in my next update, so you don't need to overwrite it everytime you update.
     
  17. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    If its set by default to true its good for me but i dont know if it will be good for other people :)
    Prefab solution is not possible for me , most of my stuff is generated at runtime.

    I try the new export function it's working well for the proxy but i still have to change your code to access to the generated mesh, is it possible to return the mesh at end of export function instead of returning void.

    I still have to made some update in your code to disable all popup when application is playing , is it possible to add a setting who disable all popup (with eventually the overide choice settings)?

    And last question who is very specific , i use a lower polygone resolution on my proxy mesh to have good performance but i ll need the exported object in higher resolution with a smooth, i still didnt find an algorythm to double the number of vertex and smooth them (i m not an expert of mesh manipulation) , maybe you have some script like this somewhere :)

    Thanks again for your support
     
  18. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Both script changes are possible, you can also send me your modified script and I can try to include it in the next update.

    About your last question: Sounds like you need tessellation? You can try the tess cloth shader when you are using the builtin pipeline or you can do it in Blender, if it's not needed at runtime.
     
  19. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    For the Export i just add the line 'return newMesh' at the end and change the type (i m not sure about the variable name)
    And for the popup i comment them so i dont think its good for you :)

    Yes i need tesselation :) , didnt know the word before, but i think with that keyword i ll find easily a solution :)

    Thank you :)
     
    Last edited: Aug 12, 2021
  20. NexarChile

    NexarChile

    Joined:
    Apr 29, 2016
    Posts:
    17
    Hi @Nexusmaster ! Thanks for your great asset and thanks for the continuous improvements! We have already purchased your asset :D

    We are evaluating the option of using it in a Unity HDRP project for Linux, but we want to be sure if your asset is compatible.

    In your first post, you say that your asset should run on Linux.

    Have you tested it on Unity HDRP for Linux?

    Is it possible that you can generate a demo executable for Linux on HDRP?

    Thanks in advance!

    Best regards! :)
     
    JonBanana likes this.
  21. oceancx

    oceancx

    Joined:
    Aug 20, 2021
    Posts:
    3
    get error when exit play mode .

    MissingReferenceException: The object of type 'GPUSkinning' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    ClothDynamics.GPUSkinning.SkinUpdate () (at Assets/ClothDynamics/Plugins/GPUSkinning/Scripts/GPUSkinning.cs:118)
    ClothDynamics.GPUSkinning.UpdateSync () (at Assets/ClothDynamics/Plugins/GPUSkinning/Scripts/GPUSkinning.cs:95)
    ClothDynamics.ClothUpdateAnimator.UpdateSync () (at Assets/ClothDynamics/Scripts/ClothUpdateAnimator.cs:83)
    ClothDynamics.ClothUpdateAnimator.LateUpdate () (at Assets/ClothDynamics/Scripts/ClothUpdateAnimator.cs:76)
     

    Attached Files:

  22. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Sorry about this issue, this bug should be fixed in the next version, I will upload a new version tomorrow evening, so it will be soon online! For now you could just add a ClothUpdateAnimator to your character root and set it to "SyncOff", this might fix it. You can also set a if(this == null) return; in the top line of the SkinUpdate() function of the GPUSkinning.cs. Sounds silly but it should work for now.
     
    Last edited: Aug 22, 2021
  23. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Sorry for the delay, I was sick for almost a week, but now I can finish the next version tomorrow.
     
  24. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    No, I haven't tested it, I think it works but I'm not sure. I'm currently busy with other stuff, but maybe you can try it out and if you have issues with it, you can get a refund or wait until I fix it :)
     
  25. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I'm currently more focused on mobile stuff and want to improve this part, I think it's possible to get self collision working on mobile by using my surface push method on different vertex layers. I also need to improve the mesh collision part but this will take some more time. Currently I'm not so happy with the usability, I want Cloth Dynamics more user friendly, so you can just put on the script and it works out of the box, however that is very easy to say, but actually very complicated.
     
  26. oceancx

    oceancx

    Joined:
    Aug 20, 2021
    Posts:
    3
    My character's skirt mesh had a custom shader, when I add GPU Cloth Dynamics on the skirt, it will swap the skirt shader to Shader Graphs/URP_Lit_Graph_Cloth, how can I fix this problem.also, I found that when a mesh was add GPU Skinning component and "render" is checked in the inspector, it will swap the initial shader.

    upload_2021-8-23_10-21-37.png
     
  27. tousan

    tousan

    Joined:
    Feb 10, 2020
    Posts:
    3
    When I run on my iOS device, it's not working with log: Invalid device load executing kernel function "PBDClothSolver.CalcCubeCenterFast". After I delete this function it starts to work. I know little about Unity, don't know what went wrong.
     
  28. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    You need to rename your custom shader to something with "Cloth" in it and it won't swap. However you need to add the cloth function to your custom vertex shader.
    You can also use a custom shader for the skinning, it should contain the name "Skinning" in it.
     
    Last edited: Aug 23, 2021
  29. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Sorry about that, I will try to fix the iOS issues today, promise!
     
  30. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    Hi, I can't find a way to make the SSS shader work. I'm I missing something or is it broken?
     
  31. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    If you are talking about the "Lit_Graph_SSS" shader, it's a normal Lit SSS sahder, but it has nothing to do with the cloth shaders, all cloth shaders have names like "Lit_Graph_Cloth". I (or you) can add it, but why do you need an SSS effect for the cloth?
     
  32. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, the next version (1.6.1) will be soon in the store, however I didn't add the 2021.2 skinned vertex buffer, because it's kind of tricky to use. The problem is the buffer gets init delayed, so I have to delay all dependencies of it. Also the skinned transformation matrix is not easy to solve in the shader, but I will find a solution, I will try to add this in the next update.

    I finally added the custom constraints, there is a new example scene called: "DressWithConstraints"
    upload_2021-8-24_11-46-59.png
    You just have to add the GPUClothConstraint to an object and set the Intensity to 1, if you want to use it. It will auto search the nearest cloth vertex, you can also turn it off and keep the found vertex id. The idea is to attach this e.g. to a hand of another character and increase the intensity when the hand grabs the cloth. To release the grab just set the intensity to 0. You need to add your intended ClothSim component to the ClothSim slot to make it work.

    Also the Skinning LOD is improved by switching from ClothSim to GPUSkinning when the LOD reaches it's full Skinning state or if the LOD value is set to 0.
    (In my current game I set the LOD value via script so only the active character has it's cloth sim running, the other characters, which are not moving, get a LOD value of 0).

    I will soon update the documentation for this version (1.6.1) and after that I will continue with new features.
     
    Last edited: Aug 24, 2021
    victorkin11 and SunnySunshine like this.
  33. oceancx

    oceancx

    Joined:
    Aug 20, 2021
    Posts:
    3
    what cloth function should I add? can you give some examples or torturials on how to do that?
     
  34. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
  35. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I'm testing a new "Projection Mask" technique, it's actually very simple but helps to hide body-cloth intersections:
    upload_2021-8-25_10-57-15.png
    upload_2021-8-25_10-59-16.png
     
    victorkin11 likes this.
  36. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    We use the SSS shader for our character's hairs. Is it possible for you to add a Cloth SSS shader ?
     
  37. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Are you using HDRP ? I can put this in the next update sure... should be 1.6.3 because I already sent out 1.6.2.
     
  38. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Btw. I'm now uploading version 1.6.3, so best you wait until it's up because 1.6.2 has some unclean shader folders and Projection Mask has some bugs, which I already fixed in 1.6.3.
     
  39. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, I'm still working on the documentation update, so for now it's best when you check out the TOOLTIPs, which will appear when you hover over the parameters with your cursor in the Editor Mode (Does not work in Play Mode).
    upload_2021-8-29_14-56-35.png
    Here you can see the tooltip of the Mask Depth Threshold. This threshold will clip geometry that is leaking out of the cloth mesh, like the body skin. So it's important to tweak this value for your needs. The tooltip recommends -0.1 for SRP and 0.01 for Builtin. Currently only the GPUSkinning- or DualQuaterionSkinner body meshes will get this shader, it only works when you apply one of these components to your body mesh.
    The ProjectionMask needs to be applied to the cloth object, check out the new example scene.
     
    Last edited: Aug 30, 2021
  40. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    The latest version is online, you can already test the new ProjectionMask, however I will do some more improvements in the next days. I think it's a very helpful feature to get rid of the small overlapping issues between cloth and skinned body.
     
  41. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi!
    I updated the Projection Mask again, the depth threshold is now unified and has a default value of 0.05, this should work in most cases. The new version 1.6.6 should be online soon!
     
  42. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    Yes I'm using HDRP. Thanks!
     
  43. Giocas

    Giocas

    Joined:
    Oct 15, 2013
    Posts:
    4
    Hello @Nexusmaster,
    just bought your asset. Imported inside an existing project with ObiCloth amd MagicCloth assets imported.
    I get the following error:
    Assets\ClothDynamics\Plugins\BezierSolution\InsideCheck.cs(157,47): error CS0246: The type or namespace name 'BezierPoint' could not be found (are you missing a using directive or an assembly reference?)

    and if I try to add Cloth Dynamics to a skinned mesh, it is not listed by the component adder.
    What can I do?
     
  44. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, maybe you can try it in an empty project? Sounds like scripts are missing, but they should be there. Did you install the Burst package from the package manager?
    Edit: sometimes you just need to Reimport or restart the project, please check if the script is really missing or if this is just a mistake by the compiler.
     
    Last edited: Sep 2, 2021
  45. vinjohn

    vinjohn

    Joined:
    Aug 18, 2020
    Posts:
    3
    Hi, I wonder if it support grabbing the cloth from a flat surface with a hand mesh, and if the related documentation is provided? If so, I will instantly buy one!
     
  46. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    You mean, you have a table cloth and you want to lift it? This should be no problem, basically you just add a cloth constraint to a game object and set the cloth you want to manipulate and the intensity. The constraint will pick the nearest vertex and applies it's transform. The doc will take a bit longer because I have currently not much time for it, should be ready in 2 weeks.
     
  47. vinjohn

    vinjohn

    Joined:
    Aug 18, 2020
    Posts:
    3
    Thanks for your reply. I don't know if I understand correctly.
    So the effect would be like the vertex on the cloth will be pinned/attached to the hand mesh, not a physically grasping process based on the collision? The former will look a little strange for a multi-finger hand (after all, you have one point to pin on one of the finger), the latter is what in my mind. According to the #10 reply in this thread (in the first page) by you, the surface collision is supported. I wonder if it could be applied to my desired application? Thanks!
     
  48. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Surface collision is a very general description, currently there is mesh collision (not for mobile devices) and primitive collisions. Mesh collision creates small collision spheres on the vertex points or on triangle surfaces, depending on your decision. These spheres will be sorted out by a voxel octree, so only the nearest spheres will be used.
    The primitive collisions use simple SDF shapes which get all iterated per cloth object, so too many will slow down the simulation.
    Yes, it's a pinned effect, maybe the hand can be used as a collision object to make it more realistic.
     
    Last edited: Sep 2, 2021
  49. vinjohn

    vinjohn

    Joined:
    Aug 18, 2020
    Posts:
    3
    Hi, does it support multiple gpus? Say, one gpu can handle 100K vertex (or not), and two gpus can handle more? Besides, can you share with me the face and vertex number for all the character and cloth meshes in the test scene from http://www.fraglights.com/ClothDynamics/HDRP.zip?

    Thanks!
     
  50. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Cloth Dynamics uses Unity's Compute shaders, there is no external api that runs the system. As far as I know you can't do anything in Unity to influence how SLI gfx cards will process the scene. I think only try to render everything in one scene, because then the gfx cards can split their work per frame.
    Which of the test scenes do you mean? The HD fighting scene has the highest amount of tris count, I think it was about 100k per character, but I will check again, when I'm back in office on Monday. Did you test the latest demo scene from the asset store website?