KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.49k stars 317 forks source link

Shapekey export is incorrect #2021

Open hybridherbst opened 1 year ago

hybridherbst commented 1 year ago

Describe the bug While playing with some of the files available on https://studio.blender.org/films/charge/, I noticed that the shape keys for the Einar rig are not exported correctly to glTF.

To Reproduce Steps to reproduce the behavior:

  1. Download .blend file from https://studio.blender.org/films/charge/?asset=6279
  2. (optional) delete everything but the geometry image
  3. Export as .glb

Expected behavior While it's expected that materials and shaders break, I would expect the shapekey animation to look correct.

https://github.com/KhronosGroup/glTF-Blender-IO/assets/2693840/1df1512d-3068-443f-bd76-ffd9739dcbb8

Screenshots If applicable, add screenshots to help explain your problem.

.blend file/ .gltf See above

Version

Additional context Have used ShapeKey export just fine in the past so I think there may be another issue at play here.

julienduroure commented 1 year ago

Most ShapeKeys of this model have some blend VertexGroup. This is not implemented in glTF exporter (yet). This is a duplicate of #747

image

Deleting of VertexGroup blend will lead to same behavior in Blender than you got after export: image

hybridherbst commented 1 year ago

I see, thank you! Do you have an idea on when you may get to that, seeing that the other issue is from 2019?

In case it helps, I recently found this very helpful way of retrieving the actual result state of a mesh from Blender:

# From https://blenderartists.org/t/alternative-to-bpy-ops-object-convert-target-mesh-command/1177790/3
def mesh_eval_to_mesh(context, obj):
    deg = context.evaluated_depsgraph_get()
    eval_mesh = obj.evaluated_get(deg).data.copy()
    new_obj = bpy.data.objects.new(obj.name + "_collapsed", eval_mesh)

    for o in context.selected_objects:
        o.select_set(False)

    new_obj.matrix_world = obj.matrix_world
    new_obj.select_set(True)
    context.view_layer.objects.active = new_obj
    return new_obj