donmccurdy / glTF-Transform

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

Draco compression issue #1215

Closed marwie closed 6 months ago

marwie commented 11 months ago

Describe the bug Hello, it seems like with draco compression the UV coordinates (?) get lost for one particular model

To Reproduce Steps to reproduce the behavior:

  1. Open zip
  2. See LiamA without compression
  3. Inspect LiamA-draco - see that the texture is not correctly displayed on the character
  4. run gltf-transform draco LiamA.glb LiamA-draco.glb to repro

Expected behavior Character looks the same with draco compression aplied

Versions:

Additional context

draco-issue.zip

original and expected: image

after draco: image

image

after meshopt: image

donmccurdy commented 11 months ago

Pulling the UV islands up in Blender, note the long tail off to the right:

UV islands in Blender extending far outside 0-1 range

In short, some UVs are wild outliers, and any quantization implementation (in this case it's Draco's quantization, but my own cannot do better) will end up sacrificing quality with a larger quantization grid on the assumption that these UVs are important.

Same cause:


I'm curious why this happens... is it one particular DCC tool? Perhaps it's common enough that it's worth scanning for, though. The process could be something like:

  1. iterate over all UVs, record counts in three buckets:
    • number of UVs inside [0,1]
    • number of UVs inside [-24,+24]
    • number of UVs outside [-24,+24]
  2. if the last bucket contains a trivial number of vertices compared to the first two, bring these UVs back inside a smaller range; this would require checking texture samplers, and finding an 'equivalent' UV coordinate
  3. log a warning so users know their input data is a bit troubled

Does this sound reasonable to you? The 24 threshold is arbitrary of course, it could be anything — I just don't want to trigger this code path for intentionally repeating UVs.

marwie commented 11 months ago

Thank you very much for looking into this - I've forwarded the question about the tool to our user and also how to fix the issue. I'll let you know when I get more information.