Proposal to improve shapekey transfer

Issue #1664 resolved
jeroen b created an issue

I like to create custom shapekeys for my characters, included is an example blendfile for demonstration purpose. Blender allows copying any shapekey from one mesh to another, regardless of size, shape or location as long as the geometry shares thesame number & order of vertices.

Unfortunately, this can only be done one shapekey at the time, wich becomes a tedious procedure very quickly.

I wonder if it would be possible to extend the excellent shapekey transfer from the addon (that is based on the projection method), with the option to use this method of copying shapekeys to another mesh while using the addon’s dialogue to make a selection?

If possible, this would be a major time saver and I think will offer interesting new possibilities for using genesis characters in Blender.

(NB; feel free to use the custom shapekeys from the blendfile, hope you like them. After copying the custom key’s from selected to active, the drivers must be copied manually from the respective default JCM’s. Some custom shapekeys have there driver argument modified. For instance the custom shin155 key must show up quickly only at the extreme position, so the argument becomes a*a*a, making it exponential. The argument shows up when you leftclick the purple driverfield and can then be edited.)

Comments (11)

  1. Alessandro Padovani

    Meanwhile this is a script that does it, actually my very first script in blender.

    # by Alessandro Padovani
    # 
    # this copies all shape keys
    # select source then shift-select target as active then run the script
    
    import bpy
    
    source = bpy.context.selected_objects[0]
    
    for idx in range(1, len(source.data.shape_keys.key_blocks)):
        source.active_shape_key_index = idx
        bpy.ops.object.shape_key_transfer()
    

  2. jeroen b reporter

    Alessandro, that is a useful script for transfering shapekey’s to a mesh that you start working with, but not very good for transfer between meshes that both have already a hundred (or even more) shapekey’s. I was hoping that it would be possible to use the addon's selection dialogue and perhaps even automate copying the correct drivers & arguments to the transfered custom shapekey’s at thesame time.

  3. Thomas Larsson repo owner

    Implemented in last commit. Set the transfer method to “By Number”.

    As you noticed, there are problems with drivers, so it is probably best to leave the Transfer Drivers option unchecked. If it is enabled, the new shapekeys are driven by the shapekeys of the original mesh. This makes sense if we transfer to clothes or geografts, whose shapekeys should have the same values as the body. But that is strange if we transfer between different characters. The best strategy is probably to import the morphs again to the new character, and only transfer the special morphs that don’t come from DS.

  4. jeroen b reporter

    Thanks Thomas for the quick implementation, appreciated!

    However there is a problem with the Diffeo shapekey transfer. The shapekeys that are transferred with the plugin take the size of the source mesh into account, while the manually transfered shapekeys work as expected.

    See the pictures and the blendfile that is included above this message.

    I suspect that this problem might have something to do with the reverse order of selecting source & target mesh in the manual method versus the Diffeo method.

  5. Thomas Larsson repo owner

    I see. In the last commit the offset between the source and target vertex location is added to each shapekey. Seems to fix the issue. At least a zero shapekey becomes zero on the target mesh.

    Transferred shapekeys will not work so well if the meshes are as different as in the test file, since a bigger mesh generally requires bigger shapekeys. But that is lesser problem.

  6. jeroen b reporter

    Transfer by number working perfect now, thanks Thomas!

    You are right offcourse about shapekeys not working so well if the target mesh differs in size as in the testfile, normally this will almost never be an issue. It is not hard to fix though if you multiply min/max range of the shapekey and tweak the driver argument with the size ratio of the two meshes.

    Thanks again, issue closed.

  7. Log in to comment