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

Object transforms look off after using Instance #1509

Closed
Kyozon opened this issue Sep 24, 2024 · 6 comments · Fixed by #1511 or #1522
Closed

Object transforms look off after using Instance #1509

Kyozon opened this issue Sep 24, 2024 · 6 comments · Fixed by #1511 or #1522
Labels
bug Something isn't working

Comments

@Kyozon
Copy link

Kyozon commented Sep 24, 2024

Describe the bug
The resulting .gltf scene looks off when using the gltf-transform instance.

To Reproduce
Steps to reproduce the behavior:

  1. Download: merged.zip

  2. Import merged.gltf into Blender and verify original transforms as seen in the image below:

Default

  1. Use gltf-transform instance merged.gltf instanced.gltf

  2. Import instanced.gltf into Blender and verify the bug as seen in the image below:

Instance

Expected behavior
Retain the original transforms but optimize the scene to use GPU instances.

Versions:

  • Version: 4.0.8
  • Environment: Node.js CLI
@Kyozon Kyozon added the bug Something isn't working label Sep 24, 2024
@donmccurdy
Copy link
Owner

Hi @Kyozon! The instanced scene looks correct to me, both in Blender and in https://gltf-viewer.donmccurdy.com/. Could you confirm if you're seeing the problem both in Blender and in my viewer, and perhaps share the 'broken' copy of the model as well?

CleanShot 2024-09-24 at 16 40 19@2x

@Kyozon
Copy link
Author

Kyozon commented Sep 24, 2024

Hi @donmccurdy. Thank you for the quick reply!

Sure, here is the broken file: Instanced.zip

My filed failed to open in your viewer, here is the error message:

Validation

@donmccurdy
Copy link
Owner

donmccurdy commented Sep 24, 2024

Hm... something is weird in the source file:

  "buffers": [
    {
      "uri": "glTF.bin",
      "byteLength": 8160
    },
    {
      "uri": "glTF.bin",
      "byteLength": 8160
    },
    {
      "uri": "glTF.bin",
      "byteLength": 8160
    }
  ],

Three buffers, all pointing at the same thing... I'm not sure whether it's technically valid in the glTF spec, but the pygltflib authors probably didn't intend that, and it's leading to data loss here.

I'll have to think a bit about the best way to handle it, but in the meantime, you can avoid the issue by writing to .glb instead of .gltf:

gltf-transform instance merged.gltf instanced.glb

@donmccurdy
Copy link
Owner

Fixed in #1511. With these changes glTF Transform will log a warning (Duplicate resource URI, "glTF.bin") but will continue to process the file. When writing to .gltf, the additional buffers will be written as separate files with unique names. In this case:

  • merged.gltf
  • merged_1.bin
  • merged_2.bin
  • glTF.bin

To consolidate the binary data and avoid extra files, either write to .glb or use the unpartition() function.

instanced 3D letters, no bugs

@donmccurdy
Copy link
Owner

donmccurdy commented Sep 30, 2024

Reverting #1511 in 84e77f5 and reopening the issue. Original approach to fixing the issue will cause other problems.

@donmccurdy
Copy link
Owner

New attempted change in #1522. Unfortunately not a "fix", but will throw a clear error if conflicting buffer URIs are going to break the file. To workaround it will still be necessary to write to .glb or use the unpartition() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants