[RELEASED] Magica Cloth

hi first time i use magika cloth in unity 2020.3 and i have lot of probleme see :

Hello.
Probably because the required packages are not installed.
Try installing the [Burst] and [Jobs] packages according to the following installation guide.
If the version is old, please try to update it.

https://magicasoft.jp/en/magica-cloth-install-2/

thx for answer now i have another probleme whene i load skirt preset i cant click on the button create to create data the button is not activated

Hello.
Perhaps the vertex selection remains open as shown in the image.
6987839--825044--start-11.jpg
Try pressing [End] or [Cancel] to finish the vertex selection.

If not for the above reasons, is there any error message in the Inspector?

Hello.
I noticed that magica is taking cca 5ms in my build so i tried to change update mode to delay unscaled time but then - for some reason - it jump up to cca 15ms and this is how it looks in profiler. Is this normal behavior or do you think there can be bug somewhere?

Hello. Please forgive me for not being able to answer in detail because I am moving now. First, burst from the menu Can you check if the compiler is enabled? You can find the item somewhere in the menu.

Heya. Yes Burst should be enabled.
For additional info, i have character with 2x MagicaMeshCloth, MagicaBoneCloth and MagicaBoneSpring (different part of body/clothing). I noticed that sometimes magica is low as 2ms and sometimes it jumps up to 10ms (difference is always only after editor/gameMode change. Not during play itself).
Also, good luck with moving! :smile:
7002107--827609--upload_2021-4-3_1-22-10.png

Hello @hoshos , I’m really enjoying Magica cloth and finding it very good for my project. I’m having a bit of issue with the ReplaceComponentBone() method. Is there a script example of how to use this? I’m unable to use GetComponent() to access the RenderMeshDeformer and am unsure how this is done.

Specifically I’m unsure how to access the original bone data as outlined in CoreComponent – Magica Soft

I tried using the MagicaAvatar system but it wasn’t really working well with my current swappable system. Thank you.

Hello.
Thank you, you have successfully moved.

It may have taken 10ms to initialize the game when it started.
If this problem becomes noticeable, please contact us.

It is running in safe mode when running in Burst's editor. It will also be slower as we are also collecting profilers. By actually building it, the speed will increase several times. So it's currently 2ms in the editor, but it should be much faster at build time. If you are still concerned about performance, there is a "delayed execution" mode. https://magicasoft.jp/en/magica-cloth-physics-manager-2/ This mode significantly improves performance because the simulation is done during rendering. However, clipping may be noticeable because the result is delayed by one frame. Magica Cloth covers this issue with "Future Prediction".

Hello.
Sorry for the late reply due to the move.
First of all, unfortunately there is no sample scene for ReplaceComponentBone ().
Currently only the following documents are available.
https://magicasoft.jp/en/corecomponent-2/

All Magica Cloth components have class names with Magica as follows.
MagicaRendereDeformer
MagicaVirtualDeformer
MagicaBoneCloth
MagicaMeshCloth
MagicaBoneSpring
MagicaMeshSpring

Therefore, you can get it by doing GetComponent () with the above class name.
Also, all Magica components inherit from the CoreComponent class.
Therefore, it is also possible to get all with GetComponentsInChildren () etc. and replaceComponentBone ().

Does this solve the problem?

1 Like

Thank you, that did help. At first I was having trouble with the fabric stretching uncontrollably but found out it was because my attached object wasn’t sharing the same position as the source. Below is my method, it seems to work but if there’s a cleaner solution I’m open to it.

I’m iterating through all the bones in source and target skinned meshes and adding them to the dictionary. I had to make VirtualMeshDeformrer.cs/bonelist public for this.

            MagicaVirtualDeformer[] vDeformer = sourceRenderer.GetComponentsInChildren<MagicaVirtualDeformer>();

            if (vDeformer != null)
                for (int v = 0; v < vDeformer.Length; v++)
                {
                    Dictionary<Transform, Transform> boneReplaceDict = new Dictionary<Transform, Transform>();
                    for (int vb = 0; vb < vDeformer[v].Deformer.boneList.Count; vb++)
                        for (int sb = 0; sb < sourceRenderer.bones.Length; sb++)
                            if (sourceRenderer.bones[sb].name == vDeformer[v].Deformer.boneList[vb].name)
                                boneReplaceDict.Add(vDeformer[v].Deformer.boneList[vb], sourceRenderer.bones[sb]);

                    vDeformer[v].ReplaceComponentBone(boneReplaceDict);
                }

@hoshos heya.
Im aware that editor/game can have different results in profiling, yet my issues is presented in both. In editor and even in game, it takes cca 5ms just for magica (i can show you different screens from profiling dev. build but you will see similar thing to what i posted).
Also you mentioned i should try delayed execution but thats what im talking about. I have 5ms with ā€œone per frameā€ but when i use delayed execution, it jumps up to 15ms, as is visible on screen i posted here.
I tried few tests because i was wondering if i can speed it up on my side and i noticed that there is no difference between activated/deactivated magica component. Its still calculating even if its disabled (im not talking about manager). I tried to look at different Jobs in magica and i was not able to find anything related to component enable or checking if blend values (distance disable) are bellow certain value.
When i added simple blend ā€œifsā€ to all magica jobs that was visible in profiler, they drop from for example 0.75ms to just 0.13ms. Is it something missing in jobs?

Hello.
I think there is no problem with the source code.
As you pointed out, is currently set to private.
Therefore, I would like to add an API that can get the list of Transforms referenced by each component.
It will probably be available in the next version, so you will be able to use that API in the future.

1 Like

I’m sorry, I was a little misunderstood.
I now understand that it is a performance issue during deferred execution.
Could you please give me the following information to understand the problem?

(1) MagicaPhysicsManager settings
What is the manager’s ā€œUpdate Per Seccondā€ set to?

(2) Cloth Monitor values
Could you give me a screenshot of the running Cloth Monitor?
This is an example of an image.
7016341--830317--clothmonitor-1.jpg

Heya, i hope i have it everything visible on screens. I created two screes with ā€œOnce per frameā€ and second with ā€œDelay unscaled timeā€ :smile:

Just to show as much data as possible, i also build game and make screenshot of debugger. You can see, there is still cca 5ms take from magica

Thank you for the detailed information.
I tried to analyze your profiler.

Looking at the number of parties and colliders and the number of cores in your CPU, I’m sorry, but it’s a simple performance limit.
[Once] is calculated once per frame.
In [Unscale], the calculation is performed every 1 / 90s regardless of the FPS, so the calculation may be performed multiple times in one frame.
For this reason, Unscale is more expensive.
Also, if you use a lot of MeshCloth, the process of skinning the Virtual Deformer and the process of writing the calculation result to the Renderer will occur.
These two loads are quite heavy and consume about 1/3 of the total time.

For now, the only way to avoid it is to turn off the components of characters that are far from the screen or the camera.
In this case, the [Distance Disable] feature may be useful.
https://magicasoft.jp/en/distance-disable-2/
Also, if the FPS of the game is stable, Once is fine.
In this case, the load is constant for 5ms.

Hello.
This is something i also already mentioned before.
Distance disable is already set to 20m but there was almost no increase so i tried disable all components from script to see if i can realtime disable/enable magica but it seems that its not working (You can see i talked about components about it in my post #712). Can you please check that post and confirm or decline that issue i mentioned there? maybe there is just missing checks in Jobs. I will gladly disable all components if character will be far away but currently its not possible (it is but there is no difference in performance)

Hello.
In response to your indication, we performed the performance test of [Distance Disable] and the enable switching of the component again.
As a result, as you pointed out, it turned out that the calculation load does not decrease much even if the active components decrease.
It is actually decreasing, but the rate seems to be low.
This becomes more noticeable as the number of components increases.
(If there are hundreds of components)

I know the cause, but I can’t do it right away because the improvement requires a major modification of the calculation process.
However, I think this issue should be improved, so I would like to prioritize performance optimization and incorporate it into the roadmap.
I’m sorry, but the improvement will probably take months.

Thank you for your suggestions.

1 Like

It looks nice but there are a lot of parameters to set.
I can not achieve good results until after many trials.
It would be nice to have more types of presets.