Is it possible to bake armature poses into shape keys/ morph targets?

Is it possible to bake armature poses into shape keys/ morph targets?

Using 32 bones to animate hands seems excessively when i reality they will only be switching between clutching a weapon, open palm and fists…

I have a hand rig set up already and have the poses i would like saved as key-frames is there any way to essential bake these down into shape keys?, collapsing, applying or removing the armature skinning.

if you select the mesh and open the modifiers panel, on the armature modifier you will see a button “apply as shapekey” this is what you are looking for, BUT you will need to find proper instructions on how to use it and set up the model to make the shape key from the modifier as i have not used this function yet and can’t advise you further.

1 Like

This sounds suspiciously like the model will eventually go into a game. Make sure your game engine supports Blender’s shape keys and doesn’t require everything to be animated by bones before you waste your time with this.

Also, shape keys don’t move the same way as bones, so the action of curling the fingers and such might not end up looking the way you expect. Besides, if you already have made the armature, you’ll have to animate the motion of the bones just to get this shape key in the first place, at which point you could just save that motion to a pose library, which would make this whole shape key thing unnecessary and allow you the flexibility to animate other hand actions later if you discover that you need them after all.

The Apply as Shape Key option works only for the pose of the frame at which the modifier is applied, it will not save a series of poses so a shape key/morph target animation can be accomplished. For that, you need to export the animation as a .mdd file, which first requires enabling the Import-Export Newtek MDD file add-on (in User Prefs/Add Ons). Once the add-on is active, use File>Export>Lightwave Point Cache to export a designated series of frames as a cache (file) of vertex (point) locations. Check the Tools panel for user export options, which are extensive & may need some trials to get the best settings.

The data exported (the point cache) can then be applied to the existing mesh or a duplicate (recommended) by importing the .mdd file (File>Import>Lightwave Point Cache .mdd) as shape keys on the selected mesh, which needs to be identical to the mesh from which the point cache was exported.

Note that the point cache export will include ALL mesh-level modifiers on the selected/exported mesh, including such modifiers as Cloth, Soft Body, Edge Split, and (iirc) even those such as Solidify and Subsurf, anything that alters the base topology/vertex count and/or the morphology (shape) of the selected mesh, so remember to disable any and all modifiers that you do NOT want exported. This makes it very versatile but also requires caution, because many modifiers can result in a gargantuan .mdd file, and/or a Blender crash due to memory exhaustion.

Also note that the shape keys will also reflect all Transforms on the exported mesh, even Object-level transforms, so adjustment to the target mesh will be needed to compensate once the shape keys are invoked. At first try, it can seem confusing because it can cause the mesh to seem to jump out of place, but if you remember that the shape keys record vertex positions per frame, as determined by all active Modifiers and Transforms, it makes more sense.

Ironically, the animations you can produce this way are the oldest form of 3D mesh animation (for games as well), and predate skeletal (armature) animation by many years. But it is an out-dated animation process for characters, though useful for some types of animation like a looped waving flag, and it is not as widely supported as it once was. For example, the base Unity engine does not include vertex animation (the label for the process in many game settings). The advent of real-time cloth sims and the physics chips have almost made such animation methods fully obsolete.

1 Like

I don’t know if you still need the answer. This is how I solve it: use modifiers than apply armature to the modifier. The armature is used to control the modifier. According to the different materials of the model, you can choose Laplacian Deform or Lattice.My English is not very good,these videos from two experts, hope it helps.


1 Like

Can you put the links of the videos please?

That user was online last time more than 2 years ago

However I’ve found this one:

Hope it helps

Seems like I’ve found them:

1 Like

Hey, you can use this script to create shapekey animation from your evaluated mesh. Either if it’s a displacement or an armature modifier. It will apply the modifier stack and create a shapekey for each frame:

import bpy

ob = bpy.context
obAc = ob.active_object
mesh_data = obAc.data

start_frame = bpy.context.scene.frame_start
end_frame = bpy.context.scene.frame_end

if not obAc.data.shape_keys:
    obAc.shape_key_add(name="Basis")

# Create shape keys for each frame
for frame in range(start_frame, end_frame + 1):
    bpy.context.scene.frame_set(frame)
    
    # Evaluate the mesh with modifiers
    depsgraph = bpy.context.evaluated_depsgraph_get()
    object_eval = obAc.evaluated_get(depsgraph)
    mesh_eval = object_eval.data
    
    # Create a new shape key and set its points based on the current frame
    shape_key = obAc.shape_key_add(name=str(frame))
    
    # Collect vertex positions for the current frame
    vertices = [vertex.co for vertex in mesh_eval.vertices]
    
    # Set shape key data
    shape_key.data.foreach_set('co', [c for v in vertices for c in v])


if obAc.data.shape_keys:
    shape_keys = obAc.data.shape_keys.key_blocks
    
    # Iterate through shape keys and set keyframes
    for frame in range(start_frame, end_frame + 1):
        ob.scene.frame_set(frame)
        
        for shape_key in shape_keys:
            if shape_key.name.isdigit(): 
                value = 1.0 if int(shape_key.name) == frame else 0.0
                shape_key.value = value
                shape_key.keyframe_insert(data_path='value', index=-1)
1 Like