KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.07k stars 1.13k forks source link

Implement Draco Encoding Compression algorithm #2291

Open SoftwareMechanic opened 1 year ago

SoftwareMechanic commented 1 year ago

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](https://faculty.cc.gatech.edu/~jarek/papers/EdgeBreaker.pdf)

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

echadwick-artist commented 1 year ago

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

donmccurdy commented 1 year ago

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:

SoftwareMechanic commented 1 year ago

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.

donmccurdy commented 1 year ago

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.

ngcthuong commented 7 months ago

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