godotengine / godot-blender-exporter

Addon for Blender to directly export to a Godot Scene
GNU General Public License v2.0
1.12k stars 120 forks source link

Support exporting shape keys (blend shapes) #40

Closed mysticfall closed 6 years ago

mysticfall commented 6 years ago

Currently, it seems that the exporter ignores shape keys (or 'blend shapes') when it exports a mesh. But they are quite commonly used for animating facial expressions, or lip syncing(phonemes) in a 3d character, so it'd be good if we could support this feature.

I wish this issue could get priority even though it might look like a minor feature compared to others.

The reason is, we have no viable method of using shape key based facial expressions or lip syncing animations in Godot at this moment, which could be quite a significant limitation since two most widely used open source character models - namely, Manuel Bastioni Lab and Make Human - all support those features through shape keys.

While it is possible to workaround other limitations of Blender exporter by mixing the result from different exporters, like it's the case with materials for example, there's no other exporters that support shape keys reliably with a rigged mesh for now.

There's an issue report for Better Collada (godotengine/collada-exporter#41) which was created in 2016, but apparently that project looks to be made obsolete in favor of Blender exporter or GLTF.

So, I hope this could get resolved before more people begin to use Godot for 3D projects, because facial expressions or phonemes could be quite important features for such type of games.

Jason0214 commented 6 years ago

There is already a PR of supporting shape key, it is already tested and will be merged soon (hopefully tomorrow

mysticfall commented 6 years ago

Wow, didn't expect to see it'd happen so fast :) Thanks, and I'll try it as soon as it's merged to the master.

sdfgeoff commented 6 years ago

As Jason says, see PR #32 There's an outstanding bug that was spotted today, so it may be another day or two, but sometime very soon it will become supported.

sdfgeoff commented 6 years ago

PR #32 was merged.

mysticfall commented 6 years ago

I tested the new version with my model (https://github.com/mysticfall/AlleyCat/blob/master/Design/Blender/Characters/Human/Female/Body.blend) and it successfully exported an .escn file with reasonable file size in a few minutes.

But none of the exported shape keys seem to work if I change them inside Godot. Is there additional steps to make them work inside the editor?

sdfgeoff commented 6 years ago

Hmm. Ideally not. They should just work. (Thanks for being willing to use/report/test the exporter)

@Jason0214 May be something to do with combined armature and shapekeys?

Jason0214 commented 6 years ago

It is reasonable to take a few minutes, as for each shape key it is like exporting the mesh again. (Actually I can not even finish exporting the Body.blend, there are dozens of shape keys in the mesh! and blender only takes up one CPU and no GPU acceleration)

For simplicity I only keep one shape key in Body.blend remove others to test it. I found the even the original mesh is deformed if shape key is exported. And when I remove the subdivision modifier from the mesh, the exported mesh and shape key works perfectly, so I suppose mostly like the problem is caused by subdivision modifier. I will keep thinking about why this happens and come about a solution to it. @mysticfall @sdfgeoff

mysticfall commented 6 years ago

@Jason0214 When I said it took several minutes, I actually mentioned it in a sense that it's a vast improvement over how it was with Better Collada which just freezes my whole desktop (even with 'Apply Modifier' unchecked) as I commented in a relevant issue :)

By the way, I should have said that I tested with Apply Modifiers option unchecked. When I export the model and move the sliders under blend_shapes section on the imported mesh node, I don't see any differences in the viewport.

Jason0214 commented 6 years ago

I tested one shape key (the_closed_eye_max one) it works fine by moving the slider in blend_shapes, the eye do close. could you tell me which blend_shape doesn't work @mysticfall ? then, I will go to test it

mysticfall commented 6 years ago

I tested again with removing everything except for basis and Expressions_eyeClosedL_max but it didn't work either.

Could it be the case that it was because I'm using a different version of Godot/Blender? I tested it with the master branch (2ff31bada revision) of Godot, and Blender 2.79. And I exported my model with the skeleton (which looks deformed, but not the mesh) and without animations.

Please let me know if there's anything I can do to track down the cause.

Jason0214 commented 6 years ago

confirmed when Apply Modifier is NOT used, the exported blend_shape doesn't work. It is a bug.

but when Apply Modifier is used and remove the subdivision modifier, the blend_shapes does being exported and work correctly. Problem may comes from shape key itself is a modifier. In the implementation exporting the shape key, it need a step to apply shape key on the original mesh, this will not happen if the Apply Modifier is not set.

sdfgeoff commented 6 years ago

There is now a check against the modifiers in blender that will warn the user in the case they try to export a mesh with shapekeys and modifiers.

There are technical reasons why exporting shapekeys with modifiers that generate topology (eg bevel, subsurf) is, at the very least, rather difficult.