Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Cloth Dynamics

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

  1. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    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
    - 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, around 20-30 bucks.





    I already created a short documentation with FAQs at the end:
    http://www.fraglights.com/ClothDynamics/ClothDynamicsDocumentation.pdf

    Here you can download the Windows x64 HDRP build demo:
    http://www.fraglights.com/ClothDynamics/HDRP.zip
     
    Last edited: Apr 30, 2021
    victorkin11 and Treecrotch like this.
  2. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    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:
    104
    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:
    19
    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:
    104
    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:
    156
    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:
    124
    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:
    9
    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:
    104
    @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:
    9
    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:
    104
    @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:
    9
    OK @Nexusmaster thanks for you answer. No problem. I will wait for the final version.
     
  14. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    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:
    104
    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:
    104
    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:
    574
    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:
    104
    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:
    104
    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:
    104
    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:
    104
    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:
    104
    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:
    104
  25. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    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:
    21
    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 at 1:05 AM
  27. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    574
    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:
    104
    @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:
    104
    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:
    104
    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:
    21
    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:
    574
    Yes, that would be great because I have a custom clothing shader setup :)
     
  33. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    @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:
    21
    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:
    104
    @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:
    104
    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:
    104
    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:
    104
    So, I uploaded the changes, should be available in two days in the store.
     
    Last edited: May 3, 2021 at 7:23 PM
  39. julesd

    julesd

    Joined:
    Sep 30, 2016
    Posts:
    21
  40. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    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:
    98
    After tried the demo, instant bought it!

    Will it work for virtual reality?
     
  42. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    104
    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:
    104
    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:
    104
    Hi, I'm still working on the Unity 2019 version, will be finished probably tomorrow and online next week!
     
unityunity