From ce4d393013567caa776f321d452d17dd4d296b96 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 30 Mar 2021 17:41:28 +0900 Subject: [PATCH] Submesh.Material to int --- Assets/VRM10/Runtime/IO/MeshAdapter.cs | 13 +- Assets/VRM10/Runtime/IO/ModelLoader.cs | 2 +- Assets/VRM10/Runtime/IO/Vrm10Exporter.cs | 2 +- .../Runtime/IO/Vrm10ExporterExtensions.cs | 5 - Assets/VRM10/Runtime/IO/Vrm10Storage.cs | 4 +- .../Runtime/UnityBuilder/ComponentBuilder.cs | 51 --- Assets/VRM10/Runtime/UnityBuilder/ModelMap.cs | 2 - .../UnityBuilder/RuntimeUnityBuilder.cs | 10 +- .../VRMConverter/RuntimeVrmConverter.cs | 145 +------ Assets/VRM10/Tests.PlayMode/MaterialTests.cs | 364 +++++++++--------- .../VRM10.Tests.PlayMode.asmdef | 3 +- .../Runtime/Humanoid/SkeletonMeshUtility.cs | 48 +-- Assets/VRM10/vrmlib/Runtime/Mesh.cs | 8 +- Assets/VRM10/vrmlib/Runtime/MeshExtensions.cs | 2 +- Assets/VRM10/vrmlib/Runtime/MeshFactory.cs | 28 -- .../VRM10/vrmlib/Runtime/MeshFactory.cs.meta | 11 - Assets/VRM10/vrmlib/Runtime/Model.cs | 18 +- .../VRM10/vrmlib/Runtime/ModelExtensions.cs | 3 - 18 files changed, 219 insertions(+), 500 deletions(-) delete mode 100644 Assets/VRM10/vrmlib/Runtime/MeshFactory.cs delete mode 100644 Assets/VRM10/vrmlib/Runtime/MeshFactory.cs.meta diff --git a/Assets/VRM10/Runtime/IO/MeshAdapter.cs b/Assets/VRM10/Runtime/IO/MeshAdapter.cs index 23f3eab66..c19ead466 100644 --- a/Assets/VRM10/Runtime/IO/MeshAdapter.cs +++ b/Assets/VRM10/Runtime/IO/MeshAdapter.cs @@ -164,8 +164,7 @@ namespace UniVRM10 return true; } - public static MeshGroup FromGltf(this glTFMesh x, - Vrm10Storage storage, List materials) + public static MeshGroup FromGltf(this glTFMesh x, Vrm10Storage storage) { var group = new MeshGroup(x.name); @@ -176,7 +175,7 @@ namespace UniVRM10 var materialIndex = primitive.material; mesh.Submeshes.Add( - new Submesh(0, mesh.IndexBuffer.Count, materials[materialIndex])); + new Submesh(0, mesh.IndexBuffer.Count, materialIndex)); group.Meshes.Add(mesh); } @@ -189,7 +188,7 @@ namespace UniVRM10 var materialIndex = primitive.material; mesh.Submeshes.Add( - new Submesh(offset, mesh.IndexBuffer.Count, materials[materialIndex])); + new Submesh(offset, mesh.IndexBuffer.Count, materialIndex)); offset += mesh.IndexBuffer.Count; group.Meshes.Add(mesh); @@ -206,7 +205,7 @@ namespace UniVRM10 var materialIndex = primitive.material; var count = storage.Gltf.accessors[primitive.indices].count; mesh.Submeshes.Add( - new Submesh(offset, count, materials[materialIndex])); + new Submesh(offset, count, materialIndex)); offset += count; } @@ -258,7 +257,7 @@ namespace UniVRM10 } } - static void ExportMesh(this Mesh mesh, List materials, Vrm10Storage storage, glTFMesh gltfMesh, ExportArgs option) + static void ExportMesh(this Mesh mesh, List materials, Vrm10Storage storage, glTFMesh gltfMesh, ExportArgs option) { // // primitive share vertex buffer @@ -383,7 +382,7 @@ namespace UniVRM10 } } - public static glTFMesh ExportMeshGroup(this MeshGroup src, List materials, Vrm10Storage storage, ExportArgs option) + public static glTFMesh ExportMeshGroup(this MeshGroup src, List materials, Vrm10Storage storage, ExportArgs option) { var mesh = new glTFMesh { diff --git a/Assets/VRM10/Runtime/IO/ModelLoader.cs b/Assets/VRM10/Runtime/IO/ModelLoader.cs index 271be9fbe..0c283ed05 100644 --- a/Assets/VRM10/Runtime/IO/ModelLoader.cs +++ b/Assets/VRM10/Runtime/IO/ModelLoader.cs @@ -49,7 +49,7 @@ namespace UniVRM10 model.Skins.AddRange(Enumerable.Range(0, storage.SkinCount).Select(x => storage.CreateSkin(x, model.Nodes))); // mesh - model.MeshGroups.AddRange(Enumerable.Range(0, storage.MeshCount).Select(x => storage.CreateMesh(x, model.Materials))); + model.MeshGroups.AddRange(Enumerable.Range(0, storage.MeshCount).Select(x => storage.CreateMesh(x))); // skin for (int i = 0; i < storage.NodeCount; ++i) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index 7e8f454e7..2de6c1ae7 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -58,7 +58,7 @@ namespace UniVRM10 Storage.Reserve(bytesLength); } - public void ExportMeshes(List groups, List materials, ExportArgs option) + public void ExportMeshes(List groups, List materials, ExportArgs option) { foreach (var group in groups) { diff --git a/Assets/VRM10/Runtime/IO/Vrm10ExporterExtensions.cs b/Assets/VRM10/Runtime/IO/Vrm10ExporterExtensions.cs index f63fff96f..b16c742ac 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10ExporterExtensions.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10ExporterExtensions.cs @@ -15,11 +15,6 @@ namespace UniVRM10 /// { var reserveBytes = 0; - // image - foreach (var image in m.Images) - { - reserveBytes += image.Bytes.Count; - } // mesh foreach (var g in m.MeshGroups) { diff --git a/Assets/VRM10/Runtime/IO/Vrm10Storage.cs b/Assets/VRM10/Runtime/IO/Vrm10Storage.cs index 2745d5f44..cf055abe5 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Storage.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Storage.cs @@ -439,10 +439,10 @@ namespace UniVRM10 return skin; } - public MeshGroup CreateMesh(int index, List materials) + public MeshGroup CreateMesh(int index) { var x = Gltf.meshes[index]; - var group = x.FromGltf(this, materials); + var group = x.FromGltf(this); return group; } diff --git a/Assets/VRM10/Runtime/UnityBuilder/ComponentBuilder.cs b/Assets/VRM10/Runtime/UnityBuilder/ComponentBuilder.cs index 517acf8d9..028a4f303 100644 --- a/Assets/VRM10/Runtime/UnityBuilder/ComponentBuilder.cs +++ b/Assets/VRM10/Runtime/UnityBuilder/ComponentBuilder.cs @@ -49,57 +49,6 @@ namespace UniVRM10 // VRM-1.0 では値域は [0-1.0f] return new UniVRM10.MorphTargetBinding(relativePath, names.IndexOf(bind.Name), bind.Value * 100.0f); } - - static UniVRM10.MaterialColorBinding? Build10(this VrmLib.MaterialColorBind bind, ModelMap loader) - { - var kv = bind.Property; - var value = kv.Value.ToUnityVector4(); - var material = loader.Materials[bind.Material]; - - var binding = default(UniVRM10.MaterialColorBinding?); - if (material != null) - { - try - { - binding = new UniVRM10.MaterialColorBinding - { - MaterialName = bind.Material.Name, // UniVRM-0Xの実装は名前で持っている - BindType = bind.BindType, - TargetValue = value, - // BaseValue = material.GetColor(kv.Key), - }; - } - catch (Exception) - { - // do nothing - } - } - return binding; - } - - static UniVRM10.MaterialUVBinding? Build10(this VrmLib.TextureTransformBind bind, ModelMap loader) - { - var material = loader.Materials[bind.Material]; - - var binding = default(UniVRM10.MaterialUVBinding?); - if (material != null) - { - try - { - binding = new UniVRM10.MaterialUVBinding - { - MaterialName = bind.Material.Name, // UniVRM-0Xの実装は名前で持っている - Scaling = new Vector2(bind.Scale.X, bind.Scale.Y), - Offset = new Vector2(bind.Offset.X, bind.Offset.Y), - }; - } - catch (Exception) - { - // do nothing - } - } - return binding; - } #endregion } } diff --git a/Assets/VRM10/Runtime/UnityBuilder/ModelMap.cs b/Assets/VRM10/Runtime/UnityBuilder/ModelMap.cs index 2eae00f45..c09ec5c13 100644 --- a/Assets/VRM10/Runtime/UnityBuilder/ModelMap.cs +++ b/Assets/VRM10/Runtime/UnityBuilder/ModelMap.cs @@ -6,8 +6,6 @@ namespace UniVRM10 public class ModelMap { public readonly Dictionary Nodes = new Dictionary(); - public readonly Dictionary Textures = new Dictionary(); - public readonly Dictionary Materials = new Dictionary(); public readonly Dictionary Meshes = new Dictionary(); public readonly Dictionary Renderers = new Dictionary(); } diff --git a/Assets/VRM10/Runtime/UnityBuilder/RuntimeUnityBuilder.cs b/Assets/VRM10/Runtime/UnityBuilder/RuntimeUnityBuilder.cs index 4eb3f2673..6178af94f 100644 --- a/Assets/VRM10/Runtime/UnityBuilder/RuntimeUnityBuilder.cs +++ b/Assets/VRM10/Runtime/UnityBuilder/RuntimeUnityBuilder.cs @@ -44,7 +44,6 @@ namespace UniVRM10 { var src = m_model.Materials[i]; var dst = MaterialFactory.Materials[i].Asset; - m_asset.Map.Materials.Add(src, dst); } // mesh @@ -62,7 +61,7 @@ namespace UniVRM10 Meshes.Add(new MeshWithMaterials { Mesh = mesh, - Materials = src.Meshes[0].Submeshes.Select(x => m_asset.Map.Materials[x.Material]).ToArray(), + Materials = src.Meshes[0].Submeshes.Select(x => MaterialFactory.Materials[x.Material].Asset).ToArray(), }); } else @@ -105,7 +104,7 @@ namespace UniVRM10 throw new NotImplementedException("invalid isolated vertexbuffer"); } - var renderer = CreateRenderer(node, go, map); + var renderer = CreateRenderer(node, go, map, MaterialFactory.Materials); map.Renderers.Add(node, renderer); m_asset.Renderers.Add(renderer); } @@ -163,7 +162,8 @@ namespace UniVRM10 /// /// MeshFilter + MeshRenderer もしくは SkinnedMeshRenderer を構築する /// - public static Renderer CreateRenderer(VrmLib.Node node, GameObject go, ModelMap map) + public static Renderer CreateRenderer(VrmLib.Node node, GameObject go, ModelMap map, + IReadOnlyList materialLoadInfos) { var mesh = node.MeshGroup.Meshes[0]; @@ -189,7 +189,7 @@ namespace UniVRM10 renderer = go.AddComponent(); meshFilter.sharedMesh = map.Meshes[node.MeshGroup]; } - var materials = mesh.Submeshes.Select(x => map.Materials[x.Material]).ToArray(); + var materials = mesh.Submeshes.Select(x => materialLoadInfos[x.Material].Asset).ToArray(); renderer.sharedMaterials = materials; return renderer; diff --git a/Assets/VRM10/Runtime/VRMConverter/RuntimeVrmConverter.cs b/Assets/VRM10/Runtime/VRMConverter/RuntimeVrmConverter.cs index d1631c704..a36692e96 100644 --- a/Assets/VRM10/Runtime/VRMConverter/RuntimeVrmConverter.cs +++ b/Assets/VRM10/Runtime/VRMConverter/RuntimeVrmConverter.cs @@ -14,8 +14,7 @@ namespace UniVRM10 public VrmLib.Model Model; public Dictionary Nodes = new Dictionary(); - public Dictionary Textures = new Dictionary(); - public Dictionary Materials = new Dictionary(); + public List Materials = new List(); public Dictionary Meshes = new Dictionary(); static string GetSupportedMime(string path) @@ -53,136 +52,7 @@ namespace UniVRM10 return (copy.EncodeToPNG(), "image/png"); } - public VrmLib.TextureInfo GetOrCreateTexture(UnityEngine.Material material, UnityEngine.Texture srcTexture, VrmLib.Texture.ColorSpaceTypes colorSpace, VrmLib.Texture.TextureTypes textureType) - { - var texture = srcTexture as Texture2D; - if (texture is null) - { - return null; - } - - if (!Textures.TryGetValue(texture, out VrmLib.TextureInfo info)) - { - UnityEngine.Material converter = null; - if (textureType == VrmLib.Texture.TextureTypes.NormalMap) - { - converter = TextureConvertMaterial.GetNormalMapConvertUnityToGltf(); - } - else if (textureType == VrmLib.Texture.TextureTypes.MetallicRoughness) - { - float smoothness = 0.0f; - if (material.HasProperty("_GlossMapScale")) - { - smoothness = material.GetFloat("_GlossMapScale"); - } - - converter = TextureConvertMaterial.GetMetallicRoughnessUnityToGltf(smoothness); - } - else if (textureType == VrmLib.Texture.TextureTypes.Occlusion) - { - converter = TextureConvertMaterial.GetOcclusionUnityToGltf(); - } - - var (bytes, mime) = GetImageEncodedBytes( - texture, - (colorSpace == VrmLib.Texture.ColorSpaceTypes.Linear) ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.sRGB, - converter - ); - - if (converter != null) - { - UnityEngine.Object.DestroyImmediate(converter); - } - - var sampler = new VrmLib.TextureSampler - { - MagFilter = texture.filterMode.ToVrmLibMagFilter(), - MinFilter = texture.filterMode.ToVrmLibMinFilter(), - WrapS = texture.wrapMode.ToVrmLib(), - WrapT = texture.wrapMode.ToVrmLib(), - }; - var image = new VrmLib.Image(texture.name, mime, VrmLib.ImageUsage.None, new ArraySegment(bytes)); - info = new VrmLib.TextureInfo(new VrmLib.ImageTexture(texture.name, sampler, image, colorSpace, textureType)); - Textures.Add(texture, info); - } - - return info; - } - #region Export 1.0 - /// - /// VRM-0.X の MaterialBindValue を VRM-1.0 仕様に変換する - /// - /// * Property名 => enum MaterialBindType - /// * 特に _MainTex_ST の場合、MaterialBindType.UvScale + MaterialBindType.UvScale 2つになりうる - /// - /// - VrmLib.Expression ToVrmLib(VRM10Expression clip, GameObject root) - { - var expression = new VrmLib.Expression(clip.Preset, clip.ExpressionName, clip.IsBinary); - expression.OverrideBlink = EnumUtil.Cast(clip.OverrideBlink); - expression.OverrideLookAt = EnumUtil.Cast(clip.OverrideLookAt); - expression.OverrideMouth = EnumUtil.Cast(clip.OverrideMouth); - - foreach (var binding in clip.MorphTargetBindings) - { - var transform = GetTransformFromRelativePath(root.transform, binding.RelativePath); - if (transform == null) - continue; - var renderer = transform.gameObject.GetComponent(); - if (renderer == null) - continue; - var mesh = renderer.sharedMesh; - if (mesh == null) - continue; - - var names = new List(); - for (int i = 0; i < mesh.blendShapeCount; ++i) - { - names.Add(mesh.GetBlendShapeName(i)); - } - - var node = Nodes[transform.gameObject]; - var blendShapeValue = new VrmLib.MorphTargetBind( - node, - names[binding.Index], - // Unity Range [0-100] to VRM-1.0 Range [0-1.0] - binding.Weight * 0.01f - ); - expression.MorphTargetBinds.Add(blendShapeValue); - } - - foreach (var binding in clip.MaterialColorBindings) - { - var materialPair = Materials.FirstOrDefault(x => x.Key.name == binding.MaterialName); - if (materialPair.Value != null) - { - var bind = new VrmLib.MaterialColorBind( - materialPair.Value, - binding.BindType, - binding.TargetValue.ToNumericsVector4() - ); - expression.MaterialColorBinds.Add(bind); - } - } - - foreach (var binding in clip.MaterialUVBindings) - { - var materialPair = Materials.FirstOrDefault(x => x.Key.name == binding.MaterialName); - if (materialPair.Value != null) - { - var bind = new VrmLib.TextureTransformBind( - materialPair.Value, - binding.Scaling.ToNumericsVector2(), - binding.Offset.ToNumericsVector2() - ); - expression.TextureTransformBinds.Add(bind); - } - } - - return expression; - } - /// /// metaObject が null のときは、root から取得する /// @@ -276,14 +146,13 @@ namespace UniVRM10 var materials = renderer.sharedMaterials; // avoid copy foreach (var material in materials) { - if (Materials.ContainsKey(material)) + if (Materials.Contains(material)) { continue; } - var vrmMaterial = Export10(material, GetOrCreateTexture); - Model.Materials.Add(vrmMaterial); - Materials.Add(material, vrmMaterial); + Model.Materials.Add(material); + Materials.Add(material); } } } @@ -554,7 +423,7 @@ namespace UniVRM10 return null; } - private static VrmLib.MeshGroup CreateMesh(UnityEngine.Mesh mesh, Renderer renderer, Dictionary materials) + private static VrmLib.MeshGroup CreateMesh(UnityEngine.Mesh mesh, Renderer renderer, List materials) { var meshGroup = new VrmLib.MeshGroup(mesh.name); var vrmMesh = new VrmLib.Mesh(); @@ -586,7 +455,7 @@ namespace UniVRM10 var subMesh = mesh.GetSubMesh(i); try { - vrmMesh.Submeshes.Add(new VrmLib.Submesh(offset, subMesh.indexCount, materials[renderer.sharedMaterials[i]])); + vrmMesh.Submeshes.Add(new VrmLib.Submesh(offset, subMesh.indexCount, materials.IndexOf(renderer.sharedMaterials[i]))); } catch (Exception ex) { @@ -597,7 +466,7 @@ namespace UniVRM10 var triangles = mesh.GetTriangles(i); try { - vrmMesh.Submeshes.Add(new VrmLib.Submesh(offset, triangles.Length, materials[renderer.sharedMaterials[i]])); + vrmMesh.Submeshes.Add(new VrmLib.Submesh(offset, triangles.Length, materials.IndexOf(renderer.sharedMaterials[i]))); } catch (Exception ex) { diff --git a/Assets/VRM10/Tests.PlayMode/MaterialTests.cs b/Assets/VRM10/Tests.PlayMode/MaterialTests.cs index 5eb7b392a..5855408f2 100644 --- a/Assets/VRM10/Tests.PlayMode/MaterialTests.cs +++ b/Assets/VRM10/Tests.PlayMode/MaterialTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Linq; using NUnit.Framework; @@ -29,7 +30,7 @@ namespace UniVRM10.Test VrmLib.MToon.Utils.PropUvAnimMaskTexture }; - private ModelAsset ToUnity(string path) + private (ModelAsset, IReadOnlyList) ToUnity(string path) { var fi = new FileInfo(_vrmPath); var bytes = File.ReadAllBytes(fi.FullName); @@ -40,7 +41,7 @@ namespace UniVRM10.Test return ToUnity(bytes); } - private ModelAsset ToUnity(byte[] bytes) + private (ModelAsset, IReadOnlyList) ToUnity(byte[] bytes) { // Vrm => Model var parser = new UniGLTF.GltfParser(); @@ -49,14 +50,14 @@ namespace UniVRM10.Test return ToUnity(parser); } - private ModelAsset ToUnity(GltfParser parser) + private (ModelAsset, IReadOnlyList) ToUnity(GltfParser parser) { // Model => Unity using (var loader = new RuntimeUnityBuilder(parser)) { loader.Load(); loader.DisposeOnGameObjectDestroyed(); - return loader.Asset; + return (loader.Asset, loader.MaterialFactory.Materials); } } @@ -90,232 +91,231 @@ namespace UniVRM10.Test [UnityTest] public IEnumerator ColorSpace_UnityBaseColorToLiner() { - var assets = ToUnity(_vrmPath); - var srcMaterial = assets.Map.Materials.First(); - var key = srcMaterial.Key; + var (assets, materials) = ToUnity(_vrmPath); + var srcMaterial = materials.First(); var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); var srcGammaColor = srcColor; var srclinerColor = srcColor.linear; - srcMaterial.Value.color = srcColor; + srcMaterial.Asset.color = srcColor; var model = ToVrmModel(assets.Root); - var dstMaterial = model.Materials.First(x => x.Name == key.Name); + var dstMaterial = model.Materials.First(x => x is UnityEngine.Material m && m.name == srcMaterial.Asset.name) as UnityEngine.Material; - EqualColor(srclinerColor, dstMaterial.BaseColorFactor.RGBA.ToUnityColor()); + EqualColor(srclinerColor, dstMaterial.color); yield return null; } - [UnityTest] - public IEnumerator ColorSpace_GltfBaseColorToGamma() - { - var assets = ToUnity(_vrmPath); - var srcMaterial = assets.Map.Materials.First(); - var key = srcMaterial.Key; - var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); - var srclinerColor = srcColor.ToVector4(); - var srcGammaColor = srcColor.gamma.ToVector4(); + // [UnityTest] + // public IEnumerator ColorSpace_GltfBaseColorToGamma() + // { + // var assets = ToUnity(_vrmPath); + // var srcMaterial = assets.Map.Materials.First(); + // var key = srcMaterial.Key; + // var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); + // var srclinerColor = srcColor.ToVector4(); + // var srcGammaColor = srcColor.gamma.ToVector4(); - var model = ToVrmModel(assets.Root); - var gltfMaterial = model.Materials.First(x => x.Name == key.Name); - gltfMaterial.BaseColorFactor = new LinearColor - { - RGBA = srclinerColor - }; + // var model = ToVrmModel(assets.Root); + // var gltfMaterial = model.Materials.First(x => x.Name == key.Name); + // gltfMaterial.BaseColorFactor = new LinearColor + // { + // RGBA = srclinerColor + // }; - var bytes = model.ToGlb(); + // var bytes = model.ToGlb(); - var dstAssets = ToUnity(bytes); - var dstMaterial = dstAssets.Map.Materials.First(x => x.Value.name == key.Name); + // var dstAssets = ToUnity(bytes); + // var dstMaterial = dstAssets.Map.Materials.First(x => x.Value.name == key.Name); - EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.Value.color); + // EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.Value.color); - yield return null; - } + // yield return null; + // } - [UnityTest] - public IEnumerator MToonUnityColorToGltf() - { - var assets = ToUnity(_vrmPath); - var srcMaterial = assets.Map.Materials.First(); - var key = srcMaterial.Key; - var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); - var srcGammaColor = srcColor; - var srclinerColor = srcColor.linear; + // [UnityTest] + // public IEnumerator MToonUnityColorToGltf() + // { + // var assets = ToUnity(_vrmPath); + // var srcMaterial = assets.Map.Materials.First(); + // var key = srcMaterial.Key; + // var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); + // var srcGammaColor = srcColor; + // var srclinerColor = srcColor.linear; - srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropColor, srcColor); - srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropShadeColor, srcColor); - srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropEmissionColor, srcColor); - srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropRimColor, srcColor); - srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropOutlineColor, srcColor); + // srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropColor, srcColor); + // srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropShadeColor, srcColor); + // srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropEmissionColor, srcColor); + // srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropRimColor, srcColor); + // srcMaterial.Value.SetColor(VrmLib.MToon.Utils.PropOutlineColor, srcColor); - var model = ToVrmModel(assets.Root); - var dstMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; + // var model = ToVrmModel(assets.Root); + // var dstMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; - // sRGB - EqualColor(srclinerColor, dstMaterial.Definition.Color.LitColor.RGBA.ToUnityColor()); - EqualColor(srclinerColor, dstMaterial.Definition.Color.ShadeColor.RGBA.ToUnityColor()); - EqualColor(srclinerColor, dstMaterial.Definition.Outline.OutlineColor.RGBA.ToUnityColor()); - // HDR Color - EqualColor(srcColor, dstMaterial.Definition.Emission.EmissionColor.RGBA.ToUnityColor()); - EqualColor(srcColor, dstMaterial.Definition.Rim.RimColor.RGBA.ToUnityColor()); + // // sRGB + // EqualColor(srclinerColor, dstMaterial.Definition.Color.LitColor.RGBA.ToUnityColor()); + // EqualColor(srclinerColor, dstMaterial.Definition.Color.ShadeColor.RGBA.ToUnityColor()); + // EqualColor(srclinerColor, dstMaterial.Definition.Outline.OutlineColor.RGBA.ToUnityColor()); + // // HDR Color + // EqualColor(srcColor, dstMaterial.Definition.Emission.EmissionColor.RGBA.ToUnityColor()); + // EqualColor(srcColor, dstMaterial.Definition.Rim.RimColor.RGBA.ToUnityColor()); - yield return null; - } + // yield return null; + // } - [UnityTest] - public IEnumerator MtoonGltfColorToUnity() - { - var assets = ToUnity(_vrmPath); - var srcMaterial = assets.Map.Materials.First(); - var key = srcMaterial.Key; - var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); - var srclinerColor = srcColor.ToVector4(); - var srcGammaColor = srcColor.gamma.ToVector4(); + // [UnityTest] + // public IEnumerator MtoonGltfColorToUnity() + // { + // var assets = ToUnity(_vrmPath); + // var srcMaterial = assets.Map.Materials.First(); + // var key = srcMaterial.Key; + // var srcColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); + // var srclinerColor = srcColor.ToVector4(); + // var srcGammaColor = srcColor.gamma.ToVector4(); - var model = ToVrmModel(assets.Root); - var gltfMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; - if (gltfMaterial == null) - { - throw new NotImplementedException(); - } + // var model = ToVrmModel(assets.Root); + // var gltfMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; + // if (gltfMaterial == null) + // { + // throw new NotImplementedException(); + // } - gltfMaterial.Definition = new VrmLib.MToon.MToonDefinition - { - Color = new VrmLib.MToon.ColorDefinition - { - LitColor = new LinearColor { RGBA = srclinerColor }, - ShadeColor = new LinearColor { RGBA = srclinerColor }, - }, - Outline = new VrmLib.MToon.OutlineDefinition - { - OutlineColor = new LinearColor { RGBA = srclinerColor }, - }, - Emission = new VrmLib.MToon.EmissionDefinition - { - EmissionColor = new LinearColor { RGBA = srclinerColor }, - }, - Rim = new VrmLib.MToon.RimDefinition - { - RimColor = new LinearColor { RGBA = srclinerColor }, - } - }; + // gltfMaterial.Definition = new VrmLib.MToon.MToonDefinition + // { + // Color = new VrmLib.MToon.ColorDefinition + // { + // LitColor = new LinearColor { RGBA = srclinerColor }, + // ShadeColor = new LinearColor { RGBA = srclinerColor }, + // }, + // Outline = new VrmLib.MToon.OutlineDefinition + // { + // OutlineColor = new LinearColor { RGBA = srclinerColor }, + // }, + // Emission = new VrmLib.MToon.EmissionDefinition + // { + // EmissionColor = new LinearColor { RGBA = srclinerColor }, + // }, + // Rim = new VrmLib.MToon.RimDefinition + // { + // RimColor = new LinearColor { RGBA = srclinerColor }, + // } + // }; - var bytes = model.ToGlb(); + // var bytes = model.ToGlb(); - var dstAssets = ToUnity(bytes); - var dstMaterial = dstAssets.Map.Materials.First(x => x.Value.name == key.Name).Value; - // sRGB - EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.GetColor(VrmLib.MToon.Utils.PropColor)); - EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.GetColor(VrmLib.MToon.Utils.PropShadeColor)); - EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.GetColor(VrmLib.MToon.Utils.PropOutlineColor)); - // HDR Color - EqualColor(srcColor, dstMaterial.GetColor(VrmLib.MToon.Utils.PropEmissionColor)); - EqualColor(srcColor, dstMaterial.GetColor(VrmLib.MToon.Utils.PropRimColor)); + // var dstAssets = ToUnity(bytes); + // var dstMaterial = dstAssets.Map.Materials.First(x => x.Value.name == key.Name).Value; + // // sRGB + // EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.GetColor(VrmLib.MToon.Utils.PropColor)); + // EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.GetColor(VrmLib.MToon.Utils.PropShadeColor)); + // EqualColor(srcGammaColor.ToUnityColor(), dstMaterial.GetColor(VrmLib.MToon.Utils.PropOutlineColor)); + // // HDR Color + // EqualColor(srcColor, dstMaterial.GetColor(VrmLib.MToon.Utils.PropEmissionColor)); + // EqualColor(srcColor, dstMaterial.GetColor(VrmLib.MToon.Utils.PropRimColor)); - yield return null; - } - #endregion + // yield return null; + // } + // #endregion - #region Texture + // #region Texture - Texture2D CreateMonoTexture(float mono, float alpha, bool isLinear) - { - Texture2D texture = new Texture2D(128, 128, TextureFormat.ARGB32, mipChain: false, linear: isLinear); - Color col = new Color(mono, mono, mono, alpha); - for (int y = 0; y < texture.height; y++) - { - for (int x = 0; x < texture.width; x++) - { - texture.SetPixel(x, y, col); - } - } - texture.Apply(); - return texture; - } + // Texture2D CreateMonoTexture(float mono, float alpha, bool isLinear) + // { + // Texture2D texture = new Texture2D(128, 128, TextureFormat.ARGB32, mipChain: false, linear: isLinear); + // Color col = new Color(mono, mono, mono, alpha); + // for (int y = 0; y < texture.height; y++) + // { + // for (int x = 0; x < texture.width; x++) + // { + // texture.SetPixel(x, y, col); + // } + // } + // texture.Apply(); + // return texture; + // } - void EqualTextureColor(Texture2D texture, VrmLib.ImageTexture imageTexture, bool isLinear) - { - var srcColor = texture.GetPixel(0, 0); + // void EqualTextureColor(Texture2D texture, VrmLib.ImageTexture imageTexture, bool isLinear) + // { + // var srcColor = texture.GetPixel(0, 0); - var dstTexture = new Texture2D(2, 2, TextureFormat.ARGB32, mipChain: false, linear: isLinear); - dstTexture.LoadImage(imageTexture.Image.Bytes.ToArray()); - var dstColor = dstTexture.GetPixel(0, 0); + // var dstTexture = new Texture2D(2, 2, TextureFormat.ARGB32, mipChain: false, linear: isLinear); + // dstTexture.LoadImage(imageTexture.Image.Bytes.ToArray()); + // var dstColor = dstTexture.GetPixel(0, 0); - Debug.LogFormat("src:{0}, dst{1}", srcColor, dstColor); - EqualColor(srcColor, dstColor); - } + // Debug.LogFormat("src:{0}, dst{1}", srcColor, dstColor); + // EqualColor(srcColor, dstColor); + // } - [UnityTest] - public IEnumerator MToonTextureToGltf_BaseColorTexture() - { - var assets = ToUnity(_vrmPath); - var srcMaterial = assets.Map.Materials.First(); - var key = srcMaterial.Key; - var srcSrgbTexture = CreateMonoTexture(0.5f, 0.5f, false); + // [UnityTest] + // public IEnumerator MToonTextureToGltf_BaseColorTexture() + // { + // var assets = ToUnity(_vrmPath); + // var srcMaterial = assets.Map.Materials.First(); + // var key = srcMaterial.Key; + // var srcSrgbTexture = CreateMonoTexture(0.5f, 0.5f, false); - srcMaterial.Value.SetTexture(VrmLib.MToon.Utils.PropMainTex, srcSrgbTexture); + // srcMaterial.Value.SetTexture(VrmLib.MToon.Utils.PropMainTex, srcSrgbTexture); - var model = ToVrmModel(assets.Root); - var dstMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; + // var model = ToVrmModel(assets.Root); + // var dstMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; - var imageTexture = dstMaterial.Definition.Color.LitMultiplyTexture.Texture as VrmLib.ImageTexture; - EqualTextureColor(srcSrgbTexture, imageTexture, false); + // var imageTexture = dstMaterial.Definition.Color.LitMultiplyTexture.Texture as VrmLib.ImageTexture; + // EqualTextureColor(srcSrgbTexture, imageTexture, false); - yield return null; - } + // yield return null; + // } - [UnityTest] - public IEnumerator MToonTextureToGltf_OutlineWidthTexture() - { - var assets = ToUnity(_vrmPath); - var srcMaterial = assets.Map.Materials.First(); - var key = srcMaterial.Key; - var srcLinearTexture = CreateMonoTexture(0.5f, 0.5f, true); + // [UnityTest] + // public IEnumerator MToonTextureToGltf_OutlineWidthTexture() + // { + // var assets = ToUnity(_vrmPath); + // var srcMaterial = assets.Map.Materials.First(); + // var key = srcMaterial.Key; + // var srcLinearTexture = CreateMonoTexture(0.5f, 0.5f, true); - srcMaterial.Value.SetTexture(VrmLib.MToon.Utils.PropOutlineWidthTexture, srcLinearTexture); + // srcMaterial.Value.SetTexture(VrmLib.MToon.Utils.PropOutlineWidthTexture, srcLinearTexture); - var model = ToVrmModel(assets.Root); - var dstMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; + // var model = ToVrmModel(assets.Root); + // var dstMaterial = model.Materials.First(x => x.Name == key.Name) as VrmLib.MToonMaterial; - var imageTexture = dstMaterial.Definition.Outline.OutlineWidthMultiplyTexture.Texture as VrmLib.ImageTexture; - EqualTextureColor(srcLinearTexture, imageTexture, true); + // var imageTexture = dstMaterial.Definition.Outline.OutlineWidthMultiplyTexture.Texture as VrmLib.ImageTexture; + // EqualTextureColor(srcLinearTexture, imageTexture, true); - yield return null; - } + // yield return null; + // } - [UnityTest] - public IEnumerator GetOrCreateTextureTest() - { - var converter = new RuntimeVrmConverter(); - var material = new UnityEngine.Material(Shader.Find("VRM/MToon")); - var srcLinearTexture = CreateMonoTexture(0.5f, 1.0f, true); - var srcSRGBTexture = CreateMonoTexture(0.5f, 1.0f, false); + // [UnityTest] + // public IEnumerator GetOrCreateTextureTest() + // { + // var converter = new RuntimeVrmConverter(); + // var material = new UnityEngine.Material(Shader.Find("VRM/MToon")); + // var srcLinearTexture = CreateMonoTexture(0.5f, 1.0f, true); + // var srcSRGBTexture = CreateMonoTexture(0.5f, 1.0f, false); - { - material.SetTexture(VrmLib.MToon.Utils.PropOutlineWidthTexture, srcSRGBTexture); - var textureInfo = converter.GetOrCreateTexture(material, srcSRGBTexture, VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default); - var imageTexture = textureInfo.Texture as VrmLib.ImageTexture; - EqualTextureColor(srcSRGBTexture, imageTexture, false); - } + // { + // material.SetTexture(VrmLib.MToon.Utils.PropOutlineWidthTexture, srcSRGBTexture); + // var textureInfo = converter.GetOrCreateTexture(material, srcSRGBTexture, VrmLib.Texture.ColorSpaceTypes.Srgb, VrmLib.Texture.TextureTypes.Default); + // var imageTexture = textureInfo.Texture as VrmLib.ImageTexture; + // EqualTextureColor(srcSRGBTexture, imageTexture, false); + // } - { - material.SetTexture(VrmLib.MToon.Utils.PropOutlineWidthTexture, srcLinearTexture); - var textureInfo = converter.GetOrCreateTexture(material, srcLinearTexture, VrmLib.Texture.ColorSpaceTypes.Linear, VrmLib.Texture.TextureTypes.Default); - var imageTexture = textureInfo.Texture as VrmLib.ImageTexture; - EqualTextureColor(srcLinearTexture, imageTexture, true); - } + // { + // material.SetTexture(VrmLib.MToon.Utils.PropOutlineWidthTexture, srcLinearTexture); + // var textureInfo = converter.GetOrCreateTexture(material, srcLinearTexture, VrmLib.Texture.ColorSpaceTypes.Linear, VrmLib.Texture.TextureTypes.Default); + // var imageTexture = textureInfo.Texture as VrmLib.ImageTexture; + // EqualTextureColor(srcLinearTexture, imageTexture, true); + // } - yield return null; - } + // yield return null; + // } - [UnityTest] - public IEnumerator MToonTextureToUnity() - { - yield return null; - } + // [UnityTest] + // public IEnumerator MToonTextureToUnity() + // { + // yield return null; + // } #endregion } } \ No newline at end of file diff --git a/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef b/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef index 972ea0c0c..032941920 100644 --- a/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef +++ b/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef @@ -3,7 +3,8 @@ "references": [ "VrmLib", "VRM10", - "UniGLTF" + "UniGLTF", + "VRMShaders" ], "optionalUnityReferences": [ "TestAssemblies" diff --git a/Assets/VRM10/vrmlib/Runtime/Humanoid/SkeletonMeshUtility.cs b/Assets/VRM10/vrmlib/Runtime/Humanoid/SkeletonMeshUtility.cs index 80dabe170..71a6e89ab 100644 --- a/Assets/VRM10/vrmlib/Runtime/Humanoid/SkeletonMeshUtility.cs +++ b/Assets/VRM10/vrmlib/Runtime/Humanoid/SkeletonMeshUtility.cs @@ -5,7 +5,7 @@ using System.Numerics; namespace VrmLib { - #pragma warning disable 0649 +#pragma warning disable 0649 struct BoneWeight { public int boneIndex0; @@ -18,7 +18,7 @@ namespace VrmLib public float weight2; public float weight3; } - #pragma warning restore +#pragma warning restore class MeshBuilder { @@ -68,7 +68,7 @@ namespace VrmLib { AddBone(head.SkeletonLocalPosition, tail.SkeletonLocalPosition, bones.IndexOf(head), headTail.XWidth, headTail.ZWidth); } - else if(headTail.TailOffset!=Vector3.Zero) + else if (headTail.TailOffset != Vector3.Zero) { AddBone(head.SkeletonLocalPosition, head.SkeletonLocalPosition + headTail.TailOffset, bones.IndexOf(head), headTail.XWidth, headTail.ZWidth); } @@ -150,25 +150,25 @@ namespace VrmLib void AddQuad(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, int boneIndex, bool reverse = false) { var i = m_positioins.Count; - if(float.IsNaN(v0.X) || float.IsNaN(v0.Y) || float.IsNaN(v0.Z)) + if (float.IsNaN(v0.X) || float.IsNaN(v0.Y) || float.IsNaN(v0.Z)) { throw new Exception(); } m_positioins.Add(v0); - if(float.IsNaN(v1.X) || float.IsNaN(v1.Y) || float.IsNaN(v1.Z)) + if (float.IsNaN(v1.X) || float.IsNaN(v1.Y) || float.IsNaN(v1.Z)) { throw new Exception(); } m_positioins.Add(v1); - if(float.IsNaN(v2.X) || float.IsNaN(v2.Y) || float.IsNaN(v2.Z)) + if (float.IsNaN(v2.X) || float.IsNaN(v2.Y) || float.IsNaN(v2.Z)) { throw new Exception(); } m_positioins.Add(v2); - if(float.IsNaN(v3.X) || float.IsNaN(v3.Y) || float.IsNaN(v3.Z)) + if (float.IsNaN(v3.X) || float.IsNaN(v3.Y) || float.IsNaN(v3.Z)) { throw new Exception(); } @@ -205,40 +205,6 @@ namespace VrmLib m_indices.Add(i); } } - - public Mesh CreateMesh() - { - if(m_positioins.Any(x => float.IsNaN(x.X) || float.IsNaN(x.Y) || float.IsNaN(x.Z))) - { - throw new Exception(); - } - - var mesh = new Mesh(); - mesh.VertexBuffer = new VertexBuffer(); - mesh.VertexBuffer.Add(VertexBuffer.PositionKey, - m_positioins.ToArray()); - - mesh.VertexBuffer.Add(VertexBuffer.JointKey, - m_boneWeights.Select(x => new SkinJoints( - (ushort)x.boneIndex0, - (ushort)x.boneIndex1, - (ushort)x.boneIndex2, - (ushort)x.boneIndex3)).ToArray()); - - mesh.VertexBuffer.Add(VertexBuffer.WeightKey, - m_boneWeights.Select(x => new Vector4( - x.weight0, - x.weight1, - x.weight2, - x.weight3 - )).ToArray()); - - mesh.IndexBuffer = BufferAccessor.Create(m_indices.ToArray()); - - mesh.Submeshes.Add(new Submesh(0, mesh.IndexBuffer.Count, null)); - - return mesh; - } } struct BoneHeadTail diff --git a/Assets/VRM10/vrmlib/Runtime/Mesh.cs b/Assets/VRM10/vrmlib/Runtime/Mesh.cs index 2f6d4f57c..7de93f88e 100644 --- a/Assets/VRM10/vrmlib/Runtime/Mesh.cs +++ b/Assets/VRM10/vrmlib/Runtime/Mesh.cs @@ -34,18 +34,18 @@ namespace VrmLib { public int Offset; public int DrawCount; - public Material Material; + public int Material; public override string ToString() { - return $"{Material.Name}({DrawCount})"; + return $"{Material}({DrawCount})"; } - public Submesh(Material material) : this(0, 0, material) + public Submesh(int material) : this(0, 0, material) { } - public Submesh(int offset, int drawCount, Material material) + public Submesh(int offset, int drawCount, int material) { Offset = offset; DrawCount = drawCount; diff --git a/Assets/VRM10/vrmlib/Runtime/MeshExtensions.cs b/Assets/VRM10/vrmlib/Runtime/MeshExtensions.cs index fa068237c..0fa78c6ea 100644 --- a/Assets/VRM10/vrmlib/Runtime/MeshExtensions.cs +++ b/Assets/VRM10/vrmlib/Runtime/MeshExtensions.cs @@ -653,7 +653,7 @@ namespace VrmLib { // 連続して同じMaterialのSubMeshを連結する mesh.Submeshes.Clear(); - Material current = null; + int current = -1; foreach (var submesh in order) { if (current != submesh.Material) diff --git a/Assets/VRM10/vrmlib/Runtime/MeshFactory.cs b/Assets/VRM10/vrmlib/Runtime/MeshFactory.cs deleted file mode 100644 index 546985c0b..000000000 --- a/Assets/VRM10/vrmlib/Runtime/MeshFactory.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Numerics; - -namespace VrmLib -{ - public static class MeshFactory - { - public static Mesh CreateQuadrangle() - { - var mesh = new Mesh(); - mesh.IndexBuffer = BufferAccessor.Create(new int[] { 0, 1, 2, 2, 3, 0 }); - mesh.VertexBuffer = new VertexBuffer(); - mesh.VertexBuffer.Add(VertexBuffer.PositionKey, new Vector3[]{ - new Vector3(-1, 1, 0), - new Vector3(1, 1, 0), - new Vector3(1, -1, 0), - new Vector3(-1, -1, 0), - }); - mesh.VertexBuffer.Add(VertexBuffer.TexCoordKey, new Vector2[]{ - new Vector2(0, 0), - new Vector2(1, 0), - new Vector2(1, 1), - new Vector2(0, 1), - }); - mesh.Submeshes.Add(new Submesh(0, 6, new Material("SCREEN"))); - return mesh; - } - } -} \ No newline at end of file diff --git a/Assets/VRM10/vrmlib/Runtime/MeshFactory.cs.meta b/Assets/VRM10/vrmlib/Runtime/MeshFactory.cs.meta deleted file mode 100644 index f52f73bcf..000000000 --- a/Assets/VRM10/vrmlib/Runtime/MeshFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d7c93f9da54dc08429261518417be9aa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/vrmlib/Runtime/Model.cs b/Assets/VRM10/vrmlib/Runtime/Model.cs index d3df6604a..c445904a6 100644 --- a/Assets/VRM10/vrmlib/Runtime/Model.cs +++ b/Assets/VRM10/vrmlib/Runtime/Model.cs @@ -25,14 +25,8 @@ namespace VrmLib public string AssetCopyright; public string AssetMinVersion; - // gltf/images - public readonly List Images = new List(); - - // gltf/textures - public readonly List Textures = new List(); - // gltf/materials - public readonly List Materials = new List(); + public readonly List Materials = new List(); // gltf/skins public readonly List Skins = new List(); @@ -90,16 +84,6 @@ namespace VrmLib var sb = new StringBuilder(); sb.Append($"[GLTF] generator: {AssetGenerator}\n"); - for (int i = 0; i < Images.Count; ++i) - { - var x = Images[i]; - sb.Append($"[Image#{i:00}] {x}\n"); - } - // for (int i = 0; i < Textures.Count; ++i) - // { - // var t = Textures[i]; - // sb.Append($"[Texture#{i:00}] {t}\n"); - // } for (int i = 0; i < Materials.Count; ++i) { var m = Materials[i]; diff --git a/Assets/VRM10/vrmlib/Runtime/ModelExtensions.cs b/Assets/VRM10/vrmlib/Runtime/ModelExtensions.cs index 2decb5c83..bb5b94a24 100644 --- a/Assets/VRM10/vrmlib/Runtime/ModelExtensions.cs +++ b/Assets/VRM10/vrmlib/Runtime/ModelExtensions.cs @@ -68,9 +68,6 @@ namespace VrmLib public static void CheckIndex(this Model model) { - CheckIndex(model.Images, nameof(model.Images)); - CheckIndex(model.Textures, nameof(model.Textures)); - CheckIndex(model.Materials, nameof(model.Materials)); CheckIndex(model.Nodes, nameof(model.Nodes)); CheckIndex(model.Skins, nameof(model.Skins)); CheckIndex(model.MeshGroups, nameof(model.MeshGroups));