Compressing 3D Model Files with Draco

Historically used for CAD and video games, 3D computer models are working their way into the mainstream. This is, in part, due to the rise in popularity of things like augmented reality and 3D printing.

My current project uses 3D model data, and my team was looking for an efficient way to upload this data to our server. The file sizes for 3D models can often be very large, so compressing the files was a requirement. We initially tried using standard compression approaches (e.g., gzip, 7-Zip, etc.) and were able to make some progress, but even the compressed files were still pretty large. Then we discovered Draco.

Draco is an open-source library for compressing and decompressing 3D mesh data. Thus far, it has worked well for us. In fact, it has worked so well it’s hard to believe.

In this post, I’ll give a quick rundown of installing and using Draco, then walk through an experiment that demonstrates how well it can compress 3D model files.

Installing Draco

Draco was created by the Google Chrome media team. It’s open-source and available on GitHub. The GitHub README provides installation and execution instructions for different platforms.

To use the Draco command-line tools on Mac OS, I did the following:

  1. Clone the Draco repository
  2. Create a new directory and cd into it
  3. Run cmake path/to/local/draco-repository
  4. Run make

Note: I installed cmake on my Mac via Homebrew (brew install cmake).

After running make, you should have draco_encoder and draco_decoder binaries that you can run from your shell.

Using Draco

Draco supports compressing OBJ and PLY files. If your 3D model files are in a different format, you’ll have to convert them before using Draco.

You can compress an input file via:

./draco_encoder -i myfile.ply -o myfile.drc

The above will generate a compressed myfile.drc.

To decompress, simply run:

./draco_decoder -i myfile.drc -o myfile.drc.ply

Compression: Lossy vs. Lossless

Draco compression can be both lossy or lossless, depending on the input file and compression settings.

Note: Under the hood, it seems that Draco switches between the lossy, but efficient, Edgebreaker algorithm and a different compression algorithm, depending on how it is run.

There are a few notable command-line options that control how the input file is compressed.

One option is the compression level. This level can be set via the cl command-line flag (e.g., -cl 8). It can can vary from 0 to 10, but the default is 7. Draco’s documentation states that the compression level turns on/off different compression features, but it doesn’t go into detail about what features this includes, or when they are turned on/off.

Another knob you can control is something called the quantization parameter. It can be controlled via the qp flag (e.g., -qp 14). The specified value is the number of bits that Draco will use to quantize different attributes. A value of 0 will not perform any quantization. The default value is 14.

The Draco docs state:

In general, the more you quantize your attributes the better compression rate you will get. It is up to your project to decide how much deviation it will tolerate. In general, most projects can set quantization values of about 14 without any noticeable difference in quality.

Compression Experiment

To give an idea of how well Draco can compress files, let’s look at few examples. I downloaded two 3D model files from the Stanford 3D Scanning Repository.

Stanford Bunny:

Dragon:

The below table summarizes the compression observed when compressing these models using the default Draco encoder settings.

Model File Size Compressed Size Compression %
Bunny 3 MB 82 KB 72.6 %
Dragon 33.8 MB 1.1 MB 96.7 %

Both models were quite compressible–especially the Dragon model.

Anecdotally, I’ve found that most files that are at least tens of MBs are able to be compressed to around 5% of the original file size. Files that are smaller (few MBs) tend to do a bit worse.

Additional Integrations

In addition to the command-line tools, Draco also supports some nice browser integrations. Specifically, three.js supports reading and rendering Draco (.drc) files.

Beyond command-line applications, the Draco encoder and decoder can both be run via JavaScript and C++.