CesiumGS / gltf-pipeline

Content pipeline tools for optimizing glTF assets. :globe_with_meridians:
Apache License 2.0
1.91k stars 250 forks source link

Reuse data chunks for minimal file size #307

Open Nehon opened 7 years ago

Nehon commented 7 years ago

Following this issue https://github.com/KhronosGroup/glTF-Blender-Exporter/issues/70 @donmccurdy asked me to submit an enhancement.

The original issue was about reusing animation sample inputs when possible. Usually, input will be times from start frame to end frame and if they are sampled with an identical rate the data will be the same. So using the same chunk of data for all samplers saves space.

However @donmccurdy's idea goes further. He suggest to scan already written data and reuse identical chunks by using sparse accessors. This would provide some sort of compression, with virtually no decompression overhead, as you have to read the data anyway. However... it can take a lot of time to export the file with this kind of process.

Maybe a middle ground would be to write, right away in the data chunk, common data like unit vector 3 (often used for anim scale), vector 3 Zero, identity matrix or quat etc... and create a sparse accessor to them whenever it's relevant. This would save space to some degree especially with data containing redondant default data.

Envisioned difficulty is that it's not so simple to check equality with floats, and methods to use to do it can depend of the magnitude of the float. interesting read about the topic

lilleyse commented 7 years ago

Good ideas - combining identical animation inputs will be helpful. The sparse accessor approach might be a good second step if needed, but could be overly complicated too.