Search Unity

[RELEASED] Cloth Dynamics

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

  1. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Asset Store:
    https://assetstore.unity.com/packages/tools/physics/cloth-dynamics-194408



    Cloth Dynamics is one of the fastest realtime GPU based cloth simulation systems for Unity3D.
    It should run on all next-gen mainstream platforms: PC, Mac, Linux, Consoles and Mobile.

    Features:
    - Fast and solid GPU cloth simulation (with and without skinned meshes)
    - Multi collision system with PBD for mesh collision and SDFs for primitives (Sphere, Cube,...)
    - Automatic Bone Spheres system creates primitive collision objects for characters in one click
    - Modern Mobile support (limited to primitives collision only)
    - GPU Skinning (with Unity standard or Dual Quaternion Skinning)
    - Automatic Skinning
    - Garment Mesh Creator
    - LOD system
    - HDRP, URP and Builtin-RP supported
    - Full source code
    - Complete content from the video is included in the package

    Why creating a new cloth simulation asset:
    I'm currently working on a next-gen game and needed a fast cloth sim solution for my characters. So, I tested different cloth sim assets from the store and also a new beta gpu based cloth system, which will be soon released for unity. However, all of them were eating up my framerate, so I decided to create a fast and "simple" GPU cloth system. I started with a free gpu cloth source and extended it for my needs, out came "Cloth Dynamics".

    Fair refund policy and price:
    I don't like assets where you can't get your money back, if you are not happy with them. So, I decided to give every customer the opportunity to get one refund without questions ask, when he/she wants to return it in 14 days. So you have 14 days to test the product. Also the price will be quite fair.

    Edit: Unity changed the refund policy:
    Users can request refunds for specific assets from the Order History page.
    The new refund flow will require users to submit a reason for each request. Refunds will only be granted automatically in cases where the user did not download a package purchased less than 14 days prior. In all other cases, the request will be sent to Unity Customer Support, where they’ll be handled independently, following the current refund policy.


    I already created a short documentation with FAQs at the end:
    https://drive.google.com/file/d/1hNYMBu12LZqfLl6zJYThqubHVP-N16S8/view?usp=sharing

    Here you can download the Windows x64 HDRP build demo:
    http://drive.google.com/file/d/1pRzRWiUzKHg8H_YEdpZnlg7MQ-2iMRwN/view?usp=sharing
     
    Last edited: Feb 11, 2022
    daneobyrd, victorkin11 and tree_arb like this.
  2. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi,
    I will soon upload a daz model video. In this current video there are only free models that will be included in the package. The price will be around 20-30. I also tested different cloth sims, but I was not happy with the performance.
    I'm still working on improving the collision, also the mesh proxy needs some improvement, the rest is fine.
    So, release date might be around January-February. Beta testing currently is quite complicated because I don't want to share the full source code with the beta testers (and I can't precompile the compute shaders in Unity).
    Maybe I can make a "import your own" mesh demo, if it's not too complicated. I really like to focus on finishing this, so a test demo might come out after the release.
     
    Last edited: Dec 17, 2020
  3. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Here is a new test with a DAZ character in a Kimono outfit:


    I'm still working on some bug-fixing and I will not rush with the release, before everything works fine. Hope you guys understand that. Thanks!
     
  4. Kory-therapy

    Kory-therapy

    Joined:
    Jun 5, 2013
    Posts:
    56
    thanks for the daz3d video I was wondering do you have plans on adding a wind physics
    example frame :30-50
    video
    something like this unreal engine flag
    video


    thanks for your time
    Kory
     
  5. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, in the first video / demo is also a flag example included or do you mean a tutorial video?
    The hitman example is a great idea, I will try that out, thanks!
     
  6. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    867
    This looks very interesting! I am working on the exact same thing, using the same stuff (DQS, PBD, both from same projects as you). Would buy this package instantly to save some time, as you have integrated stuff I have not done yet (self collision).
     
  7. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    Well I can't wait for this !!
    I'm still using Unity cloth !

    Your asset looks rather cooler indeed! You have another customer!
     
    Kory-therapy likes this.
  8. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Looks great! How does it compare to Magica Cloth though?
    Magica uses Burst and Jobs, and this uses GPU simulation.
    Is it faster or more accurate?
     
  9. NexarChile

    NexarChile

    Joined:
    Apr 29, 2016
    Posts:
    17
    Hey @Nexusmaster ! I'm impressed with your work! Your HDRP demo is very good! When will you release your asset? Here you have another customer! :D
     
  10. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @Qleenie: Yes, I added some more stuff, like surface collision detection which is more stabil. Thanks for your interest.

    @vertexx: Unity cloth is also not bad, the performance is ok, but the vertex setup is not very user friendly so I decided to make my own system. You can create all these collision colliders automatically with Cloth Dynamics and use Round cones which are basically two spheres connected to one collider, which is more efficient that creating many spheres.

    @skiwee: I didn't try Magica Cloth, but I'm sure my system is faster when you have meshes with more vertices, you can also get a vertex to vertex (or vertex to triangle) collision with my system, not sure if that is possible with Magica.
    My system is more similar to this one: https://deformdynamics.com/

    @NexarChile: Thanks!

    Btw.: Sorry for the delay! I'm trying to improve the collision system a bit, because currently if you have fast animations the underlying mesh might be visible though the cloth mesh, so I need to fix this before the release. It's possible to hide the mesh part under the cloth via shader, but it would be much nicer if the cloth will be more correctly moving with the animations.
     
  11. NexarChile

    NexarChile

    Joined:
    Apr 29, 2016
    Posts:
    17
    Hey @Nexusmaster Thanks for your answer.

    Do you have an ETA for the release?
    On previous post you said the release date might be around January-February.
    I have a proyect on March and I want to know if it's possible to include your solution on this project.

    Thanks!
     
  12. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @NexarChile: Sorry, looks like it will be end of march. Maybe earlier but I can't promise anything.
     
  13. NexarChile

    NexarChile

    Joined:
    Apr 29, 2016
    Posts:
    17
    OK @Nexusmaster thanks for you answer. No problem. I will wait for the final version.
     
  14. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, sorry for keeping you waiting!
    Good news, I could finish fixing all my old bugs and I will not add new features to the system anymore until release.
    The bad news, there is still a collision bug in the standalone app, when a scene gets loaded and there are more than one cloth sims running (does not happen all the time but sometimes).
    After fixing this bug, I will release the first version.
    Here is a new test video, the auto skinning is done in Unity, so normally I would do it in Blender, this is just for testing:


    ^
    This shows a test video of the GPU Cloth Dynamics for Unity, it handles four cloth simulations at the same time at runtime with about ~90 fps (depending on the scene and cloth setup). In the background there are also cloth sims deactivated and running only as skinned meshes. If the camera comes closer the cloth simulation gets activated.
     
    Last edited: Apr 6, 2021
    NexarChile, Rowlan and Qleenie like this.
  15. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Good news everyone, I fixed the bug in the standalone, so no more bug fixing for now. Next steps are cleaning up and sending it to the asset store. Furthermore, I will make some tutorial videos. Cheers!
     
    NexarChile and Qleenie like this.
  16. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    This is the latest build with a new daz character test:


    I updated the windows build demo:
    http://www.fraglights.com/ClothDynamics/HDRP.zip (~250MB)

    The asset will be probably available next week, depending on how fast the unity team will process it.
     
    Last edited: Apr 26, 2021
    Rowlan, Bartolomeus755 and NexarChile like this.
  17. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Congrats on the release! Could you perhaps add some more details on performance? A showcase with some background scenery as additional GPU load plus a couple of character would make for a more reasonable performance test. Also perhaps a sort of stress test with a larger number of characters? Oh and another quick question - what do you do with the result from the compute shader, are you sending that back to the CPU? Also, could you perhaps create a video showing the setup process of taking a regular skinned character (with clothing) and setting it up to work with your asset?

    Anyway, really interesting stuff!
     
    Last edited: Apr 29, 2021
    LudiKha likes this.
  18. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi one_one,
    thanks! Good questions! Did you already download the Windows Build Demo and test it on your computer? If you press Win+G or use the Nvidia Overlay, you can get an FPS display.
    It's really not that simple to showcase all the scenarios, because also the Builtin and HDRP setups run on a different FPS.
    In the demo there is a setup with 6 characters each has two cloth sims using the LOD switch (for turning the cloth sim off in the background). Also the multi belly dancer scene has 3 character sims running at the same time. But basically I would recommend not to use so many sims at the same time. Also it makes sense to pack cloth parts together e.g. shirt plus trousers as one sim for one character. Cloth Dynamics is focused on character clothes.
    In all the test scenes I get an FPS count between 60 and 90 fps with FullHD Res, I have an GTX 1080, a i7-3820 CPU @ 3.60GHz and 32GB RAM.

    The compute shader results get send directly to the cloth shader of the cloth materials. So there is no CPU readback. However, I used an Async GPU Readback for calculating the bounding box position of the cloth vertices, so the voxel grid can be positioned around the cloth, but this does not affect the performance and can be also be switched off if your cloth stays more or less in the same place.

    Currently most performance loss accrues when you use too many primitive colliders per character or you have too many vertices colliding at the same place (see stress test).

    I will soon post some video tutorials, sorry for the delay (again) !
    All the best,
    Chris
     
    Last edited: Apr 30, 2021
    one_one likes this.
  19. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I just found another small bug in the new release, there is an issue with the collision of the capsule-collider, I already fixed the bug, but you need to wait until it's online in the store.
    Also there might be some material-missing-errors, just tell me if you have them, I will try and fix it in the next release!
     
    Last edited: Apr 30, 2021
    NexarChile likes this.
  20. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Here are the first tutorials and more will come soon!

    Short tutorial:


    Long Version:
     
    one_one, cjjeffery and NexarChile like this.
  21. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Next week I will upload a Unity2019 version!
     
    NexarChile and wetcircuit like this.
  22. kalinins1998

    kalinins1998

    Joined:
    Apr 19, 2020
    Posts:
    2
    Hi, I am using Unity 2020.3.6f1 HDRP My system
    AMD RX480 RedDevil / Xeon X5650 6/12 / 24Gb I can't see clothes on the scenes from the examples. I do not see any errors either during playback or in shader compilation. Maybe I'm doing something wrong, what could be the problem?

    upload_2021-4-30_20-48-23.png
     
  23. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Are you using HDRP? You can select the cloth objects in the hierarchy and apply normal Lit materials to them. When you hit run the system should replace them. Check if the shaders are imported correctly. Sometimes shadergraph shaders do not get imported right. Just select them and press reimport. Also a screenshot with the selected cloth and the material would be more helpful. (Search for the Shaders folder and reimport them, see my long video tutorial)
     
    Last edited: Apr 30, 2021
  24. Nexusmaster

    Nexusmaster

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

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    If this does not help write me a PM and I will try to figure it out, thanks! And sorry there might be still some bugs I will try to collect and fix them all next week with a new update!
     
  26. julesd

    julesd

    Joined:
    Sep 30, 2016
    Posts:
    26
    Same here. And I have tried everything you said. Shows in editor but not runtime.
    Unity 2020.3.6f1; HDRP; AMD 5700XT
    I believe it has something to do with the mesh and not the material.
    I believe it is the GPU Cloth Dynamics Script. If I disable it and run I am able to see mesh. With SimpleShapes Scene.

    The GPU Skinning (Script) also I believe.

    Wish I had a RTX 3090 and test it perhaps it is AMD cards.

    I noticed that when I run it. The check mark in the box for 'Render' in the GPU Skinning (Script) get's unchecked at run time. Could that have anything to do with it?
    I am not a programmer but I believe for sure the problem is in 'GPU Skinning (Script)'
     
    Last edited: May 1, 2021
  27. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Great, that's very helpful! Nope, admittedly haven't tried the demo build yet. Good to hear there's no CPU readback for the rendering. I see that the shaders are integrated into HDRP Lit shaders - would it be feasible for this to be packed into a shader graph node?
     
  28. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @julesd is the demo build running on your sytem, when it works it should also work in unity. Can you please select a cloth material in playmode and make a screenshot of the complete unity editor? Thanks!
     
  29. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Yes that might be the problem, can you try and turn on "use custom voxel center", I think the GPUReadback does not work correctly with AMD cards, I have to further investigate this. If you can't see the green bounding box it might not work correctly.
    upload_2021-5-1_15-37-24.png
     
  30. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    They are shadergraph shaders, but I can also make a sub graph if you prefer this.
     
    one_one likes this.
  31. julesd

    julesd

    Joined:
    Sep 30, 2016
    Posts:
    26
    No still does not render mesh.
    No still does not render mesh to screen. While performing simulation.
     
  32. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Yes, that would be great because I have a custom clothing shader setup :)
     
  33. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @julesd and @kalinins1998 I will run a test with my old AMD laptop, maybe I can figure it out.
     
  34. julesd

    julesd

    Joined:
    Sep 30, 2016
    Posts:
    26
    If any one else has a AMD card and Cloth Dynamics for unity could you please post your results with Cloth Dynamics?
     
  35. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    @julesd & @kalinins1998:
    Good news, I could test it on my old AMD laptop and also the cloth gets invisible in URP (HDRP is not working on this laptop). I switched to builtin and it works! So it must be some issue with the shadergraph shader. Can you please try the builtin content (please delete the HDRP content first) and see if that works. Thx!
     
    cjjeffery likes this.
  36. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Of course I will now try to fix the issue in URP and try to transfer the results to HDRP. But please let me know if builtin works for you, so that we are on the same page.
     
  37. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Ok, so here is the fix ( I will upload it in my next version 1.2):

    go to:
    Assets\ClothDynamics\Resources\Shaders\SRP
    open:
    ClothFunc.hlsl

    and rewrite this:

    Code (CSharp):
    1. Buffer<float3> positionsBuffer;
    2. Buffer<float3> normalsBuffer;
    into this:

    Code (CSharp):
    1. StructuredBuffer<float3> positionsBuffer;
    2. StructuredBuffer<float3> normalsBuffer;
    reimport the shadergraphs or open the shaders in the graph and save them. Thats it.
     
  38. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    So, I uploaded the changes, should be available in two days in the store.
     
    Last edited: May 3, 2021
  39. julesd

    julesd

    Joined:
    Sep 30, 2016
    Posts:
    26
    Thanks.
     
  40. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I found a minor bug happening only with android, you need to replace following line in GPUClothDynamicsEditor.cs to fix it:

    Code (CSharp):
    1. #if UNITY_ANDROID || UNITY_IPHONE
    2.                                 EditorGUILayout.LabelField("This feature doesn't work on mobile devices!", s);
    3. #endif
    to

    Code (CSharp):
    1. #if UNITY_ANDROID || UNITY_IPHONE
    2.                                 EditorGUILayout.LabelField("This feature doesn't work on mobile devices!", orangeStyle);
    3. #endif
     
  41. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    After tried the demo, instant bought it!

    Will it work for virtual reality?
     
  42. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hm, didn't test it, but should be fine, because the shaders that render the cloth are based on Unity's graph shaders. So if the shadergraph works with VR this should also work in VR. The only thing I can think of is the frustum culling that currently only looks for the main cam, so in VR with two cams you should probably turn it off.
    upload_2021-5-5_13-10-19.png upload_2021-5-5_13-11-36.png
     
  43. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Just for anyone who is more interested in mesh gpu collision than characters, I'm currently working on a solution to make the GPU Mesh collision better. Because, currently ClothDynamics is focused on character collision and when you try to use environment as GPUMesh you will find out, that the scale values differ per mesh:
    upload_2021-5-5_13-17-1.png
    Basically, it makes sense to only use one environment mesh collision object per cloth, I will try to move the collision scale to the mesh component to make it more flexible, currently it's best to use a few "Collidable Objects".
    upload_2021-5-5_13-20-59.png
    I will also try to improve performance with the CollidableObjects.
     

    Attached Files:

  44. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, I'm still working on the Unity 2019 version, will be finished probably tomorrow and online next week!
     
  45. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    It is possible to make a dress like this?
    Dress.jpg

    I saw this from youtube.
     
  46. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Better use an external tool like Marvelous Designer or the Blender Garment Tool https://gumroad.com/bartoszstyperek#MAnWP and import it in Unity.

    However you can try my simple garment tool but it's not that easy, I will make a tutorial video soon about this. Basically you get the cloth wrinkles, when you make holes and stitch them together. I'm thinking about improving this feature, but currently it's only meant for simple cloth objects and testing purposes.
     
  47. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I'm not so happy with unity's dependency asset recognition, so it's best when you import Cloth Dynamics, skip the dependencies and just import "Burst" in the package manager. That's it!
    In future versions I will remove the dependencies and try to create a wizard that tells you to install burst.
     
  48. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    I am very happy the result. . Try to use MagicaCloth demo scene vs Cloth Dynamics, the fps not accurate, but it should more than 400fps, use i7 gtx1070.

     
    jcluts likes this.
  49. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,270
    What exactly is that supposed to compare?
     
  50. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    The detail of the cloth
     
    jcluts likes this.