Search Unity

[RELEASED] MagicaCloth2 - Hybrid Cloth Simulation

Discussion in 'Assets and Asset Store' started by hoshos, Feb 5, 2023.

  1. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    MagicaCloth2_KeyImage_1950x1300.png




    Hello everyone!

    I am happy to create this thread today.
    MagicaCloth2 has been released!

    Asset Store Link

    Documents

    MagicaCloth2 is a cloth simulation system that can be used with Transform and Mesh.
    This asset allows you to shake anything on your character!
    It works fast with Unity's DOTS (Data-Oriented Technology Stack).
    No need for special shaders!

    It became Version2.0 by adding improvements from the previous work.
    System optimization integrates all components into one and eliminates the need for that cumbersome pre-build (Create button).
    New collision features such as edge collision and backstop are also added.

    Features:
    • Unity DOTS (Data-Oriented Technology Stack) for fast cloth-simulation
    • Works on all platforms except WebGL
    • Available for both Transform and Mesh
    • Achieve 2.5D behavior that combines 2D-like movement while maintaining physically realistic movement
    • Available in all CoreRP/URP/HDRP render pipelines
    • No dedicated shaders required
    • Easy and intuitive interface for quick setup
    • Time manipulation such as slow and stop
    • Point / Edge based collision
    • Self-collision and mutual collision
    • Penetration measure (Backstop by normal line)
    • Normal adjustment function
    • Full support for run-time builds
    • With full source code
    Improvements from Ver1:
    • Eliminate pre-build (eliminate Create button)
    • Remove PhysicsManager
    • Remove RenderDeformer/VirtualDeformer
    • Integrate components into one
    • Greatly simplified parameters
    • Significant improvements in vertex painting
    • Specify vertex painting by texture
    • Doesn’t store subassets in Prefabs
    • Not compatible

    Required:
    Unity2021.3.16(LTS) higher
    Burst 1.8.1 or higher
    Collections 1.4.0 or higher
    * The Burst and Collections packages are installed automatically.
     
    Last edited: Feb 11, 2023
    saskenergy, the_unity_saga and Lymdun like this.
  2. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    Will this include collision for bone springs?
     
  3. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    Unfortunately BoneSpring itself is not included in the first release.
    This is because the initial release was developed with a minimal configuration.
    But it has been added to the roadmap going forward.
    Of course with collision detection!
    Although it has not yet been released, please refer to the next page for the future development roadmap.
    https://magicasoft.jp/en/mc2_roadmap/
     
    YangYuanJie and Hummy91 like this.
  4. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    This is how to set BoneCloth.
    BoneCloth uses Transform to perform cloth simulation.

     
  5. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    How to set MeshCloth.
    MeshCloth combines multiple renderer meshes for cloth simulation.

     
    ikemen_blueD likes this.
  6. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,701
    Looks very impressive!
    May I ask whether this is pure 3D or could I apppy it to 2D elements as well?
     
  7. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello!
    It's basically designed for 3D, but I think it can be used for 2D as well.
    Technically, it should be applicable to 2D as well.
    But I haven't tested it, so I can't be sure.
     
  8. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    Congrats on the release ^^ I am waiting for this GEM for so so long, that I am pretty old now hehe jk
    Purchased it right away :D please keep updates, Unity deserves a better Cloth Simulation system!!!
     
  9. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Thank you!
    We will continue to add more functions in the future, so please look forward to it!
     
  10. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    hey
    small question, is there a chance, the asset will support 2020.3 version? (sadly, we can not use 2021 in our project, and it would be a shame to miss out on magica cloth 2)
    also, is there a way to migrate the values of my characters into the new system (even if its manual/tedious)?
     
  11. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello!

    There are currently no plans to support Unity 2020.
    This is because in Unity2020 some Burst processing does not work in the background thread.
    In Unity2020, Burst only works on the main thread.
    However, after Unity2021, some bursts will run in background threads.
    MagicaCloth2 makes extensive use of this feature.
    This is the reason.

    Also, there is no conversion function from Ver1.
    The parameters have also changed considerably and need to be readjusted.
    However, MagicaCloth2 can be constructed from scripts and all parameters can be manipulated.
    Therefore, it is possible for users to create their own conversion tools.
     
  12. Alaapb1

    Alaapb1

    Joined:
    Mar 4, 2022
    Posts:
    11
    hi is that work with unity 2022.1.15?
     
  13. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Hi, will this version have the Dress-Up system like version 1 has?
     
  14. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Yes it works!
     
  15. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    Yes, there is a dress-up system!
    Already introduced in v2.0.0.
    But the demo and documentation are not ready yet.
    It will take some more time to prepare the documentation.
     
    PolygonPros likes this.
  16. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    486
    Can i use this in subscenes?
     
  17. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    By SubScene do you mean ECS?
    If so, unfortunately it is not available in ECS Entity.
    MagicaCloth is only available in GameObject and Transform configurations.
     
  18. Andy888888

    Andy888888

    Joined:
    Apr 27, 2018
    Posts:
    4
    Great Work!!!! I am waiting for this for so so long! This is the happiest thing so far this year!!!
    Purchased it right away:D:D:D please keep updates, it will be the best Cloth bone Simulation system for Unity!!!
    Thank you so so so so much!!!!!
     
  19. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Thank you!
    We will continue to add more functions, so please look forward to it!
     
  20. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    What is "backstop" and "edge collision" ?
     
  21. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    koirat likes this.
  22. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    hoshos likes this.
  23. Fenj

    Fenj

    Joined:
    Dec 14, 2019
    Posts:
    1
    Does it work at 144fps ?
     
  24. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    MagicaCloth is made independent of the frame rate.
    So by design, 144fps works fine.
    The rest is whether the computational load can keep up.
    I think that it is okay if it is a desktop PC with a CPU with 8 or more cores.
    However, it will be difficult on mobile devices.
     
  25. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    Already bought it however I'm stuck at trying to register colliders in realtime, while it is running.
    I want to dynamically add and remove MagicaColliders automatically to the collidersList with OntriggerEnter\Exit, so that I don't have to do it manually, as I'll have dynamic NPC spawns. I'm not entire sure how to do that.
    I tried this:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MagicaCloth2;
    5.  
    6. [RequireComponent(typeof(BoxCollider))]
    7. [RequireComponent(typeof(MagicaCloth))]
    8.  
    9. public class PGS_Magica_ColliderSensor : MonoBehaviour
    10. {
    11.     BoxCollider triggerVol;
    12.     MagicaCloth MC2;
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.         MC2 = GetComponent<MagicaCloth>();
    18.         triggerVol = GetComponent<BoxCollider>();
    19.  
    20.     }
    21.  
    22.     // Update is called once per frame
    23.     void Update()
    24.     { }
    25.  
    26.     private void OnTriggerEnter(ColliderComponent other)
    27.     { MagicaCloth2.ColliderManager.AddCollider(other); }
    28.  
    29.     private void OnTriggerExit(ColliderComponent other)
    30.     { ColliderManager.RemoveCollider(other); }
    31. }
    32.  
    But I'm being blocked by accessability errors, as its labeled internal [in ColliderManager]. I tried making it public but no success.
    I also tried using
    Code (CSharp):
    1. using System.Runtime.CompilerServices;
    2.  
    3. [assembly: InternalsVisibleTo("PGS_Magica_ColliderSensor")]
    To byapss ther accessability and also did not work. Though iv never used that method before.

    Sadly the runtime page is still WIP. hah
     
    Last edited: Feb 14, 2023
  26. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    It is possible to add/remove colliders during runtime.
    We're currently working on the API documentation, but it's going to take some time.
    Therefore, I prepared a special sample code for this time.
    Working with colliders is very easy.
    The following code adds/removes colliders every 100 frames.

    Code (CSharp):
    1. using MagicaCloth2;
    2. using UnityEngine;
    3.  
    4. public class RuntimeColliderTest : MonoBehaviour
    5. {
    6.     public MagicaCloth cloth;
    7.     public ColliderComponent col;
    8.  
    9.     bool sw = false;
    10.  
    11.     void Start()
    12.     {
    13.  
    14.     }
    15.  
    16.     void Update()
    17.     {
    18.         if (cloth == null || col == null)
    19.             return;
    20.  
    21.         // Check if MagicaCloth is running
    22.         if (cloth.IsValid() == false)
    23.             return;
    24.  
    25.         if (Time.frameCount % 100 == 0)
    26.         {
    27.             sw = !sw;
    28.             UpdateCollider();
    29.         }
    30.     }
    31.  
    32.     /// <summary>
    33.     /// Add or Remove colliders
    34.     /// </summary>
    35.     void UpdateCollider()
    36.     {
    37.         // It manages all parameters that cloth.SerializeData can change at runtime.
    38.         if (sw)
    39.         {
    40.             // add collider.
    41.             cloth.SerializeData.colliderCollisionConstraint.colliderList.Add(col);
    42.         }
    43.         else
    44.         {
    45.             // remove collider
    46.             cloth.SerializeData.colliderCollisionConstraint.colliderList.Remove(col);
    47.         }
    48.  
    49.         // change notification
    50.         cloth.SetParameterChange();
    51.     }
    52. }
    53.  
    The operation is not done to the system manager, but to each cross-component.
    The MagicaCloth component's SerializeData holds all parameters that can be manipulated during execution.
    After changing the SerializeData class, call SetParameterChange() to notify the system.
    Only this.
    This is the same for all parameters, not just colliders.

    However, up to 16 colliders can be set for one cloth component.
    If this limit is too strict, it may be extended, but it is currently 16.
     
    Last edited: Feb 14, 2023
  27. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    Ah man, you are the best. Here is my script :)
    Code (CSharp):
    1. using UnityEngine;
    2. using MagicaCloth2;
    3.  
    4. [RequireComponent(typeof(BoxCollider))]
    5. [RequireComponent(typeof(MagicaCloth))]
    6.  
    7. public class PGS_Magica_ColliderSensor : MonoBehaviour
    8. {
    9.     BoxCollider triggerVol;
    10.     MagicaCloth MC2;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.         MC2 = GetComponent<MagicaCloth>();
    16.         triggerVol = GetComponent<BoxCollider>(); triggerVol.isTrigger = true;
    17.     }
    18.  
    19.     private void OnTriggerEnter(Collider other)
    20.     {
    21.         if (other.gameObject.GetComponent<MagicaCapsuleCollider>() == true)
    22.         {
    23.             {
    24.                 MC2.SerializeData.colliderCollisionConstraint.colliderList.Add(other.gameObject.GetComponent<MagicaCapsuleCollider>());
    25.                 MC2.SetParameterChange();
    26.             }
    27.         }
    28.     }
    29.     private void OnTriggerExit(Collider other)
    30.     {
    31.         if (other.gameObject.GetComponent<MagicaCapsuleCollider>() == true)
    32.         {
    33.             {
    34.                 MC2.SerializeData.colliderCollisionConstraint.colliderList.Remove(other.gameObject.GetComponent<MagicaCapsuleCollider>());
    35.                 MC2.SetParameterChange();
    36.             }
    37.         }
    38.     }
    39. }
     
    hoshos likes this.
  28. DreamGirlGames

    DreamGirlGames

    Joined:
    Jul 3, 2014
    Posts:
    11
    Hey, Magica Soft! ✨
    Thank you for such an amazing release! It works so well! Looks amazing and is so easy to use!

    I am having a very minor issue where my character movement and the magica cloth simulation are not in sync--the simulation seems to jitter and lag at times.
    My characters are updated with FixedUpdate(), so I thought that might be the issue, but it was still showing up with regular Update().
    However, this does not occur when I play full screen or a stand alone build. So it's not a big problem or anything--just something I thought I'd mention. (Maybe it's just my old pc lol)

    I really appreciate the work you've done!
    Thanks! ❤
     
  29. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    Interestingly Iv see a similar very minor issue as well.
    When adding the Magica Collider realtime ONLY while I have it selected so i can watch it update the list, it gets some lag. If nothing is selected it works flawlessly lag free. Possibly related possibly not. Just thought I'd add my observance here as well. In no way does this impact perormance of the game itself, as I said its only when selecting the component for tests. A player will have never seen the impact at all.
     
  30. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello!
    Yes, this is definitely a FixedUpdate() issue.
    V2 does not yet support moving FixedUpdate().

    Support for FixedUpdate has already been registered on the roadmap and will be implemented in the future, so please wait a little longer.
    For reference, the future roadmap is summarized on the next page.

    https://magicasoft.jp/en/mc2_roadmap/
     
    DreamGirlGames likes this.
  31. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    I'm relieved that it worked first.

    The lag issue is probably caused by the inspector in the Unity editor.
    In fact, the display of the inspector is heavy, and if you leave it displayed, the performance will drop.
    The cause of this is not well understood.
    I think it's okay if the build time performance is not an issue.
     
  32. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
  33. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    I watched the video!
    I see, so that's how it was used.
    interesting!

    The wind function will be created as soon as possible.
    Please wait for a while.

    As an aside, this is an old Japanese store, isn't it?
    I'm Japanese so I understand.
     
  34. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    Good Eye! Correct.
    Iv got a couple of nations to make for my game and one is somewhat like the early 1800s Japan(or atleast what I can manage to put together.)
    This is the capital of Okayama so far :)


    https://i.gyazo.com/865765352e4dc5bac21ef38ef7358aa9.mp4
     
  35. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Wonderful!
     
  36. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    197
    Hi, is it unity only or you can export it use it in another application like blender or unreal engine? I wish to use the cloth and other features in another engine is it possible? I just upgraded from v1 to v2
     
  37. il_8izips

    il_8izips

    Joined:
    Dec 17, 2017
    Posts:
    5
    Hi, I upgraded to v2 and have a issue with jittering.

    When I play first time there's no problem, but playing it again makes it more jittery.
    (memory used by burst not cleaned up properly?)

    If I turn on reload domain (Project Settings > Editor > Reload Domain) it works well,
    but unity editor becomes very unstable.

    Unity 2022.2.6f1
    Burst 1.8.3
    Collections 2.1.0pre6
    Mathematics 1.2.6
     
  38. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    140
    I've encountered a bug where MagicaManager registers to the PlayerLoop each time you enter play mode - so it ends up running multiple times per frame. This is with Enter Play Mode options enabled and Doman Reload disabled.
     
  39. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    MagicaCloth works only with Unity.
     
  40. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    I upgraded to MagicaCloth2 and Im having a visual issue with Mesh Cloth. I've set everything up how I'd like it, and when I run in the editor the Moving parts of my mesh turn black? As if the normals or lighting is broken. I tried changing the "Normal Axis" and "Normal Alignment" but nothing fixes the issue, Im unsure why Magica would even affect the normals of my mesh?

    With Mesh Cloth Disabled: http://puu.sh/JzshR/33c6a307ef.jpg
    Broken: http://puu.sh/Jzsht/9c29f9dc20.jpg
     
  41. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    @il_8izips
    @LudiKha
    Hello.
    Thank you for your report!
    This is definitely a problem caused by Enter Play Mode.
    It turned out that the job is duplicated when Enter Play Mode is turned on.
    Please wait for a while as we will fix it.

    playmode-1.jpg
     
    nattuhan likes this.
  42. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    I saw the image.
    However, I was unable to pinpoint the problem from the images alone.
    I would like additional information.

    * Is the shader Standard or a special shader?
    * Are all other meshes the same or just this skirt?
    * Which BuildinRP/URP/HDRP are you using?
     
  43. yupengfei

    yupengfei

    Joined:
    Nov 10, 2017
    Posts:
    21
    When will the dressup document be avaible?:)
     
  44. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Hello.
    I'm a little late because I have a problem.
    But it should be out within a week.
     
  45. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    A few extra notes, I was using Unity version 2020.3 before, I upgraded to 2021.3.18f1 so I could try out MagicaCloth2. This problem doesn't occur in 2020.3 with MagicaCloth1 on the same skinned meshes.
     
  46. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    Update: 2.0.1

    v2.0.1 has been released on the Asset Store!
    https://u3d.as/2Zc3

    Release Note:
    Fix: Fixed an issue where using the Enter Play Mode Options would cause strange behavior on subsequent runs.
    Fix: Fixed vertex paint cursor disk misorientation.
    Improvement: Added version notation to MagicaCloth component.

    https://magicasoft.jp/en/mc2_releasenote/
     
  47. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    @il_8izips
    @LudiKha
    An issue with Enter Play Mode Options has been fixed in 2.0.1.
    2.0.1 is already on the market.
    Please update and check.
     
    il_8izips likes this.
  48. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    922
    I see, then it's most likely a V2 issue.
    Could you please tell me the following situation?

    * Is the shader Standard or a special shader?
    * Can you tell if the shader is using tangents?
    * Are all the meshes that utilize MagicaCloth2 the same, or is it just this skirt?
    * Which BuildinRP/URP/HDRP are you using?
     
  49. il_8izips

    il_8izips

    Joined:
    Dec 17, 2017
    Posts:
    5
    Thank you for quick updating!
    With 2.0.1 the problem fixed
     
    hoshos likes this.
  50. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Magica Cloth 2 and VRoid Studio (VRM) character questions (and successes!).
    • I took a VRoid Studio VRM character (with UniVRM), disabled the VRM Spring Bones and added Magica Cloth 2 with "Bone Cloth" and it just worked! Very nice! (I have not done all the collision stuff yet, I started only with hair and not skirt etc, but so far it has worked really well.)
    • A challenge however (which might not be important). I was trying to use Mesh Cloth mode for the clothes. The problem I hit was the SkinnedMeshRenderer has all of the body layers in it - the body skin, shoes, pants, top clothing, etc. So when I added it, it was very hard to say "just do the outer layer of clothes and not the skin under it". I found it very hard to paint this because the clothes and skin are very close together. (Note: the clothes all have bones for skirts etc, so I will probably just stick with bone cloth.)
    • I assume to get different settings for different parts of the hair etc. I should add multiple components - e.g. one for the fringe and one for long hair at the back of the head. If I understand, the presets are per component, so I should add different bones to different components so I can give them different settings? (This is what VRoid does with VRM Spring Bone too - creates lots of different components controlling different hairs.)
    • Another vote for wind support! There is one for VRM Spring bones https://github.com/malaybaku/WindForVRM, looking forward to something for Magica Cloth 2 too! Great for hair etc, but also flags.
    • I am getting this error. [Deleted: I think it was some Magica Cloth 1 components I forgot I added in the past!]
    Thank you!
     

    Attached Files:

    Last edited: Feb 18, 2023