Convert morph to shapekey can take up to 6 hours.

Issue #1008 closed
bouich jules created an issue

Hello,

i just want inform, that the convert morph shapekey can take many hours, if there is a lot of morph! specially facial morph.

that’s probably normal, but just wanted to mention this.

i have a 32GB ddr4 and i9-9900k.

thank you

Comments (15)

  1. Thomas Larsson repo owner

    Yes, this tool seems to have a serious performance problem when you have meny morphs loaded. When I load and convert three expressions (loaded six, main morph + _div2 morph), each conversion took about 0.2 seconds. With all 40 expressions loaded, a conversion took 2.0 seconds instead. And it didn’t help to mute every single driver.

    Unfortunately, I think that this is an issue with Blender itself. To make each conversion, the plugin sets an armature property, updates the armature, and applies the armature modifier as shapekey. Since those steps are the same for each morph, the reason why each conversion take longer when there are many morphs must be that the time for the update and applying a modifier increases with the number of drivers.

    This is not surprising, I guess, but it is a problem. The only solution I see atm is to keep down the number of morphs to the ones that you will really need. One possible workaround would be to load a subset of the required morphs, convert those, and save them to an external file. Once all morphs are done, these files could be loaded and the complete set of shapekeys assembled. But that would be a hassle.

    Anyway, the Disable Drivers button is now more complete, and disables ERC morph drivers and optionally location, rotation and scale drivers, which should boost viewport performance a little bit further.

  2. Midnight Arrow

    The shape key system is ancient and overdue for overhaul.

    Blender is doing the “everything nodes” project now where everything bit of functionality gets converted to nonlinear nodes. Geometry nodes is already replacing the end-of-life particle system. The programmer behind the Animation Nodes addon Jacques Lucke was recruited for everything nodes so I assume revamping the shape key/drivers/animation system will happen soon.

    @ Thomas

    Animation Nodes is a free addon. I haven’t used it yet, but it may be worth integrating? It was developed because of shortcomings in Blender so it may help solve some of our issues.

    Also you can transfer shape keys between a mesh as long as their indices match. So the exporter can create a duplicate figure in the background to convert the morphs to shape keys in batches and then transfer them back to the main figure.

  3. Thomas Larsson repo owner

    I don’t think it would help to create a duplicate mesh. The problem is that the rig has lots of drivers (object properties, armature properties, and posebone rotations and locations), and it is the evaluation of those that takes time, apparently even if all of them are muted. The web of drivers is quite intricate and it is not feasible to extract just a subset to add to another armature.

    I added a new tool Save Morph Preset, which saves the shapekeys as duf files. Then you can load just a subset of the morphs, convert them to shapekeys, and save those shapekeys to duf files. Rinse and repeat. This involves quite a bit of manual labor, but better than waiting six hours. The duf files can finally be loaded with Import Custom Morphs. It should be possible to load them into DS as well, but so far I didn’t succeed with that.

  4. bouich jules reporter

    Saving them, then load them on all characters that’s an amazing idea and can save a lot lot lot of times! you do it once and you’re done, that’s cool.

    Anyway i tried the new function

    but i get this crash:

  5. Thomas Larsson repo owner

    This happened because you were trying to save the files in a directory that doesn’t exist. The last commit handles this error, and has some other improvements too. Unfortunately I still haven’t been able to load the morphs in DS.

    The time to convert morphs seems to be quadratic in the number of morphs, whereas saving and loading morph files is only linear. So breaking up your morphs into managable batches should improve conversion time considerably.

  6. Alessandro Padovani

    If I understand correctly.

    We can avoid the issue from the start instead of creating it then trying to fix it. That is, we may have an option on the morphs panel to import the morphs as shapekeys or as drivers. That will do basically the same as “save morph preset“, but in the background. So the user will get a figure with either shapekeys or drivers, depending on the selected option. To get the same morphs both as shapekeys and drivers makes little sense anyway.

    The advantage of drivers is the geometry takes less memory, but we have to drive a number of bones for every morph.

    The advantage of shapekeys is we drive a single property to get the morph, but will take more memory since it’s basically “baked drivers“. And exports better to game engines. Please note that drivers baked to shapekeys will only bake the final shape though, so intermediate shapes may not be the same.

  7. bouich jules reporter

    @thomas

    what mean this? please the directory obvisouly exist. it’s “ documents”.

    changing to another output does not fix this issue.

    EDIT: Also please what is the difference between

    Presentation : Pose control and Shape

  8. Thomas Larsson repo owner

    Bouich, you have to specify the directory, not the filename. The filenames are taken from the shapekey names. In this case, the tool is looking for the subdirectory Z_NGM_Squish… which does not exist. You can also specify the directory in the field just below to button, by pressing the folder icon to the right. This is a bit inconvenient, but I haven’t figured out how to make it work inside the popup dialog.

    The presentation specifies where the morph should show up in DS, but so far I haven’t managed to make it show up at all. It doesn’t matter if you intend to load the file in Blender.

  9. Thomas Larsson repo owner

    Alessandro, even if you do the conversion on the fly Blender needs to evaluate all drivers to build the shapekey. The number of drivers and driver variables grows with the number of morphs already loaded, and so does the time for the evaluation. So now the time to load the morphs can become very large instead. Btw, this is the reason for the poor viewport performance when many morphs are loaded.

  10. Thomas Larsson repo owner

    I don’t know much about game engines, but I imagine that it isn’t a good idea to include tons of shapekeys. So that is another reason to keep the number of morphs down.

  11. bouich jules reporter

    I port all my blender model with tons of shapekeys 100+ to unreal engine 5 without any problem.

    regarding game engine it’s really easy, it’s super easy, i bring the stuff from daz with the plugin, then create/convert morphs to shapekeys, use Xin plugin to create an HD mesh then transfer all shapekey to my HD mesh, convert to MHX ( yes MHX not rigify) then FBX or any other plugin in 1 click , i transfer my HD mesh with tons of shapekey and mhx rig to UE5. all my mhx rig animation and shapekeys works perfectly good and smooth in UE5.. and to be honest it’s super beautiful, now i render everything in UE5 instead of blender even videos 🙂

    Anyway regarding this issue all looks good here, thank you thomas!

  12. Thomas Larsson repo owner

    This was an application that I didn’t foresee when I started this project, but I’m happy to hear that things work out for you.

  13. Alessandro Padovani

    Bouich, may be you can write a tutorial to export daz assets to UE5 via diffeomorphic. It may be super-easy for you but personally I’d not be able to do it without detailed instructions, admittedly also because I’m not interested in game engines. So may be Thomas could add a blog post with your tutorial. I’m sure this will be useful to many.

    edit. Bouich, also how is this better than using the official daz bridge to UE5 ? Are there advantages or is it just an alternative ?

    https://www.daz3d.com/forums/categories/unreal-discussion

  14. bouich jules reporter

    @Alessandro it’s just an alternative, actually i think that’s why Xin created the HD mesh plugin. Xin will be better than me for tutorials!

    Anyway regarding this issue i will close it if all good, thank you.

  15. Log in to comment