How to reduce GLTF file size exported from Blender?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AzureOrc

Hi, I’m trying to use GLTF to export-import models from Blender but the size of the glb/gltf files seems to be extreme (dozens of mb). I found out that during exporting the character’s animation is transformed from key-to-key interpolation into frame-by-frame animation. I know I can increase “Sampling Rate” in the settings during exporting but in the “Why we should all support glTF 2.0 as THE standard asset exchange format for game engines” article they claim that GLTF also supports “many key interpolation types”. But I don’t see it anywhere.

Is it possible to fix it in Blender or I have to import it as it is and rework animation in Godot manually?

what about materials ? They take plenty of space in gltf, while in Godot You can just use one material with various colours. Only export materials “as placeholder”

Inces | 2022-07-22 21:03

Without materials the size is reduced by several hundreds kb.

AzureOrc | 2022-07-23 06:38

Ok. But did You already determined, that it is animation responsible for the size ?
How much faces does your model have, how much bones does it use ?
If You only have one character like this, it is not a big deal. But if all of your models are of this size, You should think if is there anything all models can share for optimization. Like communal armature or animations.

Inces | 2022-07-23 06:51

Yes, it is animation. The model is a rigged character. The model has 6205 triangles. GLB files with no materials have size 19mb exported with animations and 320kb exported without animations. No shape keys in both versions.
Another example, here’s animation key in Blender before exporting
enter image description here
Then I exported the model and imported in blender again
enter image description here
As you can see the exporter just destroyed all the interpolation putting keys in every frame. There’s an option in exporter that allows to adjust the gape among keys (for instance, to put a frame every 10 frames and not every frame) but it doesn’t work for me
enter image description here

AzureOrc | 2022-07-23 07:24

Interesting.
So theoretically, could You remove interpolation handles in Blender, export sole keyframes, and add interpolation handles in Godot ?
Even if You could, that would be crippling workflow I guess, You would have to create new animation based on imported one before remaking it. This would make reimporting updated/tweaked animation extremely tedious.

Inces | 2022-07-23 08:52

Yes, that’s the problem. I wouldn’t even actually care but this makes the game’s resources extremely heavy.
I have just found animation optimization that removes duplicated keyframes and it reduces the file size to 8-9 mb but it’s still too big. Godot optimizes it somehow again and .anim file is getting size of 2-3 mb. It’s way better but the problem stays because I can’t just use GTB/TF formats in Godot, I have to convert everything in Godot resources which makes the assets workflow awfully exhausting.

AzureOrc | 2022-07-23 09:04

:bust_in_silhouette: Reply From: AzureOrc

I have solved this.

The problem appeared to be in me not understanding how to properly export animations. Every exported action must be pushed in NLA editor via “Push Down” button in the action editor
enter image description here
Or “Stash” on the right from “Push Down” to make sure every action is separated. Every tutorial says that every NLA track must be named after the action it represents. But this didn’t work for me unless I created NLA tracks automatically via the mentioned “Push Down”/“Stash” button. Then it is possible to uncheck “Always Sample Animation” checkbox in export setting in animation category
enter image description here
The instructions are very confusing and unclear, especially considering that removing “Always Sample Animation” will cause a giant Blender error instead of mentioning that actions were not properly pushed in NLA editor.

I have found Blender to be atrocious for animations that are intended to be exported to any game engine, and am trying really hard to switch to Godot 4’s skeletal animation system.

Happily, Godot 4’s skeletal animation system has progressed significantly between 3.x and 4.0. Unhappily, it is missing one crucial feature that makes it not very useful: multi-bone transforms. Godot’s animation system allows only one bone to be manipulated at a time, which makes many animations implausible to do within Godot.

Godot 4 is really close to being a substitute for Blender skeletal animations, and I can’t wait until that little oversight is addressed.

stormreaver | 2022-07-25 16:58