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. gradref

    gradref

    Joined:
    Jan 10, 2014
    Posts:
    4
    I have a magica cloth disabled until the mesh and the bones are generated by code.
    After that I would like to feed magicacloth with the bones generated and enable it.
    Or, if possible, reset or set the position of the bones manually
    In the guide it shows that it creates a magica component from scratch, but if possible it would be more convenient to use the one in the scene
     
  2. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    After investigating the problem, it seems that the vertex weight operation performed in v2.5.0 was affected.
    This issue has already been resolved and will be updated at a later date as the next v2.5.1.
    I think it's probably about two weeks.
    Please wait for a while until then.

    If you want to test the modified version immediately, please send me a DM.
    You can send a DM from "Start a Conversation" on my account.
     
  3. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Does it mean that the MagicaCloth component is attached to the character from the beginning?
    Since MagicaCloth's initialization is performed in Awake(), it is likely that the initialization was performed before you disabled the component.
    In this case, set the GameObject to which the character's MagicaCloth component is attached to Disable in advance.
    If GameObject is Disabled, Awake() will not be executed and will not be initialized.
    Then, after replacing the bones, make the GameObject Active.
     
  4. Zaba_Dev

    Zaba_Dev

    Joined:
    Feb 27, 2018
    Posts:
    18
    Is there any plans to support sub meshes with paint maps?
    I seen you mention previously about the idea of using the vertex colors of the mesh. I think this would be a great idea, would that allow for sub meshes?
     
  5. gradref

    gradref

    Joined:
    Jan 10, 2014
    Posts:
    4
    Yes, unfortunately when I enable magicacloth it only finds the root bone ignoring the whole hierarchy.
    Am I forgetting something?
    By debugging the bones are all set correctly in the boneAttributeDict, but magicacloth does not seem to use this dictionary.
    If I set the bones from editor and not from code everything works correctly, but obviously they don't have the default position that I want
    Code (CSharp):
    1. this.MagicaCloth.SerializeData.rootBones.Add(bones[0]);
    2.         ClothSerializeData2 sdata2 = this.MagicaCloth.GetSerializeData2();
    3.         sdata2.boneAttributeDict.Add(bones[0], VertexAttribute.Fixed);
    4.         for (int i = 1; i < bones.Length; i++)
    5.         {
    6.             sdata2.boneAttributeDict.Add(bones[i], VertexAttribute.Move);
    7.         }
    8.         this.MagicaCloth.gameObject.SetActive(true);
    9.         this.MagicaCloth.enabled = true;
     
  6. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Submesh support using paint maps is not planned as it is a bit complicated.
    However, painting using vertex colors is relatively easy, so I am considering implementing it.
    If it is a vertex color, it can also be used for submeshes.
     
  7. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    It looks correct when I look at the code.
    I may have overlooked something, but I can't tell without looking at the entire code.
    I think it's probably an initialization issue.
    Can you provide a project or package where I can see the problem?
    Please DM me if possible.
    You can send a DM from "Start a Conversation" in your account.
     
  8. snipercat9

    snipercat9

    Joined:
    Feb 19, 2024
    Posts:
    3
    嘿,我有一个非常小众的问题,我在我的 macbook 上没有遇到统一问题,它工作得很好,但是当我将它编译到 Apple Vision Pro 时,所有布料都无法更新/位置错误等,我读过十几页的对话,没有人提到这一点,我意识到这个新设备可能有很多自己的问题,但我也想快点问一下,你对这个错误有什么经验吗?

    UPDATE: This problem only occurs with mesh cloth, I tested bone cloth without this problem
     
    Last edited: Feb 24, 2024
  9. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Thank you for your report.
    It has been confirmed that MagicaCloth2 works with Quest2.
    With the same VR rendering, I don't know at the moment why it doesn't work in Vision Pro.
    Unfortunately, I don't own Vision Pro because it's expensive.
    Maybe you're doing some special rendering.

    Sorry, I don't know how to resolve this at this time.
    We will continue to collect information on this issue.
     
  10. oukaitou

    oukaitou

    Joined:
    Jan 10, 2014
    Posts:
    19
    If I understand correctly, it can only set the bone to Invalid, but the invalid bone is still included in the built mesh as a mesh vertex.

    For example, there are 5 bones, D and E are the children of C:
    A
    |-B
    --|-C
    ----|-D
    ----|-E

    I want to build a mesh by using A,B,C,D, exclude E.

    By the way, E has the same position with D. If I add A as the root bone and build the mesh, I got the following error at runtime. Although I'm not sure if it's because of the same position.

    QQ20240225-163620@2x.png
     
  11. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    When I performed the same experiment, I was indeed unable to properly assign attributes to DE.
    The reason is that DE is in exactly the same position.
    Internally, attributes are tied to spatial coordinates, so two attributes cannot be set at the same location.
    To solve this problem, please shift the DE position even slightly.
     
  12. hoshos

    hoshos

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

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


    Release Note:
    Added: Some parameters such as gravity can now be controlled from animation.
    mc2_9_animation_property-2.jpg
    Fixed: Fixed an issue where drawing would become incorrect when using two or more MeshCloths in one renderer. This is an enbug in v2.5.0.
    Fixed: Fixed an issue where the inspector might not refresh when the contents of SourceRenderers and RootBones changed.
    Fixed: Fixed an issue where the mesh would be broken due to precision issues with floating point arithmetic when calculating TriangleBend.
    Fixed: The format of PreBuild has been changed. Previous PreBuild data will no longer be available.


    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
     
    gradref likes this.
  13. gradref

    gradref

    Joined:
    Jan 10, 2014
    Posts:
    4
    I solved the problem .
    First, I installed the new version, then i don't know for what reason but it seems that the instance in scene I had of MagicaCloth was having problems.
    I created a new instance with the same parameters and now everything works correctly.
    One last question, I read that on the new update there is some news regarding the gravity.
    What is the correct way to change it continuously runtime?
    Thank you for support!
     
    Last edited: Feb 26, 2024
  14. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    I was relieved that the problem was resolved.
    MagicaCloth allows most parameters to be changed during execution.
    Please refer to the following document for information on how to do this.
    https://magicasoft.jp/en/mc2_runtimechanges/
     
  15. oukaitou

    oukaitou

    Joined:
    Jan 10, 2014
    Posts:
    19
    Thank you for the answer.

    Finally I solved the problem by modifying RenderSetupData class. The excluded bones will not be added into
    transformList if the bone's gameobject is inactive.

    I would appreciate it if there was a proper way to exclude bones when building the mesh.

    Thanks again.
     
  16. IgnasL

    IgnasL

    Joined:
    Feb 1, 2024
    Posts:
    3
    Hello gain. Would it be possible to add support for adding mesh colliders (a theoretical "MagicaMeshCollider" component) to the collider list? For more complicated setups mesh colliders would add much needed accuracy when it comes to body collision.
     
  17. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    I was relieved that the problem was resolved.
    The correct way is to use boneAttributeDict, but it won't work if the DE is in exactly the same position as in this case.
    I will try to see if I can solve this problem in the future.
    Thank you.
     
  18. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Mesh collider is technically possible.
    It's already on the roadmap.
    However, it is still a low priority because it requires a lot of experimentation and implementation time.
    However, I would like to implement it in the future.
     
  19. wannaplaymore

    wannaplaymore

    Joined:
    Jan 4, 2019
    Posts:
    3
    I noticed an issue when porting my app to VisionOS. For any skinned mesh that has Magica Cloth applied that does not allow all vertices of the mesh to move, the remaining vertices ( Fixed or Invalid) are locked in place in the 3d world while the rest of the mesh moves as intended. For example, lets say I have a model that can move freely using non-kinematic rigidbodies connected by configurable joints has a skirt with MagicaCloth applied. One would normally set some of the vertices as fixed so the skirt doesn't fall off. If I do this, and the model moves around, those fixed parts of the skirt stay behind, locked in virtual space stretching from the rest of the skirt that stays with the model. Does anyone have thoughts on how to resolve this? I have had great experience with my app running on MacOS and Windows. This is only an issue when running on the Apple Vision Pro on VisionOS. In another example when I applied MagicaCloth to an entire Daz3d model's body, with all rigid bodies set to kinematic, MagicaCloth performs as expected when some vertices are fixed. It is only when using non-kinematic I see issues.
     
  20. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Thank you for your report.
    It has been confirmed that MagicaCloth2 works with Quest2/3.
    With the same VR rendering, I don't know at the moment why it doesn't work in Vision Pro.
    Unfortunately, I don't own Vision Pro because it's expensive.
    You're probably doing some pretty special rendering.

    The currently known issues are:
    - Does not work in Immersive mode
    - Only MeshCloth does not work, BoneCloth works.

    Sorry, I don't know how to resolve this at this time.
    We will continue to collect information on this issue.
     
    Last edited: Mar 2, 2024
  21. snipercat9

    snipercat9

    Joined:
    Feb 19, 2024
    Posts:
    3
    I took a screenshot and he looks pretty crazy XD I likewise found some issues with the live face, so this could be a problem with the vision os themselves, if you have experience with it you can deal with it, I don't really want to hold up your normal progress!

    Also there is no need to buy vision pro, there is a simulator inside xcode that can fully simulate vision pro


     
  22. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Oh, this is so helpful!
    If we can emulate it, we may be able to find out the cause.
    It might be an issue with the scale value since the mesh is not completely broken.
     
  23. hoshos

    hoshos

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

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

    This is an urgent bug fix.
    Fixed an issue in v2.5.1 where BoneWeight was written to the mesh every frame when using MeshCloth.
    This is an enbug in v2.5.1 and will significantly impact performance.
    We apologize for the inconvenience, but if you are using v2.5.1, please update to v2.5.2 as soon as possible.


    Release Note:
    Fixed: Fixed an issue where BoneWeights were written to the mesh every frame when using MeshCloth. This is an enbug in v2.5.1.
    Please update as soon as possible as this issue will significantly impact performance.
    Fixed: Fixed an issue where the BoneWeights of the mesh would not return correctly if two or more MeshCloths were used in one renderer and one was stopped.

    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
     
  24. Nupixo

    Nupixo

    Joined:
    Jan 21, 2016
    Posts:
    8
    Hi, in the past I used Magica Cloth and made use of the "MagicaVirtualDeformer" + "MagicaMeshSpring" components.

    Now that I have Magica Cloth 2, I am unable to replicate those components. Can you tell me how to do mesh spring with MC2?

    Thanks!
     
  25. phyzix101

    phyzix101

    Joined:
    Mar 30, 2020
    Posts:
    10
    Hello Hoshos-san!
    I'm just starting to use MC2 and when I hit play the cloth piece falls. I'm sure I missed something but I couldn't find anything in the document website or this thread.
    upload_2024-3-8_23-22-45.png upload_2024-3-8_23-23-12.png
    Attached is the image of vertex paints for the piece and the hierarchy
    This is Unity 2921.3.33f1 URP
    If you have any advise for settings for this type of heavier "cloth" armour I would appreciate that as well!
     
  26. phyzix101

    phyzix101

    Joined:
    Mar 30, 2020
    Posts:
    10
    I tried to increase the level of fixed vertices and it didn't help
    upload_2024-3-8_23-29-53.png
    For performance I will switch to BoneCloth is this is only a meshcloth issue
     
  27. phyzix101

    phyzix101

    Joined:
    Mar 30, 2020
    Posts:
    10
    It works with the bonecloth, brought the apron in as a separate FBX but in the same place in the hierarchy
    upload_2024-3-9_1-16-54.png
     
  28. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Unfortunately Ver2 does not have MeshSpring yet.
    This feature is on our roadmap and will be implemented in the future.
    However, it is expected that this will happen in the second half of 2024 at the earliest.
     
  29. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    As far as I can see from the image, there doesn't seem to be any problem.
    I don't understand why the cloth keeps falling off.
    It may be that the connections between the vertices are not well established.
    Try increasing "Simple Distance" in ReductionSettings to make the proxy mesh even simpler.
    https://magicasoft.jp/en/mc2_meshclothstartguide/#Reduction
     
  30. Nupixo

    Nupixo

    Joined:
    Jan 21, 2016
    Posts:
    8
    Wow, that's unfortunate...

    Can you tell me if it's possible to have both Magica Cloth 1 and 2 in the same project?
     
  31. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Yes, Ver1 and Ver2 can be used together.
    However, performance will be poor because two different cloth simulation systems are running.
    Please be careful about this.

    Also, I have a question: why do you need MeshSpring?
    Is it a realistic chest movement?
     
  32. Nupixo

    Nupixo

    Joined:
    Jan 21, 2016
    Posts:
    8
    Actually, it is for belly movement ;-)
     
  33. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    I see, I understand.
    It is not that difficult to port Ver1 MeshSpring as is.
    However, we are thinking of adding soft body functions in Ver2.
    As a result, I haven't been able to get much work done on it.
    I'm sorry, but it looks like it will take some time to implement it in Ver2.
     
    Nupixo likes this.
  34. DMANUFACTURE

    DMANUFACTURE

    Joined:
    Jun 4, 2021
    Posts:
    2
    Could you enlighten me as to why the asset was built to leverage the CPU instead of the GPU?
    Also just wanted to say, I had a chance to try this asset out at a friend's place and I'm blown away by how simple it is to setup. How simple it is to optimize and configure how the physics work.
    It's ridiculous how quick and intuitive it is to setup, you should be extremely proud for making an incredible asset like this.
    It works incredibly with Mesh cloth, and works even better than Dynamic Bone with its Bone cloth option.
     
  35. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Thank you for your high evaluation!

    There are several reasons for using the CPU instead of the GPU.

    Computing on the GPU requires a special shader to synthesize the results.
    This is a barrier when end users utilize their own shaders.
    Especially in Unity, BuiltIn/URP/HDRP and shaders have become very complex.
    You cannot operate Unity's Transform on GPU.
    In other words, BoneCloth cannot be realized.

    That said, GPUs can run simulations over 10 times faster than CPUs.
    Therefore, I would like to perform simulations on GPU if possible.
    If the above problem can be solved in the future, I would like to create a GPU version.
     
  36. AetherMFP

    AetherMFP

    Joined:
    Feb 11, 2022
    Posts:
    39
  37. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    Thank you for your report!
    I just looked in the history and couldn't find where this problem was fixed.
    It seems that this was fixed in an update somewhere.
    Please let us know if it happens again.
     
  38. hoshos

    hoshos

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

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

    Added anchor functionality. This corresponds to what is called a moving floor.
    Allows you to disable the inertia of the specified object.



    See documentation for details
    https://magicasoft.jp/en/mc2_magicacloth_inertia/

    Also, the problem of simulation being disrupted due to lag or processing failure has been resolved.
    Other minor adjustments have been made, such as changing the initialization position from Awake() to Start().


    Release Note:
    Added: Added anchor function. This nullifies the inertia of certain objects. Can be used for moving floors and vehicles. You can also adjust the strength of the anchor.
    Fixed: Fixed an issue where the simulation would go wild when lag occurred due to load.
    Fixed: Fixed an issue where the effect of moving wind was weakened during slow playback.
    Fixed: Fixed an issue where the simulation would be distorted when the character moved during slow playback.
    Improvement: Changed the initialization timing of MagicaCloth from Awake() to Start(). This makes it easier to process the data before initialization. This setting can also be changed back to Awake() using MagicaSettings and API.
    Improvement: Increased the execution order of MagicaCloth component (+5). MagicaCloth components run after regular MonoBehaviour components.
    Improvement: Changed the execution order of MagicaSettings component to (-50). MagicaSettings components are executed before regular MonoBehaviour components.


    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
     
    hopeful likes this.
  39. Enkianthus

    Enkianthus

    Joined:
    Mar 28, 2022
    Posts:
    20
    I tried using Root Motion along with Magica Cloth 2, but encountered some issues. I'm using Easy Controller 2 from the Asset Store, where the capsule moves based on the character's Root motion clip. However, when the character moves, especially with large animation movements, my cloth starts to jitter. I believe this is related to inertia. The jitter disappears when I set World inertia to zero or when I set the Anchor to the capsule body.
     
  40. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    I would like to know how this is arranged in the hierarchy.
    Can I see an image of the Hierarchy view of how the MagicaCloth components and capsules are arranged?
     
  41. Enkianthus

    Enkianthus

    Joined:
    Mar 28, 2022
    Posts:
    20


    Player Character
    ↳Moon
    .. .↳MC2
    Player Character is the Capscule,Moon is an Avatar,MC2 is Magica Cloth2
     
  42. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Thank you for the image.
    There are three things to check.

    (1)
    Is it PlayerCharacter or Moon1 that has Animator attached?
    If Animator is attached to PlayerCharacter, try placing MC2 directly under PlayerCharacter.

    (2)
    Is Animator working with UnityPhysics?
    In other words, is Animator's UpdateMode set to AnimatePhysics?
    In that case, you will also need to change MagicaCloth's UpdateMode to UnityPhysics.
    https://magicasoft.jp/en/mc2_magicacloth_updatemode/

    (3)
    Please tell me the URL of EasyController2's assets.
    I searched for EasyController2 in the asset store but couldn't find it.
    I would like to know what kind of asset this is.

    (4)
    Please be sure to use the latest version of MagicaCloth.
    The current latest version is v2.6.1.
    If it is old, please update it.
     
  43. hoshos

    hoshos

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

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

    This is an emergency response to a critical bug found in the culling function.
    We apologize for any inconvenience caused.


    Release Note:
    Fixed: When using the culling function with Animator's CullMode set to "Cull Update Transforms", we fixed an issue where the simulation would not restart once it was removed from the camera.


    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
     
  44. Enkianthus

    Enkianthus

    Joined:
    Mar 28, 2022
    Posts:
    20
    Sorry, I said the name wrong. It's called Easy Character Movement 2.
    https://assetstore.unity.com/packages/tools/physics/easy-character-movement-2-193614

    I recorded a video to give you a clearer understanding.


    The Animator is attached to the Moon because it's the character's FBX model. There's also one attached to the PlayerCharacter, but that's used for scene interaction and is unrelated to this issue.

    The problem persists regardless of whether I have UnityPhysics checked.

    I just discovered that if I change the Animator's UpdateMode to Fixed and MagicaCloth's update mode to Normal, the issue is resolved. However, using Normal for UpdateMode would be more reasonable for me because I use a lot of IK and other animation-related components.
     
  45. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Thank you for the video.
    There seems to be no problem with the settings.
    I looked into the EasyCharacterMovement2 manual and tried to think of the cause, but I couldn't figure it out.
    Maybe EasyCharacterMovement2 is performing some special movement interpolation.
    There have been similar cases in the past.
    I would like to see the contents of this project. Is it possible to provide it?
     
  46. DMANUFACTURE

    DMANUFACTURE

    Joined:
    Jun 4, 2021
    Posts:
    2
    Thanks for that reply. Good luck with future versions. You're only going to make this amazing asset even more incredible.
     
    hoshos likes this.
  47. Enkianthus

    Enkianthus

    Joined:
    Mar 28, 2022
    Posts:
    20


    I use Unity6 beta URP ,old input system
     
    Last edited: Apr 2, 2024
  48. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Thank you for the file.
    I was able to download it successfully.
    Also, I sent you a DM because I have a very important message.
    Please check your DM.
     
    Last edited: Apr 1, 2024
  49. hoshos

    hoshos

    Joined:
    Mar 7, 2015
    Posts:
    942
    Hello.
    I've just sent you a new prototype version that fixes the issue to your DM.
    Could you please try replacing with this version and see if the issue is resolved?
     
  50. nemuyi

    nemuyi

    Joined:
    Mar 20, 2024
    Posts:
    1
    Any progress on Vision Pro?