Kupoman / blendergltf

A glTF exporter for Blender
Apache License 2.0
319 stars 49 forks source link

Options to switch off optimization for exporting skin joints #124

Closed shrekshao closed 6 years ago

shrekshao commented 6 years ago

Hi Kupoman! Thanks for this great tool.

I'm currently trying to use this to export gltf for clothes switchable avatar app.

Basically I have a blender scene with the skeleton and character skin, and another scene with the same skeleton and some clothes mesh. I export two separate gltf files, and bind the clothes to the skeleton at runtime.

The problem is that some of the nodes in the joint list are getting deleted when exported (probably because there are no weights on them). So now the joint lists in the character file and clothes file are not same any more. The inverseBindMatrices of the clothes will not match the joint list of the character file anymore.

So do you think it reasonable to add an option to let user turn on and off for some optimizations (skin joints in my case). To support this opinion, I think sometimes we want to export the gltf file exact same as what we manually put in the blender scene.

Thank you!

Below is the example of output joint lists:

character gltf:

{
            "inverseBindMatrices": 416,
            "joints": [
                3,
                4,
                5,
                6,
                7,
                8,
                10,
                11,
                12,
                13,
                14,
                15,
                16,
                18,
                19,
                20,
                22,
                23,
                24,
                26,
                27,
                28,
                30,
                31,
                32,
                34,
                35,
                36,
                37,
                38,
                39,
                40,
                42,
                43,
                44,
                46,
                47,
                48,
                50,
                51,
                52,
                54,
                55,
                56,
                58,
                59,
                60,
                61,
                63,
                64,
                65,
                66
            ],
            "name": "F010_Saber_Body",
            "skeleton": 3
        },
        {
            "inverseBindMatrices": 626,
            "joints": [
                6,
                7,
                8
            ],
            "name": "F010_Saber_Face",
            "skeleton": 3
        }

clothes gltf:

        {
            "inverseBindMatrices": 174,
            "joints": [
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10,
                11,
                12,
                13,
                14,
                15,
                16,
                17,
                18,
                19,
                20,
                21,
                22,
                23,
                24,
                25,
                26,
                27,
                28,
                29,
                30,
                31,
                32,
                33,
                34,
                35,
                36,
                37,
                38,
                39,
                40,
                41,
                42,
                43,
                44,
                45,
                46,
                47,
                48,
                49,
                50,
                51,
                52,
                53,
                54,
                55,
                56,
                57,
                58,
                59,
                60,
                61,
                62,
                63,
                64,
                65,
                66
            ],
            "name": "Saber_maid_dress",
            "skeleton": 2
        }
shrekshao commented 6 years ago

Well... I'm actually not sure if the missing nodes is because of the optimization of the exporter. The character is imported from a fbx generated by mixamo... So is the exporter takes any effort on optimization of the joint list?

Kupoman commented 6 years ago

@shrekshao There is currently no optimization of the joints list. Joints are in the node list along with other objects, such as your character, clothes, lights, camera, etc. I think what you are seeing is differences in that node list between your files. Do your two scenes have the same number of objects in them?

shrekshao commented 6 years ago

Yeah that's a good point. The number of objects are different. But besides that, Actually there's a missing node[9], which is a leaf node, in the character gltf file. But knowing that there's no optimization for joint list is enough for me. Thanks for your reply!