Search Unity

Exporting meshes with shape keys from Blender

Discussion in 'Asset Importing & Exporting' started by BrainMelter, Apr 20, 2014.

  1. BrainMelter

    BrainMelter

    Joined:
    Nov 20, 2012
    Posts:
    572
    I'm trying to export a mesh containing shape keys from Blender into Unity. I'm able to get this to work correctly with simple test meshes. However, when my mesh has modifiers attached (mirror modifier, subsurface modifier etc), then things get more difficult.

    When modifiers are attached, the shape keys won't show up in the exported mesh. If I try to apply the modifiers before exporting, I get this fun error:
    "modifier cannot be applied to a mesh with shape keys"

    I've gone through several Blender threads trying to find a solution for this, but I'm still having trouble with it. This seems to be a problem mostly related to export. If you're just doing a render inside Blender, you usually don't need to apply those modifiers, so it's really not an issue.

    Anyone else able to get this working ok?
     
  2. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    The exporter applies all the modifiers before exporting, so that's why it won't work. You'll need to apply the modifiers before creating the shape keys I think, then you should be able to export ok.

    One thing you *might* be able to do is duplicate the object, remove the shape keys from the duplicate, apply the modifiers, then copy the shape keys from the original to the duplicate and export that.
     
  3. BrainMelter

    BrainMelter

    Joined:
    Nov 20, 2012
    Posts:
    572
    I did end up trying that. And it does work, but it's a rather tedious process, at least with the way I'm doing it.

    And you have to do it every time you export ...
     
  4. oneseedfruit

    oneseedfruit

    Joined:
    Sep 30, 2013
    Posts:
    1
    I am sorry, but may I know how do you copy the shape keys from the original to the duplicate? After applying the modifiers to the duplicate, it doesn't have the same number of vertices as the original.
     
  5. WOOYU

    WOOYU

    Joined:
    Jul 7, 2014
    Posts:
    2
  6. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    I followed that thread and found someone did the obvious, which is to automate the "applying subsurf without losing shape keys by copying shape keys" process in Blender python script. I just confirmed it worked nicely even two years later in 2018.3. https://github.com/przemir/ApplyModifierForObjectWithShapeKeys
     
    Ziqie likes this.