Search Unity

Combined meshes with blendshapes (morph targets) lose the blendshape data

Discussion in 'Animation' started by Centripetal, Jun 30, 2015.

  1. Centripetal

    Centripetal

    Joined:
    May 31, 2013
    Posts:
    96
    No Unity3D API function that I'm aware of will include the blendshape data when combining two meshes. Farther, the programmer cannot create blendshape groups and cannot access the blendshape vertex data in a mesh object, so there is no way to create code to combine the meshes manually with the blendshapes.

    Does anyone know if Unity Technologies is going to expose the blendshape data and/or update CombineSkinnedMesh to include the blendshapes in the merge?
     
  2. dphe

    dphe

    Joined:
    May 10, 2015
    Posts:
    1
    i meet the same case. seek for help 2...
     
  3. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Not to be contrary - but we aren't even able to do this in 3D animation packages as far as I know.
    When combining meshes - vertex data is changed, changing the information all morph/blend shape algorithms depend on to work correctly.

    What solution is being solved that requires separate meshes to be combined? I'm guessing run-time character customization sets.
     
  4. Centripetal

    Centripetal

    Joined:
    May 31, 2013
    Posts:
    96
    I think your misunderstand how the Mesh.CombinedMeshes works. It does not preform a Boolean operation on the mesh. It simply merges all the vertex data from several meshes (usually separate game objects) into one GameObject. So it should be able to copy the blend shape data into the same GameObject as well. While it does copy the vertex data from the blend shapes, it does NOT copy the blend shape groupings (which vertex point belongs to which blend shape). You cannot access the grouping data for blend shapes because they're not public members of the class and you cannot write the blend shape group data to the new combined GameObject. So you cannot write code to manually copy it either.
     
  5. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I understand mesh.combine does not perform a boolean. I also understand how morph targets in 3D work.
    In 3D software (choose any) attaching multiple mesh objects together (not boolean) changes the vertex count and vertex order and destroys any saved morph/blend shape data. I expect Unity is no different although I am open to learning about how blendshapes are handled in Unity if it is somehow different.
    I'm unfamiliar with the difference between blend shape data and blend shape groupings (the description you gave sounds like the same thing) - even with access to this grouping data - after a mesh.combine operation the blend shapes would not work simply because the vertex count has changed and blend shapes rely on vertex count and vertex order to work properly.

    Having animated with morph targets / blend shapes for years, the only successful morph and mesh combine solution - is a non destructive process which retains the mesh vertex data so the blend shape works as expected and the mesh combine is performed after the morph function is performed. So vertex data isn't altered before the blend shape happens.
     
  6. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    This took me forever to figure out, so I'm posting it a few places that other people might wind up looking for the same thing. I made a video that shows how to get blend shapes merged properly using Mesh Baker Pro, which is the only way I know to do it at this time.



    Video description:

    Using Mesh Baker Pro, here's a tutorial on how to blend multiple skinned mesh renderers so that they use just a single rig/skeleton and contain blend shapes that your animations can actually find. This is somewhat of a followup to my previous video, based on more recent findings of best practices.

    Note that this is a complete walkthrough of a number of different steps, so it's helpful even if you don't care about blend shapes. In this case the blend shapes were from morphs in iClone 7, but blend shapes from other programs such as Poser, DAZ, Maya, Mixamo, etc, would also all work essentially the same way.

    This is also setting up my character so that I can do hair cloth animation, or use the VertExmotion tool, without baking that skinned mesh into the main body, which would be undesirable.

    This does require one small tweak to one line of code in Mesh Baker Pro, but in future versions may not. It's an innocuous little bit of code, and I show you how to make that one change near the end of the video; otherwise the blendshapes are there, but inaccessible to animations.
     
    manutoo likes this.
  7. kaaJ

    kaaJ

    Joined:
    Mar 21, 2007
    Posts:
    150
    Since I've come across this thread finding for a solution (it's the top result for google), here's how I did it in code for future reference.
    Create a mesh for each blendpose, calculate the difference between the normal mesh and the blended one(s) (in vertices, normals, tangents), and with that data, create new blendshapes for the merged model using that data. (with AddBlendShapeFrame)...
     
    x4000 likes this.
  8. stf51

    stf51

    Joined:
    Mar 25, 2021
    Posts:
    8
    hello kaaj, as i am new to unity could you make an example of your method ? thx