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
    Hi staron, I fixed the issue with the prefab, it was caused by the ABS Editor script, so for now you can change the AutoBoneSpheresEditor.cs to AutoBoneSpheresEditor.cs_bak to disable it.

    I sent the new fixed version (1.5.1) to the asset store, should be soon available!
    Thank you for finding this bug!
     
  2. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I will have a look at UMA and try it myself if it works with CD. Basically it should be possible. In Unity you can always save and load or copy component settings during runtime, but you need a script that does this for you. CD can also just be added at runtime, but depending on the cloth mesh it might take a while to load, so I added a pre-cache function that caches the cloth init data in a file, which can be loaded at runtime. Of course, this pre-cache only works when you don't edit the cloth mesh vertices and triangles at runtime.

    Edit: I had a quick look at UMA, I could add a support for this, but this might take some time, because the skinned mesh needs to be converted to a gpu skinning mesh, at runtime and this currently not always works with UMA. Also, the clothes need to be detached from the bodies to work. ABS also needs a fix to work with the UMA bones structure. SO, I would only start supporting this, if at least 20 people, who are using UMA, also want to use CD.


    - Does this asset has problems with non-uniformly scaled bones?
    I don't think so, I have a test scene where I scaled the "breast bones" of a character to zero, also included in the demo, however the vertices that get scaled can't use the skinning support functions anymore.

    - Can i use this with a generic rig instead of humanoid?
    Yes, but some functions e.g. the AutomaticBoneSpheres, might not work properly, but the AutomaticBoneSpheres are not required for the cloth sim to run. Basically you can use any mesh as a collider with the cloth, the ABS just creates simple colliders, like spheres or round cones, that might help/improve the collision in some cases, but I also have some great results with just pure cloth to mesh collision with good performance, really depends on your settings.

    - is there an ETA of the next update?
    Not really, but my plan is to release the next big version 1.6 in 2-3 weeks. Maybe I will ditch some features and add them to a later version, but I will definitely increase the price, if that's it why you asking ;-)
     
    Last edited: May 31, 2021
    SammmZ likes this.
  3. Framehacker

    Framehacker

    Joined:
    Jan 30, 2020
    Posts:
    14

    Thanks for the detailed answer, and even taking your time to try UMA out.

    Then lets hope we can make that 20 full, you can definitively count me in there.
     
  4. SammmZ

    SammmZ

    Joined:
    Aug 13, 2014
    Posts:
    174
    Hey! UMA is my main character framework so I would be happy to get UMA support.
     
  5. Uajrh1

    Uajrh1

    Joined:
    May 24, 2018
    Posts:
    2
    Would love some UMA support
     
  6. MightyDubster

    MightyDubster

    Joined:
    Apr 23, 2020
    Posts:
    1
    Count me in! I would love to use this asset if it had UMA integration.
     
  7. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    @Nexusmaster
    Hi, I do have some more require, I know CD come with shader graphic source nod for customize your own shader, but it isn't work for build in render pipe line, and the build in render cloth shader function look very limit, as least support some cutout shader or transparent shader, it will be very nice.
     
  8. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    208
    A UMA integration would elevate this asset gigantically for me - please consider adding support!
     
    JonBanana likes this.
  9. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Add in another person interested in UMA integration!
     
    JonBanana likes this.
  10. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    If you using the builtin system, maybe you are familiar with the surface shader system of unity, because basically CD uses this system, so if you know how to change/edit a surface shader you could also just edit the CD cloth shader or create a new one. CD looks for a shader with the naming "Cloth" so if your new shader name contains this, CD won't replace the shader and uses yours. https://docs.unity3d.com/Manual/SL-SurfaceShaders.html
    I can add a cutout or transparent shader in the next version as an alternative custom selection, but it's very easy to change it yourself. Hope this helps!
     
  11. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Currently there are some issues with the iOS Mac Metal system, so I will try to fix it. Anyone how also has problems with his Mac and CD can write me a PM or email, please, so I can debug better...
     
  12. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    Thank!!
     
  13. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Just a quick soft body test with an icosphere and the current CD version:


    I would not say CD is ready for soft body sims, but it's not so far away.
     
  14. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    If you not show it, we just don't know what CD can do!! thank!
     
  15. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    That's true, but I'm a bit lazy making all that videos and it takes longer than you think! :rolleyes:
     
  16. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Btw. In the advanced mode you can turn off the Garment Update if you are happy with the garment settings, this will increase the performance a bit.
    upload_2021-6-3_14-9-54.png
     
  17. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    Hi,

    I need dynamic cloth system for character who work on mobile, I already own obi cloth should i buy this asset instead ?
    What are the pros and cons ?

    Thank
     
  18. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Well, CD should be faster on modern mobile, because it uses the GPU. However, currently iOS is not tested and might be buggy. There might be a cloth to mesh vertex support for mobile with CD in the future. Obi normally uses a simple way to push the vertices away from the character, which I had problems with, that's why I started this asset. I think Obi might be better for non character stuff, but I'm more happy with my cloth system using it on the characters. I generally was not so happy with the Obi setup process and didn't get the results I wanted. But the main reason was the performance, but I didn't compare the performance on mobile yet, so can't tell you right now.

    Obi has some more features like tearing cloth, which I will add soon to CD.
     
    Last edited: Jun 4, 2021
    JonBanana likes this.
  19. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    85
    Thank for your answer i ll put your asset in my wish list :)
     
  20. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Good news, I found a possible fix for the metal API issue, anyone who has problems with it, just try and increase the Voxel Cube Scale to 4 or higher so the cloth is completely covered in the voxel cube. This is just a quick fix, I will try to fix the issue via code asap.
     
  21. faintle2

    faintle2

    Joined:
    Jun 28, 2019
    Posts:
    6
    hi,
    Very interesting asset, great job! But when I tried the demo build, very low framerate and not cloth displayed, I'm using AMD ryzen, are there some compatibility problems with AMD?
     
  22. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    What are your specs besides AMD (GPU) ? Are you using Windows10 x64 ?

    Edit: I just tested it on a Ryzen myself, and there is no problem with that. But there might be an issue with an AMD GPU, do you have one?
    If so, I think I can fix it... there was some problems with the AMD cards writing into IndirectArguments Buffers via shader. I thought it was fixed via driver update, but maybe it's not, do you have the latest driver? I can fix the IndirectArguments issue when I copy the buffer count, however this step is not so optimal, but possible.
     
    Last edited: Jun 11, 2021
  23. faintle2

    faintle2

    Joined:
    Jun 28, 2019
    Posts:
    6
    Thanks for your reply. Yes, I'm using the integrated gpu of ryzen 7 5750G with latest driver, win10 x64.
     
  24. faintle2

    faintle2

    Joined:
    Jun 28, 2019
    Posts:
    6
    The fps is less than 5 and all the clothes are missing
     
  25. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I can make a new demo with possible buffer fixes, next week, please try it out when it's done.
     
  26. faintle2

    faintle2

    Joined:
    Jun 28, 2019
    Posts:
    6
    Sure! Thanks
     
  27. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi, I was thinking about the teleporting problem (frame jumping), maybe I can improve the system by checking the next frame of the character's animation, and compare the difference. So if there are high variations in position, the system blends to skinning and if not it can turn off skinning.
     
    yukocchi likes this.
  28. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
  29. faintle2

    faintle2

    Joined:
    Jun 28, 2019
    Posts:
    6
  30. faintle2

    faintle2

    Joined:
    Jun 28, 2019
    Posts:
    6
  31. pedropla

    pedropla

    Joined:
    Apr 9, 2018
    Posts:
    21
    @Nexusmaster do you have a mobile apk demo of this with an FPS counter I can test on mobile? I would definitely be interested in an uma version if it performs well on mobile.
     
  32. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Currently I have much work to do, I will try to make it next week...
     
  33. pedropla

    pedropla

    Joined:
    Apr 9, 2018
    Posts:
    21
    that would be awesome! Also can it easily be activated/deactivated based on LOD?
     
  34. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I called it LOD mode, but basically it blends from cloth sim to skinned cloth via distance, so you need the cloth to be skinned to the character.
    Edit: But I think you mean, that you have LOD cloth meshes, they can also have the cloth applied, currently each needs a cloth component.
     
  35. pedropla

    pedropla

    Joined:
    Apr 9, 2018
    Posts:
    21
    Thanks. If it runs well on mobile I’d definitely be interested in it on UMA.

    What I meant by LOD is that once it’s at a certain distance it no longer calculates cloth physics and acts as a normal skinned mesh for uma characters.
     
  36. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Yes, that works.
     
  37. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Btw. Currently everyone who makes a build should add the needed cloth shader, which is used in the cloth materials, to the included shaders e.g. URP:

    upload_2021-6-21_8-14-27.png

    I will make this automatic in the next version.
     
  38. pedropla

    pedropla

    Joined:
    Apr 9, 2018
    Posts:
    21
    Can this shader be added as an addressable?
     
  39. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Currently the shader is in a Resources folder, when you make it an addressable you should copy the subshader graphs to the new directory or at least make sure the shader finds them... I can't support addressables, because not everyone uses them.
     
  40. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I will take a break on this project for 2-3 weeks, because I need to finish my game. I'm still available for small support questions, after that break I will update CD to the latest version, here is a preview of one new feature, cloth creation at runtime:
     
  41. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    Runtime cloth createtion. Look interesting.
     
  42. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I will also add a feature, that let you create a voxel grid point collision object, based on your cloth mesh, so the sim quality will be also improved for non uniform meshes. Basically, the plan is to make something more similar like NVIDIA's Flex, but with no CPU readback and more platform support!

    Btw.: If you are not happy with this product, please be nice and don't write bad comments about it, you will just not help to improve this product with that attitude. You can get a free refund in 14 days and in special cases also later.
     
  43. sdqq1234

    sdqq1234

    Joined:
    Jan 9, 2013
    Posts:
    7
    good work! I bought your plugin, but when I add a mesh objects in collision setting, and change the vertex scale, I can't view the vertex colliders size such as the video from 70s. will there be this feature in the future?
     
  44. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Yes, the visual Debug system will be improved, there is already a Debug display of points, but not so much information.
     
  45. sdqq1234

    sdqq1234

    Joined:
    Jan 9, 2013
    Posts:
    7
    That's great, I am looking forward to your new features.
    By the way, how to use my custom shader in your cloth system?
     
    r3ndesigner likes this.
  46. r3ndesigner

    r3ndesigner

    Joined:
    Mar 21, 2013
    Posts:
    143
    Its important to mee too, I want to use it with a toon shading, with outline, ll be good to know the behaviour for outlines.
     
  47. glad2020

    glad2020

    Joined:
    Jun 11, 2020
    Posts:
    1
    After buy cloth dynamics, i find it lacks some examples such as kimono and nyao。
    other examples have obvious defects
     
  48. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    As I mentioned kimono and nyao are not included, because the models are from DAZ. But the setup is the same like e.g. the DressAndHair example, what "defects" are you talking about? You can also write me a PM.
     
  49. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    For a custom shader you need to add this function to your Vertex shader:

    Code (CSharp):
    1. StructuredBuffer<float3> positionsBuffer;
    2. StructuredBuffer<float3> normalsBuffer;
    3.  
    4. void MyClothFunction_float(uint vertexId, out float3 vertex, out float3 normal)
    5. {
    6.     vertex = positionsBuffer[vertexId];
    7.     normal = normalsBuffer[vertexId];
    8. }
    So basically this overwrites the vertex position and normals of your cloth mesh. You can calculate the tangent vector (if needed) after this with a cross(normal, float3(0,1,0)) which is not perfect but works in most cases.

    The "vertexId" gets saved via ClothDynamics script in UV1, you can also switch the UV channel in the inspector (advanced mode) but then you also need to change the channel in the shader.
    This is only because ShaderGraph does not support VertexIDs, in a custom shader you can just use the normal SV_VertexID.

    Search for "ClothSubGraph" if you are using ShaderGraph.
    Hope this helps!

    All the best,
    Chris
     
    Last edited: Jul 7, 2021
    victorkin11 and staron82 like this.
  50. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    For everyone who has the issue with the permeate skin visibility:
    I made two examples that have almost no permeate skin visibility. (See attachment)

    The main reason for the flickering comes from the fact that the particles (vertices) are pulling eachother, reducing the stiffness, adding damping and turning off self collision helps to improve it, but I'm still working on it.

    The main reason for the permeate skin is the collision system, it's not perfect, I must admit, however without "predictive contact" the results are better (see the example scene "DressAndHairNoPC.unity" in the attachment).

    I'm working on improving and combining the collision system. Self collision works better with Predictive Contact, I will try to combine this part with the better "No Predictive Contact" collision.
    For my example scenes to work you need to unpack the builtin package or replace the materials with the ones of your current SRP.

    There will be always some cases with fast animations where you might see skin under the cloth, so one idea I had is to paint the vertices, which are under the skin, with an alpha value of 0, so you won't see them.
    Another approach, which I'm working on, is to make this more dynamic, meaning that the alpha vertex painting happens on the fly and uses the camera perspective to paint only the vertices invisible that are currently under the cloth mesh, so you won't notice it, if the cloth mesh moves or get removed.
     

    Attached Files:

    victorkin11 likes this.