diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs index f3b65e5f0..fac86a104 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs @@ -34,6 +34,10 @@ namespace UniGLTF var normals = mesh.normals; var uv = mesh.uv; var boneWeights = mesh.boneWeights; + if (boneWeights.All(x => x.weight0 == 0 && x.weight1 == 0 && x.weight2 == 0 && x.weight3 == 0)) + { + boneWeights = null; + } var colors = mesh.colors; Func getJointIndex = null; diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs index e1885be1f..6da415fcd 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs @@ -57,15 +57,23 @@ namespace UniGLTF colorAccessorIndex = data.ExtendBufferAndGetAccessorIndex(mesh.colors, glBufferTarget.ARRAY_BUFFER); } - var boneweights = mesh.boneWeights; - var weightAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneweights.Select(y => new Vector4(y.weight0, y.weight1, y.weight2, y.weight3)).ToArray(), glBufferTarget.ARRAY_BUFFER); - var jointsAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneweights.Select(y => - new UShort4( - (ushort)unityMesh.GetJointIndex(y.boneIndex0), - (ushort)unityMesh.GetJointIndex(y.boneIndex1), - (ushort)unityMesh.GetJointIndex(y.boneIndex2), - (ushort)unityMesh.GetJointIndex(y.boneIndex3)) - ).ToArray(), glBufferTarget.ARRAY_BUFFER); + var boneWeights = mesh.boneWeights; + var weightAccessorIndex = -1; + var jointsAccessorIndex = -1; + if (boneWeights.All(x => x.weight0 == 0 && x.weight1 == 0 && x.weight2 == 0 && x.weight3 == 0)) + { + } + else + { + weightAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneWeights.Select(y => new Vector4(y.weight0, y.weight1, y.weight2, y.weight3)).ToArray(), glBufferTarget.ARRAY_BUFFER); + jointsAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneWeights.Select(y => + new UShort4( + (ushort)unityMesh.GetJointIndex(y.boneIndex0), + (ushort)unityMesh.GetJointIndex(y.boneIndex1), + (ushort)unityMesh.GetJointIndex(y.boneIndex2), + (ushort)unityMesh.GetJointIndex(y.boneIndex3)) + ).ToArray(), glBufferTarget.ARRAY_BUFFER); + } var attributes = new glTFAttributes {