Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[RELEASED] MagicaCloth2 - Hybrid Cloth Simulation

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

  1. retired_unity_saga

    retired_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    290
    hello,
    a few questions

    Unity 2022.3.14 changelog notes
    Changes:
    • Burst: Removed all code specific to DOTS Runtime.
    Does this mean your asset won't function correct in Unity 2022.3.14?? or does it still work because of their other changes:

    • Burst: Added support for System.Math functions Acosh, Asinh, Atanh, Cbrt, CopySign, Log2, SinCos, FusedMultiplyAdd, and ILogB.
    Which version do you recommend developers to use?

    also



    How did you get this model to look so good in this trailer? Which shader is this?

    thanks
     
  2. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Unfortunately, the current MagicaCloth cannot be reused.
    Once BuildAndRun() is executed, the only option is to discard it.
    Reuse certainly improves convenience, so I would like to consider implementing it at a later date.
     
    aitaiwanmei likes this.
  3. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    I don't know what this DOTS update means, but rest assured that MagicaCloth will work fine with Unity 2022/2023.
    Before shipping, we always check the operation with Unity2021/2022/2023.
    Also, the added Math function is currently not used in MagicaCloth.
    These functions are currently unnecessary for MagicaCloth, so there are no plans to use them.

    The characters in the PV use UnitychanToonShader2.0.
    This shader is freely available to everyone.
    https://unity-chan.com/

    However, this shader is not included in the MagicaCloth2 package due to its large size.
     
    retired_unity_saga likes this.
  4. retired_unity_saga

    retired_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    290
  5. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
  6. aitaiwanmei

    aitaiwanmei

    Joined:
    Jul 23, 2014
    Posts:
    2
    Thanks for your reply. As skin generation happens quite frequently, I'm trying to destroy the Magic Cloth component instead of the whole game object. The overall result seems good, but there's something a bit odd, like the initial state of the transform or vertices have changed.
     
  7. RabberDakk

    RabberDakk

    Joined:
    Feb 23, 2019
    Posts:
    14
    im using toonshader, outline is not displayed only in the area is green in meshcloth. is this problem solved by the Tangent update mode in the roadmap? toonshader often uses normal for outline. does meshcloth remove normal?
     
  8. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    It's probably a character attitude issue.
    MagicaCloth must be initialized with the same posture as when editing.
    The posture at the time of editing is the posture in which vertex painting was performed.
    Therefore, if the character's posture at runtime is different from when edited, it may not work properly.
    Perhaps this is the case.

    If you want to change costumes at runtime like this time, you should also store the character Transform required for initialization on the costume prefab side.
    In other words, save the character's Transform in the prefab along with the pose it was in when editing.
    Then, initialize MagicaCloth in the prefab state, and then port MagicaCloth to the target character.
    These methods are summarized in the following document, so please refer to it.
    https://magicasoft.jp/en/mc2_dressup/
     
    kana1939 likes this.
  9. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Perhaps it is a tangent issue.
    Currently MagicaCloth recalculates normals, but not tangents.
    Recalculation of tangents is planned for implementation in 2024.
    Where can I get this toon shader?
    I would like to check here as well if possible.
     
  10. RabberDakk

    RabberDakk

    Joined:
    Feb 23, 2019
    Posts:
    14
    All ToonShaders that use the inverted outline method & baked normalmap should be applicable. UTS2 also has same feature. Rendering smooth outline by obtaining normal/tangent from vertices in runtime and transform it with baked normal
     
  11. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Thank you for the information.
    I will try a test based on this information later.
    Implementation of tangent recalculation will occur in early 2024.
     
    RabberDakk likes this.
  12. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    112
    Hello, I've got two questions about Magica Cloth 2:

    1. In regards of the new BoneSpring feature, can BoneSpring receive force from AddForce() too?

    2. My model's outfit has multiple layers. It's not a solid, regular manifold surface, so the generated proxy mesh is quite poor. I know I could use bones... but I wonder whether it's possible to supply my own premade proxy mesh? If I can generate the proxy mesh in 3D DCC it would be much easier. But I don't know how the proxy mesh binds to the actual mesh and deforms it. Could you provide me a bit of guidance on this issue?
     
  13. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.

    (1)
    Yes, BoneSpring is also affected by AddForce().
    Also receives external forces such as wind

    (2)
    The same request has been received from other end users.
    We are also considering using a self-made mesh as a proxy mesh.
    However, it is still undecided whether or not it will actually be developed.
    Binding of the render mesh from the proxy mesh will probably involve skinning using the weights calculated on the MagicaCloth side.
     
  14. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    First of all, I love the asset!
    Is there a way to make Bone Cloth look better? What could be causing the fabric to look distorted/buggy?
    upload_2024-1-13_13-15-37.png

    In Blender, the mesh looks good and normal, and when I initially import it into Unity without Cloth Simulation, it looks good too:
    upload_2024-1-13_13-16-4.png

    Edit:
    Also the hair is looking weird:
    upload_2024-1-13_13-24-33.png

    I created the following bone chains in Blender:
    upload_2024-1-13_13-26-3.png
     
    Last edited: Jan 13, 2024
  15. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    First of all, are the mesh vertex weights set correctly for the bones?
    In other words, try rotating the skirt's Transform in the editor without using MagicaCloth.
    Does the skirt transform smoothly at this time?

    Please check the following Quality settings to make sure the mesh skin weight is not limited to 2.
    This is the [Skin Weights] item at the bottom of this page.
    https://docs.unity3d.com/2022.3/Documentation/Manual/class-QualitySettings.html

    If you are limited to 2 bones, the weights set in Blender may not be working correctly.
    In that case, try changing to 4 bones.
     
  16. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Thank you very much for the response. In Unity, I set 'Skin Weights' to Unlimited in the Quality Settings, and the imported model has '4 Bones' set. Here is the hierarchy of one of the bone chains:

    upload_2024-1-14_19-43-42.png

    For example, when I rotate the lower parts (cloak2.5 or cloak2.6), the deformation looks good and normal:

    upload_2024-1-14_19-43-49.png

    But when I rotate higher up (cloak2.2), the deformation is very strong.

    upload_2024-1-14_19-43-56.png

    Here are two examples of how the weight painting looks in Blender:

    upload_2024-1-14_19-44-53.png upload_2024-1-14_19-44-57.png

    Is there something terribly wrong? Do you have any tips? Thank you in advance!
     
  17. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    If you get strange transformations like this just by rotating (cloak2.2), there may be an issue with the export from Blender or an issue with the import settings in Unity.
    Unfortunately, I'm not familiar with Blender, so I don't know the cause.
    I think it's best to post a question on the Graphics forum about this issue.
    https://forum.unity.com/forums/general-graphics.76/
     
    baumxyz likes this.
  18. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Hi @hoshos,
    sorry, that was a silly mistake on my part. The legs had a very slight weight impact on the cloth parts. I've cleaned up the weights and now everything is fine.
    I have one more question: I now have over 10 bone chains (each with 3-6 bones) with Bone Cloth components and 17 Magica colliders on my main character. Is that still acceptable performance-wise? This is the only character in the game using Magica, and the target platform is PC.
     
  19. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    I was relieved that the problem was resolved.
    About performance.
    If you are using BoneCloth on your PC, there is no problem at all.
    It's probably okay to display dozens of characters.
    However, please be aware that if you use a large amount of MeshCloth or enable self-collision, the load will be high.
    Please check the following documentation regarding performance:
    https://magicasoft.jp/en/mc2_performance/
     
  20. Claudia_Schulz

    Claudia_Schulz

    Joined:
    May 12, 2020
    Posts:
    8
    Hello! I have another question related to bone cloth setup. In our project, we wanted to make a clothes line sway in the wind using magica. The clothes line has a couple moving points and one fixed point at the start (root joint) and another fixed one at the end (end of the joint chain/hierarchy). So its a line bonecloth of fixed - move - move - move - fixed attributes.
    The starting fixed point is perfectly fixed, all following points sway in the way correctly - but the last point, even though marked to be fixed, is also swaying in the wind. I would have expected it to behave the same way as the first point, but it seems untethered.
    Do you think this could be a bug? if not, do you have an idea what we can do to fix this behavior on our end?

    joint hierarchy:
    line start
    - line point 1
    |-- line point 2
    |--- line point 3
    |---- line end
     
  21. TongOuO

    TongOuO

    Joined:
    Mar 20, 2022
    Posts:
    1
    Why choose to use ExNativeArray/ExSimpleNativeArray rather than unity nativeList,is there any performance improvement?
     
  22. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Unfortunately, such a structure with fixed attributes at the end cannot work with the current system.
    However, I think it would certainly be more convenient to have such a connection, so I would like to consider whether it can be supported in the future.
     
  23. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    ExNativeArray is a structure that stores arrays within arrays.
    Special memory management is performed internally, and multiple arrays can be added/removed within one NativeArray.
    MagicaCloth stores the data of multiple cloth components in one huge NativeArray.
    And everything is calculated in one go.
    This is a special data structure for that purpose.
    This is intended to improve performance.
    Please check the ExNativeArray source code for details.
     
  24. Claudia_Schulz

    Claudia_Schulz

    Joined:
    May 12, 2020
    Posts:
    8
    Ah! Thank you for clearing that up. We'd be very happy if this was implemented at some point in the future :)
     
  25. shma_unity

    shma_unity

    Joined:
    Jun 13, 2018
    Posts:
    118
    Hello, I've been using this Asset for a while and I'm really happy with it.

    However, I've now run into a problem. As I switched my clothing system to be loaded via prefab, I attached the MagicaCloth (with MeshCloth cloth type) component game object to the clothing SkinnedMeshRenderer, and saved those two as a Prefab.

    When I load the prefab at runtime, the vertex count of the ProxyMesh is completely off (from 1200 vertices to less than 100), making the cloth not work at all.

    However, when I deactivate the character I'm loading the cloth to, it loads the right amount of vertices but the simulation is still not correct (the moving vertices are falling apart).

    It almost seems like the Proxy mesh vertices is trying to match the selection data in its current animation which causes most vertices to miss the comparison.

    I'm not sure what to do to correctly load a prefab mesh with a meshCloth at runtime.


    EDIT: I have found a workaround. It does work when using PaintMaps, and loading the MagicaCloth game object inactive, then activating it after short wait in a coroutine (otherwise there is a "Reduction_MaxSideLengthZero" error, which I think is caused by the mesh vertices not being fully available on the same frame the object is loaded)
     
    Last edited: Jan 30, 2024
  26. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    It's probably an attitude issue during initialization.
    The character must be instantiated in the same pose it was in when edited.
    In other words, if the character is in A pose when you do vertex painting, it must be stored in A pose in the prefab and also in A pose when instantiated.
    If you don't do this, the vertex paint will shift.
    This is because the vertex paint data is stored in spatial coordinates, which will no longer match if the orientation changes.
     
    shma_unity likes this.
  27. shma_unity

    shma_unity

    Joined:
    Jun 13, 2018
    Posts:
    118
    I see. Thank you, that helps a lot.
     
  28. IgnasL

    IgnasL

    Joined:
    Feb 1, 2024
    Posts:
    3
    Hello, I seem to get these 2 errors when trying to add a Mesh Cloth to some of the outfits in my project. Could you please assist?

    error 1.png

    error 2.png
     
  29. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    I have investigated the error.
    The cause is that 254 or more vertices are connected to one vertex as a line.
    Currently, the number of lines that can be connected to one vertex is limited to 254 or less.
    This was an unexpected error and no error determination was made.
    Unfortunately, MagicaCloth cannot avoid this.

    Do you have any idea about this case?
    If possible, is it possible to reduce the number of vertices connected to one vertex to 254 or less?
     
  30. IgnasL

    IgnasL

    Joined:
    Feb 1, 2024
    Posts:
    3
    I've checked the meshes this happens to, and all of them have proper quad-based topology with triangulation, so no vertex should not be connected to more than 8 vertices. What I have noticed though is that these meshes have a large number of mesh islands. Is there a limitation on the number of mesh islands allowed?
     
  31. FirstMnM

    FirstMnM

    Joined:
    Aug 6, 2023
    Posts:
    6
    Hello, I see GPU Support on your roadmap. Do you know when that might be slated for implementation?
     
  32. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Thank you for the information.
    I'm not very familiar with modeling, so I honestly don't know if "mesh island" is the cause.
    I would like to actually look at the mesh data to solve this problem.
    Is it possible to provide this model?
    A prefab with MagicaCloth set is even better.

    If possible, could you please send me a DM?
    You can send a DM by clicking on the account and clicking "Start a Conversation".
     
  33. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Implementation on GPUs requires a lot of research and implementation, so unfortunately it is expected to be quite a while away.
    Probably not in 2024.
     
  34. rusturch1

    rusturch1

    Joined:
    Sep 3, 2014
    Posts:
    8
  35. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    rusturch1 likes this.
  36. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Update:2.5.0

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

    Added pre-build functionality
    This creates the cloth data generated at runtime in advance and turns it into an asset.
    Initialization load is reduced and simulations can be started immediately

    mc2_8_prebuild-5.jpg

    Please see the following documentation for details:
    https://magicasoft.jp/en/mc2_prebuild_setup/


    Release Note:
    Added: Added pre-build feature. By constructing cloth data at the time of editing and turning it into an asset, it is possible to immediately start simulation at runtime.
    Fixed: Fixed an issue where the OnComplete event was not called correctly after completing cloth data construction.
    Fixed: Fixed an issue where the reduction algorithm would cause an error in MeshCloth when there were a large number of vertices in a very narrow area of the mesh.

    How to Update
    Please follow the following steps to update the software as much as possible.
    (1)Backup your project
    (2)Delete the MagicaCloth2 folder from the Unity editor
    (3)Import the latest MagicaCloth2 from PackageManager
     
  37. suzuki-tai

    suzuki-tai

    Joined:
    Nov 8, 2021
    Posts:
    7
    Hi, MagicaCloth v2 is now one of my indispensable assets! Thank you very much!

    In the combination of skinned mesh and MeshCloth, only the vertices painted to the influence target do not follow when the joints to be influenced are scaled.

    For example, if I paint an object that follows Hips with skin weight 1 as the influence target in MeshCloth, and scale the Hips after execution, it is no longer affected by the scale.

    Therefore, I am puzzled when I change the height by uniform scaling after changing the costume on the character, only the part painted with MeshCloth remains the same.

    Is this a glitch?
     
  38. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Is this a scale change in the Transform or a deformation by the blendshape?
    By specification, it cannot be used in conjunction with blend shapes.
    However, it should be possible with the scale of Transform.
    However, the scale of Transform must be the same scale.
    Irregular XYZ scales are not available.
     
  39. suzuki-tai

    suzuki-tai

    Joined:
    Nov 8, 2021
    Posts:
    7
    Thank you for your response.

    Blendshapes are not used.Please check the Gif image attached.
    (Root joints are scaled)


    By the way, we are using 2022.3.18f1 for Unity and the latest version (2.5.0) for MagicaClothv2.
     
  40. Game-Dragon

    Game-Dragon

    Joined:
    Nov 16, 2012
    Posts:
    37
    Since blendshapes were brought up, are there any plans for blendshape support in the future? Or is that something that will never be compatible with MagicaCloth 2?
     
  41. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Thank you for the detailed video.
    Sorry, this scaling is not supported.
    The stretch distance of the cloth and the shape to be restored are determined and saved during initialization.
    Therefore, it cannot respond to changes in the waist scale in real time.

    Last time, I said that it supports scale, but this is the scale of the entire character.
    If you want to scale the entire character, it's fine.
     
  42. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Use with blend shapes is currently not planned.
    This is because it is technically difficult.
    MagicaCloth changes vertices with CPU.
    The blend shape then transforms the vertices using the GPU.
    Therefore, changes to MagicaCloth will be overwritten by the blendshape.

    The way to avoid this is to apply a cloth simulation after the blendshape on the GPU.
    However, MagicaCloth cannot use this method because calculations are performed on the CPU.
     
  43. oukaitou

    oukaitou

    Joined:
    Jan 10, 2014
    Posts:
    19
    Hello, is there any way to exclude some bones when using Bone Cloth?
     
  44. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
  45. oukaitou

    oukaitou

    Joined:
    Jan 10, 2014
    Posts:
    19
    Thanks for the reply.

    However I build the MagicaCloth at runtime (using BuildAndRun()), how can I exclude the bones when building the BoneCloth Mesh?
     
  46. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
  47. gradref

    gradref

    Joined:
    Jan 10, 2014
    Posts:
    4
    Is it possible to reconfigure the bones runtime?
    I have this code but it doesn't work
    Thank you

    Code (CSharp):
    1. private void Awake()
    2.     {
    3.         this.MagicaCloth.DisableAutoBuild();
    4.     }
    5.  
    6.     public void Initialize(Transform[] bones)
    7.     {
    8.         this.MagicaCloth.SerializeData.rootBones.Add(bones[0]);
    9.         ClothSerializeData2 sdata2 = this.MagicaCloth.GetSerializeData2();
    10.         sdata2.boneAttributeDict.Add(bones[0], VertexAttribute.Fixed);
    11.         for (int i = 1; i < bones.Length; i++)
    12.         {
    13.             sdata2.boneAttributeDict.Add(bones[i], VertexAttribute.Move);
    14.         }
    15.  
    16.         this.MagicaCloth.BuildAndRun();
    17.     }
     
  48. YuSa64

    YuSa64

    Joined:
    Jul 29, 2019
    Posts:
    3
    Hello

    when I’m using 2 mesh cloth on 1 mesh(for different parameters), mesh breaks when the animator works.
    I found it does not happen in 2.4.2, but only 2.5.0
    I used texture for painting.
     
  49. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Does resetting mean reusing the BoneCloth that has been started once?
    Due to specifications, it cannot be reused.
     
  50. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    I also experimented here.
    It is true that when two MeshCloths are used on one mesh, the mesh becomes strangely deformed.
    This does not occur in v2.4.2.
    Please wait for a while as we investigate the cause.