defold / defold

Defold is a completely free to use game engine for development of desktop, mobile and web games.
https://www.defold.com
Other
3.74k stars 271 forks source link

Some gltf files not loading properly #8890

Closed dlannan closed 1 week ago

dlannan commented 1 week ago

Recently upgraded from v1.7.0 to v.1.8.0 and since then Ive had some issues importing some gltf files. I tried importing them from my Defender exporter (from Blender) and then attempted plain gtlf export from Blender with the same results for some files.

I have attached a sample failed file. This file loads back into Blender correctly. It seems to be fine.

A clear and concise description of what the bug is.

Steps to reproduce the behavior:

  1. Extract the zip into a Defold project
  2. In the open project in the Defold editor. Click on the go or the gltf file and it should be visible.
  3. An error shows on the screen: `Render error: Unknown: Failed to produce vertex buffers from mesh set. The scene might contain invalid data.

Expected behaviour: The gltf model is visible in the editor

Example broken gltf guns.zip

Screenshot of error when attempting load: image

dlannan commented 1 week ago

After some quick checks. I think it is the parsing of the texture units in the mesh sections. I manually removed extra texture references and it fixed it. From originally this:

    "meshes" : [
        {
            "name" : "handgun_02",
            "primitives" : [
                {
                    "attributes" : {
                        "POSITION" : 0,
                        "TEXCOORD_0" : 1,
                        "TEXCOORD_1" : 2,
                        "NORMAL" : 3
                    },
                    "indices" : 4,
                    "material" : 0
                }
            ]
        }
    ],

To this:

    "meshes" : [
        {
            "name" : "handgun_02",
            "primitives" : [
                {
                    "attributes" : {
                        "POSITION" : 0,
                        "TEXCOORD_0" : 1,
                        "NORMAL" : 3
                    },
                    "indices" : 4,
                    "material" : 0
                }
            ]
        }
    ],

And it works/looks ok (geometry wise). I think this used to be handled with adding a new image slot in a material? But I might be wrong here. Not sure.

dlannan commented 1 week ago

Thanks to Jhonny's help, it was identified that this is caused by having unused uv maps on the Blender side. I can certainly update my exporter to detect this (and stop it from exporting them) so I feel this is more a data source problem. Maybe some way to log this error would be great, but I suspect there may be problems detecting this (not sure).

Thanks to everyone for you help. Very happy I can move forward.

dlannan commented 1 week ago

Going to close this, since I dont think it is really a Defold issue. Please reopen if not.