How to Load Draco-Compressed GLTFs in glTFast

So, I’ve had luck with the Unity glTFast package, loading some assets I’m pulling from a CMS. However, once I started compressing those assets (using GLTFPack to apply Draco for geometry and converting textures to KTX), I’ve hit problems.

I see that “Draco for Unity” and “KTX for Unity” are both available and have installed them as per the docs. KTX for Unity says it only needs to be installed and glTFast will use it. Okay, I hope that’s true :slight_smile:

As for Draco for Unity, it says the following:

The Unity glTFast package provides support for loading, importing and exporting glTF in Unity and utilizes Draco for Unity to gain Draco compression support. You have to install recent versions of both packages to unlock that feature. See the package’s documentation to learn how to create and load Draco compressed glTF files.

Well, that documentation does mention Draco support, but does not, as far as I can tell, detail how to use it within the context of glTFast… I’m notoriously unobservant so please forgive me if I’m missing the obvious, but I did look :stuck_out_tongue:

My current loading code looks like this:


// where 'data' is a byte array obtained via our CMS's API

var gltf = new GltfImport();
    
bool success = await gltf.LoadGltfBinary(data, new Uri("file:///dummyUri"));

(Note that I have to pass a fake URI to the function here because we don’t have the data on a local filesystem, nor is it loaded from a URL.)

This is where it succeeds on uncompressed GLTFs but fails on my optimised data. No error is logged — the function above just returns false. I do not actually know if the issue is Draco, or KTX or something else.

The Draco for Unity docs detail how to load a Mesh object from compressed data directly, but I’m hesitant to go down that road, as we require the many other features glTFast’s importer offers (material variant setup, etc.)

Is there something I’m missing here that would make glTFast use Draco for Unity under the hood? Is it supposed to do so automatically? Is there some way I can debug where the loading is going wrong here?

Any suggestions much appreciated! :slight_smile:

Unity macOS silicon 6000.0.25f1
Unity glTFast 6.9.0
Draco for Unity 5.1.8
KTX for Unity 3.4.5

Turns out that my problem was that I did not have ‘com.unity.meshopt.decompress’ also installed! GLTFPack was adding the ‘EXT_meshopt_compression’ extension as a requirement without me realising :person_facepalming:

So, some feedback:

  • Would be very nice to see com.unity.meshopt.decompress move out of preview.
  • For twits like me, surfacing some errors on this package missing when the EXT_meshopt_compression extension is detected would be very nice, rather than just failing. I had to step through with the debugger to catch this.
1 Like

com.unity.cloud.draco needs for com.unity.cloud.gltfast
com.unity.meshopt.decompress not needed
Unity 6000.0

1 Like