Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when compressing glTF model with DRACO compression #369

Closed
FarhadG opened this issue May 4, 2018 · 7 comments
Closed

Error when compressing glTF model with DRACO compression #369

FarhadG opened this issue May 4, 2018 · 7 comments

Comments

@FarhadG
Copy link

FarhadG commented May 4, 2018

I've been researching on how to compress a multi-texture OBJ with DRACO to be able to render in THREE.js. Anyways, after some discussions in this thread, I was advised to convert the OBJ to glTF and then leverage the V2 branch here to compress the glTF with DRACO compression.

Here are my steps:

  1. Generated a 3D OBJ model with OpenDroneMap. You can download a model with WebODM
  2. Converted the multi-texture OBJ to glTF via https://github.com/AnalyticalGraphicsInc/obj2gltf
  3. Tried to compress the new glTF via v2 branch and got the following error:
$ node ./gltf-pipeline/bin/gltf-pipeline.js -i odm/odm_textured_model.gltf  -d --stats

Statistics before:
Total byte length of all buffers: 60397176 bytes
Images: 4
Draw calls: 4
Rendered primitives (e.g., triangles): 193353
Nodes: 1
Meshes: 1
Materials: 4
Animations: 0
External requests (not data uris): 0
1
1
abort(1). Build with -s ASSERTIONS=1 for more info.

Thank you for your help and assistance.

@FarhadG FarhadG changed the title Unable to compress glTF model with DRACO compression Error when compressing glTF model with DRACO compression May 4, 2018
@lilleyse
Copy link
Contributor

lilleyse commented May 4, 2018

Thanks @FarhadG

It seems like this is an error from within the draco library. @FrankGalligan would you be to take a look at this? I uploaded the gltf here: https://drive.google.com/open?id=1u8oSGfsDpPTxD41MuJusbPahI126t9qC.

If it helps with debugging, primitive at index 3 is failing at EncodeMeshToDracoBuffer. Also the model converts correctly if MESH_SEQUENTIAL_ENCODING is applied.

This also reveals a secondary issue where mesh data is encoded multiple times when primitives share the same attributes but have different indices. I might have a chance later to look into that. For example the original glTF looks like:

        {
          "attributes": {
            "POSITION": 0,
            "NORMAL": 1,
            "TEXCOORD_0": 2
          },
          "indices": 5,
          "material": 2,
          "mode": 4
        },
        {
          "attributes": {
            "POSITION": 0,
            "NORMAL": 1,
            "TEXCOORD_0": 2
          },
          "indices": 6,
          "material": 3,
          "mode": 4
        },

Possibly relevant: KhronosGroup/glTF#1267

@lilleyse
Copy link
Contributor

lilleyse commented May 5, 2018

Fixed the secondary issue in 734f85d by adding a stage that splits primitives that share the same attributes but have different indices. This unintentionally fixed the draco crash too. The model now converts correctly.

@FarhadG
Copy link
Author

FarhadG commented May 6, 2018

Thank you, @lilleyse! It works like a charm. Do we have an idea of when v2 will be stable and merged into master?

@lilleyse
Copy link
Contributor

lilleyse commented May 7, 2018

The last two things it needs are tests for compressDracoMeshes and a couple other files, and support for KHR_techniques_webgl so that we can upgrade from 1.0 to 2.0 properly.

There's been a lot of momentum lately so I'm hopeful it will be soon!

@FarhadG
Copy link
Author

FarhadG commented May 8, 2018

That's awesome, @lilleyse. Another question: I understand that Draco offers other functionality in their compression than what I see outlined in the V2 branch. Will those be available soon? For example, the metadata and being able to omit certain data.

@lilleyse
Copy link
Contributor

lilleyse commented May 8, 2018

It's unclear to me how the metadata fits into the glTF extension, and how it should be accessed by engines. In glTF metadata usually goes in the extras properties. Maybe the Draco metadata is designed for standalone draco files not already contained in a glTF?

To keep it simple I think the draco encoding should be all or nothing, since it might get complicated to describe which primitives/attributes should be omitted. Though if you want to avoid compressing a certain type of attribute you can set its quantization bits to 0 - for example --draco.quantizePosition=0.

@DimitarMitrov
Copy link

@FarhadG You noted that you use "multi-texture OBJ". Does it mean that you use - multiple meshes with different materials/textures? Because that is what I am trying to achieve, without success so far, and in obj2gltf documentation is stated that multiple materials are not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants