godotengine / godot-blender-exporter

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

Excessive file size when exporting blendshapes #58

Open mysticfall opened 6 years ago

mysticfall commented 6 years ago

Although, now exporting blendshapes itself works great after recent changes, the resulting file(*.escn) seems to be excessively large in size, compared to its original Blender source.

For example, my model contains about 80 shapekeys which is stored as a 20mb Blender file. However, when I export it using Godot Blender Exporter, it becomes over 220mb in size and it seems to be causing various issues like visual glitches or increased loading time.

I wonder if there's any way to mitigate this problem, either by changing the Blender source file, or change the way its exported by the addon code.

sdfgeoff commented 6 years ago

This may not be possible due to the way the files are stored. Blend files are a binary format, so a floating point number occupies 32 bits. The .escn format is a text based format, so numbers are stored in ASCII, eg: 2.98023e-08, Including the comma and space, this is 88 bits, more than double the space, just for a single number. Additionally, in blender, normal and tangents are automatically calculated on teh fly, and aren't stored in the blend file. In the escn file, they are stored for each shapekey to lower computation time when displaying the model. This alone will double or triple the filesize.

Question: What are you comparing the "increased loading time" to? It could be related to file size on disc, but after converting to the binary scn format (inside the .import folder) this shouldn't have much difference to other formats.

I'm not sure what could be causing visual glitches. Do you have a blend you can share?

mysticfall commented 6 years ago

Thanks for the explanation. I was hoping that the problem was caused by duplicating vertex data without checking if they are affected by each shapekey or something similar, because in that case there could be a room for future improvements.

It seems that the only way to mitigate the problem is to reduce the number of shapekeys, if I understood the situation correctly.

The increased loading time I mentioned was that compared to how it was before I exported the mesh with shapekeys. It's understandable why it became so slower, since now I have 200mb .tscn + 30mb *.mesh files, whereas it was merely 6.4k .tscn + 523k .mesh before. I just didn't realize having shapekeys would have such a drasitic impact on file size.

As to the visual glitchy, I opened a separate issue here: godotengine/godot#19880, and you can find my Blender file here :

Jason0214 commented 6 years ago

The shape keys do have a lot of duplicating vertex data (as well as bone data), every shape key is stored as the whole mesh data merely without vertex indices, thinking about you have a large mesh and only use shape key to change an expression, the duplication is huge. The problem is that the format of shape key being stored is decided by Godot engine, it is not likely to change in this add-on side.

However, a small issue is that this exporter is using an old format of Godot to store mesh (I mentioned in #29 ), I didn't look through the new format yet but I suppose it is possible that the new format use a more space-saving way, I will go to check it when I have some available time.

Terkwood commented 3 years ago

Hi, my apologies if this takes the ticket off topic --

I found that using the decimate modifier helped me reduce the file size of the ESCN export. Taking away some of the faces in the object didn't detract from my particular use case, and I was able to shrink the output size by a lot