Search code examples
animationmayaunreal-engine4fbx

Crazy values on morph targets in unreal engine 4


Oy I'm doing some animations in Maya 2019 and I have some issues once exporter in Unreal Engine 4.20.
For exporting I use the File > Game Exporter menu. (Any other export workflow I tried so far resulted in a freezing import in Unreal).
Everything goes well using the Game Exporter, I do have some errors when imported in UE4 but it all looks fine, except for one thing:

alt text

My character's face is all messed up. After some digging, I discovered it's all about some of the face's morph targets having insane values:

alt text

If I manually put all those insane values to 0, everything looks fine. What could cause this?

If I check the mesh asset, the morph targets are limited from -1 to 1 and they look as they should look when I move the slider.

The errors I have when importing my animation are:

Imported bone transform is different from original. Please check Output Log to see detail of error.
Mesh [Geometry have no name] in the fbx file is not reference by any hierarchy node. 

Thanks for any help.


Solution

  • Sometimes the hard way is actually the simplest way.

    I couldn't have anything working using Game Exporter or using plugins, so I made myself a script for baking my animation including my corrective morphs and exported the result in FBX 2018. It works.

    So here's how I made up my script:

    First I selected my export selection set (it contains my geometry and deforming joints), then clicked Key > Bake Simulation (you have to be in Animation set menu to have the key menu displayed). I open the script editor and copy the command line starting by "bakeResults" (it's easy to find it if you have selected plenty of things just before: it's a massively long line at the end of the script editor).

    From there I have my script base, but it doesn't include the baking of my blend shapes.

    So, for each object with blend shapes to bake:

    • select the object in the outliner
    • double click its blend shape input in the channel box
    • copy its name
    • paste it at the end of the script, just before the };
    • make sure to respect the syntax: each list element must be between two " and separated with a comma and space . No comma nor space after the last element before };

    It looks something like this:

    bakeResults -simulation true -t "1:60" -sampleBy 1 -oversamplingRate 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -removeBakedAttributeFromLayer false -removeBakedAnimFromLayer false -bakeOnOverrideLayer false -minimizeRotation true -controlPoints false -shape true {"element_to_bake", "another_thing_to_bake"};
    

    But with much more elements in the list.

    Notice the -t "1:60" in the line: it's the frame range you want to bake. You will need to adapt those numbers to your needs. Once you have this line, I recommend you save it in a file somewhere.

    To use it, SAVE YOUR PROJECT BEFORE BAKING, then paste the script in the MEL command line at the bottom left corner of the UI, adapt the time range if needed, then press ⏎ ENTER to execute the baking script.
    When the baking is finished, you can export your FBX and then reload your saved project file.