GlTF2 存取单元长度
GlTF2 Accessor unit length
我目前正在尝试将 3D 几何图形导出到 GlTF,但我遇到了一个我不明白的错误。在描述一个简单的灰色立方体的文件中,我在法线访问器上得到了这个:
[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.
这里是 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"
}
]
}
我不明白验证器在谈论 3 个以上的访问器是什么,因为只有 4 个访问器...为此,我使用了可视化代码的 GlTF 插件。对于 Khronos 在线验证器,JSON 看起来是正确的 (https://github.khronos.org/glTF-Validator/),所以在这一点上,我真的不知道我的错误在哪里...
提前感谢您的见解:)
它在这里抱怨二进制数据,在您的 JSON 引用的 31546.bin
文件中。如果您单击文档问题 window 中的其中一条消息,它应该将光标聚焦在有问题的访问器上(我会继续猜测它是索引 2 处的访问器,名为 31546_normals
,因为这看起来是该模型中唯一应该归一化的。
这些消息中报告的实际索引值是此访问器中包含的数据的索引。在 VSCode 中,选择正确的访问器,按 ALT + d 将二进制数据解码到文本缓冲区中,以检查它作为文本。
我对这里发生的事情的猜测是你的模型中有一些零长度的法向量。如果将零长度向量应用于退化三角形,这不是一个大问题,但是,这种事情充其量只是浪费 bin 文件中可以删除的 space,因此验证器将其标记带有警告。
如果您在 Blender 或 Maya 等其他工具中编辑此模型,您可能可以选择查找和移除退化三角形,并重新计算法向量。这可能会摆脱你的零长度法线。
我目前正在尝试将 3D 几何图形导出到 GlTF,但我遇到了一个我不明白的错误。在描述一个简单的灰色立方体的文件中,我在法线访问器上得到了这个:
[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.
这里是 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"
}
]
}
我不明白验证器在谈论 3 个以上的访问器是什么,因为只有 4 个访问器...为此,我使用了可视化代码的 GlTF 插件。对于 Khronos 在线验证器,JSON 看起来是正确的 (https://github.khronos.org/glTF-Validator/),所以在这一点上,我真的不知道我的错误在哪里...
提前感谢您的见解:)
它在这里抱怨二进制数据,在您的 JSON 引用的 31546.bin
文件中。如果您单击文档问题 window 中的其中一条消息,它应该将光标聚焦在有问题的访问器上(我会继续猜测它是索引 2 处的访问器,名为 31546_normals
,因为这看起来是该模型中唯一应该归一化的。
这些消息中报告的实际索引值是此访问器中包含的数据的索引。在 VSCode 中,选择正确的访问器,按 ALT + d 将二进制数据解码到文本缓冲区中,以检查它作为文本。
我对这里发生的事情的猜测是你的模型中有一些零长度的法向量。如果将零长度向量应用于退化三角形,这不是一个大问题,但是,这种事情充其量只是浪费 bin 文件中可以删除的 space,因此验证器将其标记带有警告。
如果您在 Blender 或 Maya 等其他工具中编辑此模型,您可能可以选择查找和移除退化三角形,并重新计算法向量。这可能会摆脱你的零长度法线。