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

File size goes to 70mb when exporting gltf with 50 shape keys, and fbx is only 6mb #1581

Closed butaixianran closed 2 years ago

butaixianran commented 2 years ago

I'm exporting Daz Character from Blender to gltf+bin files. Character is with 50 common facial and viseme morphs, without cloth, hair or animation.

File size of gltf is 2mb, but bin file goes to about 70mb.

If I export fbx from Daz or Blender with morphs, fbx file size is about 6mb.

That's a big difference between 6mb and 70mb.

And if I export gltf+bin file without shape keys, bin file is less than 6mb.

This could make gltf out of game when exporting model from blender to game engines.

Is there a solution for this?


Infromation: Blender version: 3.0

Daz to Blender bridge for 3.0: https://github.com/butaixianran/DazToBlender

scurest commented 2 years ago

AFAIK FBX stores shapekey positions sparsely (#1346) and doesn't store normals.

butaixianran commented 2 years ago

Thanks for your reply, it helps.

Now, I unchecked shape key normal when exporting, bin file is down to 31mb.

Then, we have to wait Sparse Accessors for gltf.

donmccurdy commented 2 years ago

Would it be possible to share the .blend and/or .glb files for this example?

If your game engine supports the EXT_meshopt_compression glTF extension I'd suggest trying to run gltfpack on the model:

gltfpack -i in.glb -o out.glb -cc
butaixianran commented 2 years ago

I updated a blender file also a glb file for testing:

blender file: 108mb https://mega.nz/file/9n5W3R7I#isbVWh_xI_vnU5JpIppL9f99tOfSkFT8nW5NcrXDgA0

glb file: 75mb https://mega.nz/file/Rjw2nTKA#boURdDt2AE6DFFFpl3vi8JDks__FuG5JdgMJoU7oknk

There is a Daz Genesis 8 free default character in it, with facial shape keys.

Also thanks for the information about gltfpack. It helps to size down glb from 50mb to 35mb.

But I can't find any information about which gltf importer support "EXT_meshopt_compression" in Unity. Most gltf importer have not been updated for years.

donmccurdy commented 2 years ago

Thanks! glTFast for Unity is the package I'd suggest, and does support EXT_meshopt_compression. I'll look into ways to reduce the file with sparse shape keys as a post-export optimization when I have the chance, or the gltfpack author might be open to implementing that as well.

julienduroure commented 2 years ago

Closing, as there is no bug here. Only space for enhancement, in case one day we manage sparse encoding. This is not a priority for now

donmccurdy commented 1 year ago

As an update here — glTF Transform v3 will support writing sparse (mostly zero) data more compactly, and could be a good option for compressing files with shape keys, like this one.

Example, using a pre-release of v3:

npm install --global @gltf-transform/cli@next

gltf-transform sparse input.glb output.glb

I didn't find the original FBX to compare, but this seems to bring the size down to where you'd expect. The .bin file containing the mesh data is now only 4.4 MB.

mostafamdy commented 1 year ago

Hi @donmccurdy do you know how can I use gltf-transform with threejs

donmccurdy commented 1 year ago

@mostafamdy let's discuss this in https://github.com/donmccurdy/glTF-Transform/issues/882.

lyuma commented 1 year ago

Am I correct in assuming this is a duplicate of:

I'll put my comment there instead.