GlTF2 Accessor unit length

Viewed 2061

I am currently trying to export 3D geometry to GlTF and I come across an error I don't understand. In a file describing a simple grey cube, I get this on the normals accessor:

[glTF Validator] Accessor element at index 2 is not of unit length: 0.
[glTF Validator] Accessor element at index 5 is not of unit length: 0.
[glTF Validator] Accessor element at index 8 is not of unit length: 0.
[glTF Validator] Accessor element at index 11 is not of unit length: 0.
[glTF Validator] Accessor element at index 14 is not of unit length: 0.
[glTF Validator] Accessor element at index 17 is not of unit length: 0.
[glTF Validator] Accessor element at index 20 is not of unit length: 0.
[glTF Validator] Accessor element at index 23 is not of unit length: 0.

Here is the json:

{
  "accessors": [
    {
      "bufferView": 0,
      "byteOffset": 0,
      "componentType": 5123,
      "normalized": false,
      "count": 36,
      "type": "SCALAR",
      "name": "31546_indices"
    },
    {
      "bufferView": 1,
      "byteOffset": 0,
      "componentType": 5126,
      "normalized": false,
      "count": 8,
      "type": "VEC3",
      "max": [
        32.808,
        32.808,
        32.808
      ],
      "min": [
        0.0,
        0.0,
        0.0
      ],
      "name": "31546_vertices"
    },
    {
      "bufferView": 2,
      "byteOffset": 0,
      "componentType": 5126,
      "normalized": false,
      "count": 8,
      "type": "VEC3",
      "name": "31546_normals"
    },
    {
      "bufferView": 3,
      "byteOffset": 0,
      "componentType": 5126,
      "normalized": false,
      "count": 8,
      "type": "VEC3",
      "name": "31546_color"
    }
  ],
  "asset": {
    "version": "2.0"
  },
  "buffers": [
    {
      "uri": "31546.bin",
      "byteLength": 360,
      "name": "31546"
    }
  ],
  "bufferViews": [
    {
      "buffer": 0,
      "byteOffset": 0,
      "byteLength": 72,
      "name": "31546_indices"
    },
    {
      "buffer": 0,
      "byteOffset": 72,
      "byteLength": 96,
      "name": "31546_vertices"
    },
    {
      "buffer": 0,
      "byteOffset": 168,
      "byteLength": 96,
      "name": "31546_normals"
    },
    {
      "buffer": 0,
      "byteOffset": 264,
      "byteLength": 96,
      "name": "31546_color"
    }
  ],
  "meshes": [
    {
      "primitives": [
        {
          "attributes": {
            "POSITION": 1,
            "NORMAL": 2,
            "COLOR_0": 3
          },
          "indices": 0,
          "mode": 4
        }
      ],
      "name": "31546"
    }
  ],
  "nodes": [
    {
      "mesh": 0
    }
  ],
  "scene": 0,
  "scenes": [
    {
      "nodes": [
        0
      ],
      "name": "RNT_Viewport"
    }
  ]
}

I don't understand what the Validator is talking about accessors above 3 as there are only 4 accessors... To get this I used the GlTF plugin for Visual code. For the Khronos online validator, the JSON looks correct (https://github.khronos.org/glTF-Validator/), so at this point, I don't really know where is my mistake...

Thank you in advance for the insight :)

1 Answers

It's complaining here about the binary data, in the 31546.bin file referenced by your JSON. If you click one of the messages in the document problems window, it should focus the cursor on the accessor in question (and I'll go on a limb and guess that would be the accessor at index 2, named 31546_normals, as that looks like the only one that should be normalized in this model).

The actual index values reported in these messages are indexes into the data contained within this accessor. In VSCode, with the correct accessor selected, press ALT + d to decode the binary data into a text buffer, to examine it as text.

My guess as to what's happened here is that you have some zero-length normal vectors in your model. This isn't a big problem if the zero-length vectors are applied to degenerate triangles, but, that sort of thing is at best a waste of space in the bin file that could be removed, so the validator flags it with a warning.

If you're editing this model in some other tool like Blender or Maya, you might have an option to find and remove degenerate triangles, and recalculate normal vectors. This might get rid of your zero-length normals.

Related