vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
467 stars 75 forks source link

JOINTS accessor is out of bounds #77

Closed thatcosmonaut closed 3 years ago

thatcosmonaut commented 3 years ago

Hello! I am getting the following error when attempting to read a GLB file.

SharpGLTF.Validation.DataException: Accessor[144] JOINTS_0[0]: Is out of bounds
  at SharpGLTF.IO.ReadContext.ReadBinarySchema2 (System.IO.Stream stream) [0x00045] in <2604b81fb4d7409a98ebfff5b19a7e40>:0 
  at SharpGLTF.Schema2.ModelRoot.ReadGLB (System.IO.Stream stream, SharpGLTF.Schema2.ReadSettings settings) [0x0004f] in <2604b81fb4d7409a98ebfff5b19a7e40>:0 
  at Smuggler.Importer.ImportGLB (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) [0x00001] in <468cbeb6b89a408ea8723613fcdaca02>:0 
  at KavTest.KavTestGame.Initialize () [0x0017b] in <86cf0bdce5234e4aaf78bd11991dd38d>:0 
  at Microsoft.Xna.Framework.Game.DoInitialize () [0x00043] in <740948356cf449859ccdaa1448dcdbe0>:0 
  at Microsoft.Xna.Framework.Game.Run () [0x00016] in <740948356cf449859ccdaa1448dcdbe0>:0 
  at KavTest.Program.Main (System.String[] args) [0x00078] in <86cf0bdce5234e4aaf78bd11991dd38d>:0 

The official Khronos GLB validator lists the file as valid. Attached is the offending file: ToonShadeRuins.glb.zip

vpenades commented 3 years ago

The error seems to be produced by a mesh that has vertices with Joint+Weight attributes, but the mesh is attached to a node that it does not have any Skin object.

Theoretically, if you add Joint+Weights to a mesh, is because you're going to use a Skin... I've just read the gltf specification, and they seem to treat this issue as a warning, not as an error, which is odd.

Anyway, I'll lower the validation strictness to treat is as a warning, so it will be aligned to the official spec.

In the meantime, I would suggest you to either add a Skin to the Node that contains the mesh with vertex skinning attributes... or remove the attributes altogether

thatcosmonaut commented 3 years ago

Makes sense to me, thank you!