donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.3k stars 145 forks source link

Some text nodes are not visible after using draco compression #1266

Closed TiagoCastilhos closed 4 months ago

TiagoCastilhos commented 4 months ago

Describe the bug Some texts are disappearing from the object after using draco to compress them. Here's an image comparing the original glb file (left) and the compressed glb file (right):

image

I've used babylon's sandbox to compare materials and nodes. The node that's representing this text is "oven_prof30sextmain_text007", and it's visible if I use the "Render wireframe over mesh" debug option. The material applied to this node is the same as the original, the only difference I could identify is the number of vertices.

image

To Reproduce Steps to reproduce the behavior:

  1. Download the zip file with the original and compressed glbs
  2. Open those files in a GLB inspector
  3. See the difference between the original and compressed objects

Expected behavior Objects should look the same

Versions:

Additional context There are more objects with this same issue, let me know if they're needed to investigate.

donmccurdy commented 4 months ago

Hi @TiagoCastilhos! Draco (and many other compression methods) use a quantization grid as part of the compression process. Practically that means each vertex is snapped to an NxNxN grid, where N is 2^bits for some bit depth.

By default in glTF Transform that grid is per-mesh, so either of two things will avoid the issue:

  1. Divide the text into smaller meshes, particularly separating the left and right dials
  2. Use a higher precision grid

The second option is easier and seems to work well here:

gltf-transform draco original_oven.glb draco_compressed_oven_p16.glb --quantize-position 16

draco_compressed_oven_p16.glb.zip

TiagoCastilhos commented 4 months ago

@donmccurdy Thanks for the reply, I've just tested and it seems fine. Thank you so much!