Search Unity

Import Cloth from Blender and prevent model go through

Discussion in 'Asset Importing & Exporting' started by Benmaster, Sep 22, 2019.

  1. Benmaster

    Benmaster

    Joined:
    Aug 11, 2016
    Posts:
    39
    Hi, Im new in the "modeling" part of the Unity and I have an issue that dont find how to fix.

    Im using mixamo animations and mixamo model for base model and animations, and is working correctly.
    Now I want to add some "gear" to my characters, but I have issues importing correctly.

    I make a "cloth" in the model Im using in unity using the cloth seewing feature of Blender 2.8, I left some space between the model and the cloth.
    Then when the cloth physics are in a nice position, I make it real pressing "apply" in the cloth modifier.
    Then in object mode, I select the cloth -> shift+press the bones, and then Control+P to create the vertex groups using the option "automatic Weights".

    The result is like this:


    My issues start now.. if I try to animate this model, for example moving the arm and forearm, the mesh deforms correctly, but in some points the character model go through the cloth.
    I try to add more space between the model and the cloth, or edit the weight paint, but I alwais face similar issues.

    I try to import into Unity and using an script I found in the forum (https://gist.github.com/TwoTenPvP/29684118fb37d1de946aee03307d80c1) add the cloth to the player prefab, to attach and see moving, and is working (more or less, I have issues with the back part of the cloth because appear not render correctly), but I face the same issues that have in blender, the blue model go trought the cloth in some movements of the arm...

    Im missing something with the cloth? Maybe I need to add some kind of "mask" or make the cloth more "fat" to prevent the player model travel trought it?
     
    Last edited: Sep 23, 2019
  2. Benmaster

    Benmaster

    Joined:
    Aug 11, 2016
    Posts:
    39
    After some research, I found how to do, my issue is the automatic weights, I want to make the cloth mesh deform with the body mesh, so I need to import the "mesh data" from the base model mesh:
    https://blender.stackexchange.com/questions/67625/how-to-rig-clothes

    After that I face other issue... only the front face of the cloth is renderer, like is a fake texture with no back face, this is because Blender only render the visible side of the polys, so I need to duplicate normals in the inverse direction, or in my case... https://www.reddit.com/r/blender/comments/20oxag/double_sided_textures/cg5fush/ "Solidify" the cloth, this duplicate the poligons, but add more realistic aspect to the cloth.

    Another thing that help to get a nice spaced cloth, is enable the "cloth collision" when you are creating it, with self and other elements of the scene.

    With this now works prefect, with no model intersections, like the cloth is a second skin in the model!
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    Hmm. That sounds good, but have you actually imported the model into Unity to make sure that it works the same?

    I'm interested because I've seen three other forum threads in the last few days of people struggling with the same challenge. I've had some trouble with this too, but I mostly get around it by just making my base model already clothed.
     
  4. Benmaster

    Benmaster

    Joined:
    Aug 11, 2016
    Posts:
    39
    Yes I test it in unity with the script I found.


    The mesh deform perfectly. (The lines and holes you see in the cloth is because I dont close the edges when I join in blender, was a fast test to see if works)

    Now I need to found/learn how to make 2 more things:

    1º Join in some way the Skinned Mesh render of every "cloth" in the model, to improve performance, if I need to add the armature per cloth, and the skined mesh render, this a pit of performance...

    2º This.. i dont know if is possible, I want to have multiple models, not only this "blue guy", but im not sure if I can "fit" the clothes in other model using the same bones but different model, maybe exists a way to make the work done in Blender when I copy the mesh data but from Unity in some way, or deform the cloth from one model to another and keep the deformation values to apply automaticly dont know... what I dont want is have 4-5 different characters, and need to make the clothes 4-5 times to, to fit every model. (Imagene 5 characters with 100 pieces, i need to do 500 elements...) Maybe someone have some idea.
     
  5. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    Interesting. Does the cloth simulation in Blender have it's own skeleton? Does it import as bone animations in Unity (i.e. separate bones than the underlying character)?
     
  6. Benmaster

    Benmaster

    Joined:
    Aug 11, 2016
    Posts:
    39
    One of the issues I see, to make the cloth work correctly, is need to import the bones of the cloth, if you see the lateral object tree, the "Armature" contain the Blender bone structure, is a copy from the model structure. I try to set in the imported fbx from Blender, the Avatar from the full_char armature, but dont works, for some reason when I remove the armature from the cloth, the cloth change the position and rotation and the script I have that make the cloth work, stop to work because dont found the cloth bones.
    Maybe exists a better way to do this, but im not sure how "link" the cloth with the full_char armature to improve performance.