Gltf No complete adaptation

if gltf like this:


accessors has same bufferView index,our GltfLoader.class is not adapter
And i read gdx-gltf he is correct.
GitHub - mgsx-dev/gdx-gltf: GLTF 2.0 3D format support and PBR shader implementation for LibGDX int MeshLoader.class
he si my gltf file which is export from “magic voxelvoxel.gltf

I still can not understand the issue.

Can you elaborate more about the issue?

Are you using jMonkeyEngine or LibGdx?
If you are using JME, please let us know what version are you using?

Is there an exception occurring? if so please provide the full error stack trace.

I using jMonkeyEngine (3.5.2 and [3.6.0-beta2)
It is can’t load this gltf file
is not crash but 3D model display unusual
model’s uv data is not load correct

1 Like

What is it supposed to look like?

Where did the model come from and what did you use to export it as gltf?

A common problem in “my textures don’t look right” situations is that the image was loaded upside down.

tested here: https://www.gltfeditor.com/

Vertex color issue again? Edit: No, there is an image packed in the gltf

image

If you import it to blender and add “.png” at the end of the texture name and export it to gltf from the blender, it will load fine in JME.

Edit:
My little bit of advice, do not use gltf in form of its binary format (glb), better to export it as separate files (.gltf + glb binary + textures). That seems to work best with JME.

The code paths are nearly identical and so either should work fine.

…the nice thing about gltf is that you can look inside it to spot issues.

This is not required

Oops, I actually mean gltf embeded used by OP.

https://imgur.com/oQWFgMN.png

And just in case,

Here is the original gltf (not working in JME)

{
  "accessors": [
    {
      "bufferView": 0,
      "componentType": 5125,
      "count": 6672,
      "max": [
        3210
      ],
      "min": [
        0
      ],
      "type": "SCALAR"
    },
    {
      "bufferView": 1,
      "componentType": 5126,
      "count": 3211,
      "max": [
        32.0,
        32.0,
        32.0
      ],
      "min": [
        0.0,
        0.0,
        0.0
      ],
      "type": "VEC3"
    },
    {
      "bufferView": 1,
      "byteOffset": 12,
      "componentType": 5126,
      "count": 3211,
      "max": [
        0.98828125,
        0.5
      ],
      "min": [
        0.05078125,
        0.5
      ],
      "type": "VEC2"
    }
  ],
  "asset": {
    "generator": "voxedit 0.0.24.0",
    "version": "2.0"
  },
  "bufferViews": [
    {
      "buffer": 0,
      "byteLength": 26688,
      "target": 34963
    },
    {
      "buffer": 0,
      "byteLength": 64220,
      "byteOffset": 26688,
      "byteStride": 20,
      "target": 34962
    }
  ],
  "buffers": [
    {
      "byteLength": 90908,
      "uri": "data:application/octet-stream;base64,SAsAANgKAABHCwAASAsAAEcLAABJCwAA1woAAIEKAADa...=="
    }
  ],
  "images": [
    {
      "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAABCAYAAAAxWXB3AAAEDElEQVR4XgEB...=="
    }
  ],
  "materials": [
    {
      "name": "12212233864816749743",
      "pbrMetallicRoughness": {
        "baseColorTexture": {
          "index": 0
        },
        "metallicFactor": 0.0
      }
    }
  ],
  "meshes": [
    {
      "name": "unnamed",
      "primitives": [
        {
          "attributes": {
            "POSITION": 1,
            "TEXCOORD_0": 2
          },
          "indices": 0,
          "material": 0,
          "mode": 4
        }
      ]
    }
  ],
  "nodes": [
    {
      "children": [
        1
      ],
      "matrix": [
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0
      ],
      "name": "root"
    },
    {
      "matrix": [
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0
      ],
      "mesh": 0,
      "name": "unnamed"
    }
  ],
  "scenes": [
    {
      "nodes": [
        0
      ]
    }
  ],
  "textures": [
    {
      "source": 0
    }
  ]
}

And this is the one I exported from blender (works fine in JME)

{
    "asset" : {
        "generator" : "Khronos glTF Blender I/O v1.7.33",
        "version" : "2.0"
    },
    "scene" : 0,
    "scenes" : [
        {
            "name" : "Scene",
            "nodes" : [
                1
            ]
        }
    ],
    "nodes" : [
        {
            "mesh" : 0,
            "name" : "unnamed"
        },
        {
            "children" : [
                0
            ],
            "name" : "root"
        }
    ],
    "materials" : [
        {
            "name" : "12212233864816749743",
            "pbrMetallicRoughness" : {
                "baseColorTexture" : {
                    "index" : 0
                },
                "metallicFactor" : 0
            }
        }
    ],
    "meshes" : [
        {
            "name" : "unnamed",
            "primitives" : [
                {
                    "attributes" : {
                        "POSITION" : 0,
                        "NORMAL" : 1,
                        "TEXCOORD_0" : 2
                    },
                    "indices" : 3,
                    "material" : 0
                }
            ]
        }
    ],
    "textures" : [
        {
            "sampler" : 0,
            "source" : 0
        }
    ],
    "images" : [
        {
            "bufferView" : 4,
            "mimeType" : "image/png",
            "name" : "Image_0"
        }
    ],
    "accessors" : [
        {
            "bufferView" : 0,
            "componentType" : 5126,
            "count" : 4083,
            "max" : [
                32,
                32,
                32
            ],
            "min" : [
                0,
                0,
                0
            ],
            "type" : "VEC3"
        },
        {
            "bufferView" : 1,
            "componentType" : 5126,
            "count" : 4083,
            "type" : "VEC3"
        },
        {
            "bufferView" : 2,
            "componentType" : 5126,
            "count" : 4083,
            "type" : "VEC2"
        },
        {
            "bufferView" : 3,
            "componentType" : 5123,
            "count" : 6672,
            "type" : "SCALAR"
        }
    ],
    "bufferViews" : [
        {
            "buffer" : 0,
            "byteLength" : 48996,
            "byteOffset" : 0
        },
        {
            "buffer" : 0,
            "byteLength" : 48996,
            "byteOffset" : 48996
        },
        {
            "buffer" : 0,
            "byteLength" : 32664,
            "byteOffset" : 97992
        },
        {
            "buffer" : 0,
            "byteLength" : 13344,
            "byteOffset" : 130656
        },
        {
            "buffer" : 0,
            "byteLength" : 1093,
            "byteOffset" : 144000
        }
    ],
    "samplers" : [
        {
            "magFilter" : 9729,
            "minFilter" : 9987
        }
    ],
    "buffers" : [
        {
            "byteLength" : 145096,
            "uri" : "data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgD8AAIA...=="
        }
    ]
}

Note, I trimmed base64 data in uri to be able to upload them here.

Edit:

Notice the difference in "images"

By the way, I do not see any error or warning log with the non-working gltf, it just loads in black for me.

Here is how the working one looks like

Further investigating the model, I found out the original model has no normals which is why it is rendered black in JME. Checked it both on JME side and in an online gltf viewer.

I tried to generate normals at runtime using @sgold Heart library

but I got this error

java.lang.IllegalArgumentException: Must have not have an index buffer.

it requires mesh to not have an index buffer.

2 Likes

You should be able to eliminate the index buffer using MyMesh.expand().

1 Like
Mesh expand = MyMesh.expand(geom.getMesh());
geom.setMesh(expand);
MyMesh.generateFacetNormals(expand, VertexBuffer.Type.Normal, VertexBuffer.Type.Position);

Unfortunately, the result is not correct!

1 Like

I tried to render it with unshaded material which does not require normals

Material unshaded = new Material(assetManager, Materials.UNSHADED);
Material pbr = geom.getMaterial();
unshaded.setTexture("ColorMap", pbr.getParamValue("BaseColorMap"));
geom.setMaterial(unshaded);

looks like the buffers are corrupted

1 Like

This looks to me like an issue with texture coordinates. expand() and generateFacetNormals() are supposed to handle texture coordinates, but perhaps there’s a bug. Might be related to the texture image being one-dimensional…

1 Like

Note, this is not an issue in the Heart library. I guess this is a bug in GltfLoader.

See

3 Likes