glTF icon indicating copy to clipboard operation
glTF copied to clipboard

Implement Draco Encoding Compression algorithm

Open SoftwareMechanic opened this issue 2 years ago • 5 comments

Hi all! I would like to implement the draco compression algorithm on my own for creating gltf/glb files, but it is not clear to me what is the algorithm to implement.

I found this docs: https://observablehq.com/@mourner/edgebreaker-the-heart-of-google-draco [https://faculty.cc.gatech.edu/~jarek/papers/EdgeBreaker.pdf](url)

But it is still not clear to me how I could start, do you have any suggestion on this? Any help would be much appreciated

Thank you in advance

SoftwareMechanic avatar May 21 '23 15:05 SoftwareMechanic

The draco extension page has links to the official resources https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression

echadwick-artist avatar Jul 08 '23 13:07 echadwick-artist

I think it's fair to say that only one implementation of the Draco encoder currently exists, and that encoder is integrated (as C/C++ or WASM) into many glTF creation tools. While there should be enough detail in the specification and linked resources to implement it from scratch, be warned that it's a large undertaking. Implementing a decoder from scratch might be more practical, if that's sufficient for your needs.

If you're OK with using the official Draco encoder in your own glTF/GLB creation pipeline, you can see how I implemented Draco encoding in my own tool, glTF Transform, below. The encoder.ts file contains most of the code you'll need:

  • https://github.com/donmccurdy/glTF-Transform/tree/main/packages/extensions/src/khr-draco-mesh-compression

donmccurdy avatar Jul 08 '23 15:07 donmccurdy

Thank you guys! Yes I understand that rewriting the encoder is a big job, let's say that I am interested in how the algorithm works other than reduce the size of geometry and implement it in a custom converter directly, but I didn't find the algorithm or the pseudo code, this is why I created the issue.

If you guys will find something about it, please tell me 😀

BTW I will consider using the official Draco encoder in my pipeline.

SoftwareMechanic avatar Jul 13 '23 14:07 SoftwareMechanic

Here is the specification for the bitstream and decoder:

https://google.github.io/draco/spec/

I believe the exact implementation of an encoder is open to interpretation and not intended to be standardized, as long as the bitstream itself follows the specification.

donmccurdy avatar Jul 23 '23 16:07 donmccurdy

There is a reimplementation from MPEG with more details description. Maybe you can take a look.

ngcthuong avatar Dec 05 '23 00:12 ngcthuong