Download

Edit and duplicate morph targets of skeletal mesh

How to duplicate and edit morph targets (i.e. change affected vertices and the delta) after importing a SkeletalMesh via C++? Is there any example code for something like this somewhere? I already found the source code of the MorphTarget.h and tried to iterate over the FMorphTargetDelta and simple change the PositionDelta, however, this changed not anything:



for (FMorphTargetLODModel& model : target->MorphLODModels) {
  for (FMorphTargetDelta& targetDelta : model.Vertices) {
    targetDelta.PositionDelta *= 2;
  }
}

I guess that some update method must be called, right? Does anyone here know more? And how can I cleanly duplicate a morph target so that it can be stored in the skeletal mesh?

Background is that I would like to use morph targets for facial expressions and for speech at the same time. The problem here is that the morph targets for facial expressions already transform the mouth as well (e.g. already open the mouth). Therefore I would like to duplicate the morph targets for the faces and reset the delta of the vertices near the mouth for the copy (or reduce their influence depending on their distance from the mouth). Depending on whether the character is speaking or not, one of the both morph targets will be applied. I know it would be more performant and better to have facial animations modular (i.e. morph targets separately for eyes, eyebrows, nose, mouth, etc.). Unfortunately, I don’t have the assets to do that, and I couldn’t create facial animations by hand that were anywhere near the same quality.

I have now been able to solve this by extending the import plugin that uses the Fbx SDK. There, the BlendShapeChannel is now copied for the desired gestures during import and areas near the mouth are omitted - works great and I don’t have to manipulate the morph targets at runtime.