From d974ddfa575511ec7a24d40012f54521b1cbca5d Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 5 Sep 2022 18:41:12 +0900 Subject: [PATCH] =?UTF-8?q?out=20(SubAssetKey,=20TextureDescriptor)=20?= =?UTF-8?q?=E3=82=92=202=E3=81=A4=E3=81=AE=20out=20=E3=81=AB=E5=B1=95?= =?UTF-8?q?=E9=96=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IO/MaterialIO/GltfPbrMaterialImporter.cs | 24 ++-- .../MaterialIO/GltfUnlitMaterialImporter.cs | 4 +- .../URP/GltfPbrURPMaterialImporter.cs | 19 ++- .../IO/TextureIO/GltfPbrTextureImporter.cs | 32 ++--- .../IO/TextureIO/GltfTextureImporter.cs | 38 +++--- Assets/VRM/Runtime/IO/VRMImporterContext.cs | 5 +- .../Runtime/IO/VRMMToonMaterialImporter.cs | 4 +- .../VRM/Runtime/IO/VRMMToonTextureImporter.cs | 13 ++- ...MUnlitTransparentZWriteMaterialImporter.cs | 4 +- .../IO/VrmTextureDescriptorGenerator.cs | 11 +- .../IO/Texture/Vrm10MToonTextureImporter.cs | 110 ++++++++++-------- 11 files changed, 139 insertions(+), 125 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs index 815d6e238..21087bfec 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs @@ -76,13 +76,13 @@ namespace UniGLTF { if (src.pbrMetallicRoughness.metallicRoughnessTexture != null || src.occlusionTexture != null) { - if (GltfPbrTextureImporter.TryStandardTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryStandardTexture(data, src, out var key, out var desc)) { - if (string.IsNullOrEmpty(value.Item2.UnityObjectName)) + if (string.IsNullOrEmpty(desc.UnityObjectName)) { throw new ArgumentNullException(); } - standardTexDesc = value.Item2; + standardTexDesc = desc; } } @@ -97,13 +97,13 @@ namespace UniGLTF if (src.pbrMetallicRoughness.baseColorTexture != null && src.pbrMetallicRoughness.baseColorTexture.index != -1) { - if (GltfPbrTextureImporter.TryBaseColorTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryBaseColorTexture(data, src, out var key, out var desc)) { - if (string.IsNullOrEmpty(value.Item2.UnityObjectName)) + if (string.IsNullOrEmpty(desc.UnityObjectName)) { throw new ArgumentNullException(); } - textureSlots.Add("_MainTex", value.Item2); + textureSlots.Add("_MainTex", desc); } } @@ -127,13 +127,13 @@ namespace UniGLTF if (src.normalTexture != null && src.normalTexture.index != -1) { actions.Add(material => material.EnableKeyword("_NORMALMAP")); - if (GltfPbrTextureImporter.TryNormalTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryNormalTexture(data, src, out var key, out var desc)) { - if (string.IsNullOrEmpty(value.Item2.UnityObjectName)) + if (string.IsNullOrEmpty(desc.UnityObjectName)) { throw new ArgumentNullException(); } - textureSlots.Add("_BumpMap", value.Item2); + textureSlots.Add("_BumpMap", desc); floatValues.Add("_BumpScale", src.normalTexture.scale); } } @@ -172,13 +172,13 @@ namespace UniGLTF if (src.emissiveTexture != null && src.emissiveTexture.index != -1) { - if (GltfPbrTextureImporter.TryEmissiveTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryEmissiveTexture(data, src, out var key, out var desc)) { - if (string.IsNullOrEmpty(value.Item2.UnityObjectName)) + if (string.IsNullOrEmpty(desc.UnityObjectName)) { throw new ArgumentNullException(); } - textureSlots.Add("_EmissionMap", value.Item2); + textureSlots.Add("_EmissionMap", desc); } } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfUnlitMaterialImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfUnlitMaterialImporter.cs index 38c45c2b8..0f2549189 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfUnlitMaterialImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfUnlitMaterialImporter.cs @@ -43,9 +43,9 @@ namespace UniGLTF if (src.pbrMetallicRoughness.baseColorTexture != null) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.pbrMetallicRoughness.baseColorTexture); - if (GltfTextureImporter.TryCreateSrgb(data, src.pbrMetallicRoughness.baseColorTexture.index, offset, scale, out var value)) + if (GltfTextureImporter.TryCreateSrgb(data, src.pbrMetallicRoughness.baseColorTexture.index, offset, scale, out var key, out var desc)) { - textureSlots.Add("_MainTex", value.Item2); + textureSlots.Add("_MainTex", desc); } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/GltfPbrURPMaterialImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/GltfPbrURPMaterialImporter.cs index 6c65f2984..3660af82f 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/GltfPbrURPMaterialImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/GltfPbrURPMaterialImporter.cs @@ -47,13 +47,13 @@ namespace UniGLTF { if (src.pbrMetallicRoughness.metallicRoughnessTexture != null || src.occlusionTexture != null) { - if (GltfPbrTextureImporter.TryStandardTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryStandardTexture(data, src, out var key, out var desc)) { - if (string.IsNullOrEmpty(value.Item2.UnityObjectName)) + if (string.IsNullOrEmpty(desc.UnityObjectName)) { throw new ArgumentNullException(); } - standardTexDesc = value.Item2; + standardTexDesc = desc; } } @@ -67,10 +67,10 @@ namespace UniGLTF if (src.pbrMetallicRoughness.baseColorTexture != null && src.pbrMetallicRoughness.baseColorTexture.index != -1) { - if (GltfPbrTextureImporter.TryBaseColorTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryBaseColorTexture(data, src, out var key, out var desc)) { // from _MainTex ! - textureSlots.Add("_BaseMap", value.Item2); + textureSlots.Add("_BaseMap", desc); } } @@ -95,10 +95,9 @@ namespace UniGLTF if (src.normalTexture != null && src.normalTexture.index != -1) { actions.Add(material => material.EnableKeyword("_NORMALMAP")); - if (GltfPbrTextureImporter.TryNormalTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryNormalTexture(data, src, out var key, out var desc)) { - var (key, textureParam) = value; - textureSlots.Add("_BumpMap", textureParam); + textureSlots.Add("_BumpMap", desc); floatValues.Add("_BumpScale", src.normalTexture.scale); } } @@ -136,9 +135,9 @@ namespace UniGLTF if (src.emissiveTexture != null && src.emissiveTexture.index != -1) { - if (GltfPbrTextureImporter.TryEmissiveTexture(data, src, out var value)) + if (GltfPbrTextureImporter.TryEmissiveTexture(data, src, out var key, out var desc)) { - textureSlots.Add("_EmissionMap", value.Item2); + textureSlots.Add("_EmissionMap", desc); } } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs index d86c5a2b1..e8fc3e10b 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs @@ -15,9 +15,9 @@ namespace UniGLTF // base color if (m.pbrMetallicRoughness?.baseColorTexture != null) { - if (TryBaseColorTexture(data, m, out var value)) + if (TryBaseColorTexture(data, m, out var key, out var desc)) { - yield return value; + yield return (key, desc); } } @@ -31,18 +31,18 @@ namespace UniGLTF // emission if (m.emissiveTexture != null) { - if (TryEmissiveTexture(data, m, out var value)) + if (TryEmissiveTexture(data, m, out var key, out var desc)) { - yield return value; + yield return (key, desc); } } // normal if (m.normalTexture != null) { - if (TryNormalTexture(data, m, out var value)) + if (TryNormalTexture(data, m, out var key, out var desc)) { - yield return value; + yield return (key, desc); } } @@ -56,20 +56,20 @@ namespace UniGLTF // metallicSmooth and occlusion if (metallicRoughnessTexture.HasValue || occlusionTexture.HasValue) { - if (TryStandardTexture(data, m, out var value)) + if (TryStandardTexture(data, m, out var key, out var desc)) { - yield return value; + yield return (key, desc); } } } - public static bool TryBaseColorTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) value) + public static bool TryBaseColorTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.pbrMetallicRoughness.baseColorTexture); - return GltfTextureImporter.TryCreateSrgb(data, src.pbrMetallicRoughness.baseColorTexture.index, offset, scale, out value); + return GltfTextureImporter.TryCreateSrgb(data, src.pbrMetallicRoughness.baseColorTexture.index, offset, scale, out key, out desc); } - public static bool TryStandardTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) value) + public static bool TryStandardTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { var metallicFactor = 1.0f; var roughnessFactor = 1.0f; @@ -84,19 +84,19 @@ namespace UniGLTF src.occlusionTexture?.index, offset, scale, metallicFactor, - roughnessFactor, out value); + roughnessFactor, out key, out desc); } - public static bool TryNormalTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) value) + public static bool TryNormalTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.normalTexture); - return GltfTextureImporter.TryCreateNormal(data, src.normalTexture.index, offset, scale, out value); + return GltfTextureImporter.TryCreateNormal(data, src.normalTexture.index, offset, scale, out key, out desc); } - public static bool TryEmissiveTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) value) + public static bool TryEmissiveTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.emissiveTexture); - return GltfTextureImporter.TryCreateSrgb(data, src.emissiveTexture.index, offset, scale, out value); + return GltfTextureImporter.TryCreateSrgb(data, src.emissiveTexture.index, offset, scale, out key, out desc); } } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs index 1c55e2774..6fdb77787 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs @@ -35,19 +35,20 @@ namespace UniGLTF return (texDesc.SubAssetKey, texDesc); } - public static bool TryCreateSrgb(GltfData data, int textureIndex, Vector2 offset, Vector2 scale, out (SubAssetKey, TextureDescriptor) value) + public static bool TryCreateSrgb(GltfData data, int textureIndex, Vector2 offset, Vector2 scale, out SubAssetKey key, out TextureDescriptor desc) { var gltfTexture = data.GLTF.textures[textureIndex]; if (!gltfTexture.source.HasValidIndex()) { - value = default; + key = default; + desc = default; return false; } var gltfImage = data.GLTF.images[gltfTexture.source.Value]; var name = TextureImportName.GetUnityObjectName(TextureImportTypes.sRGB, gltfTexture.name, gltfImage.uri); var sampler = TextureSamplerUtil.CreateSampler(data.GLTF, textureIndex); - var param = new TextureDescriptor( + desc = new TextureDescriptor( name, offset, scale, sampler, @@ -56,23 +57,24 @@ namespace UniGLTF default, () => Task.FromResult(GetImageBytesFromTextureIndex(data, textureIndex)), default, default, default, default, default); - value = (param.SubAssetKey, param); + key = desc.SubAssetKey; return true; } - public static bool TryCreateLinear(GltfData data, int textureIndex, Vector2 offset, Vector2 scale, out (SubAssetKey, TextureDescriptor) value) + public static bool TryCreateLinear(GltfData data, int textureIndex, Vector2 offset, Vector2 scale, out SubAssetKey key, out TextureDescriptor desc) { var gltfTexture = data.GLTF.textures[textureIndex]; if (!gltfTexture.source.HasValidIndex()) { - value = default; + key = default; + desc = default; return false; } var gltfImage = data.GLTF.images[gltfTexture.source.Value]; var name = TextureImportName.GetUnityObjectName(TextureImportTypes.Linear, gltfTexture.name, gltfImage.uri); var sampler = TextureSamplerUtil.CreateSampler(data.GLTF, textureIndex); - var param = new TextureDescriptor( + desc = new TextureDescriptor( name, offset, scale, @@ -82,23 +84,24 @@ namespace UniGLTF default, () => Task.FromResult(GetImageBytesFromTextureIndex(data, textureIndex)), default, default, default, default, default); - value = (param.SubAssetKey, param); + key = desc.SubAssetKey; return true; } - public static bool TryCreateNormal(GltfData data, int textureIndex, Vector2 offset, Vector2 scale, out (SubAssetKey, TextureDescriptor) value) + public static bool TryCreateNormal(GltfData data, int textureIndex, Vector2 offset, Vector2 scale, out SubAssetKey key, out TextureDescriptor desc) { var gltfTexture = data.GLTF.textures[textureIndex]; if (!gltfTexture.source.HasValidIndex()) { - value = default; + key = default; + desc = default; return false; } var gltfImage = data.GLTF.images[gltfTexture.source.Value]; var name = TextureImportName.GetUnityObjectName(TextureImportTypes.NormalMap, gltfTexture.name, gltfImage.uri); var sampler = TextureSamplerUtil.CreateSampler(data.GLTF, textureIndex); - var param = new TextureDescriptor( + desc = new TextureDescriptor( name, offset, scale, @@ -108,11 +111,11 @@ namespace UniGLTF default, () => Task.FromResult(GetImageBytesFromTextureIndex(data, textureIndex)), default, default, default, default, default); - value = (param.SubAssetKey, param); + key = desc.SubAssetKey; return true; } - public static bool TryCreateStandard(GltfData data, int? metallicRoughnessTextureIndex, int? occlusionTextureIndex, Vector2 offset, Vector2 scale, float metallicFactor, float roughnessFactor, out (SubAssetKey, TextureDescriptor) value) + public static bool TryCreateStandard(GltfData data, int? metallicRoughnessTextureIndex, int? occlusionTextureIndex, Vector2 offset, Vector2 scale, float metallicFactor, float roughnessFactor, out SubAssetKey key, out TextureDescriptor desc) { string name = default; @@ -146,11 +149,12 @@ namespace UniGLTF if (string.IsNullOrEmpty(name)) { - value = default; + key = default; + desc = default; return false; } - var texDesc = new TextureDescriptor( + desc = new TextureDescriptor( name, offset, scale, @@ -161,8 +165,8 @@ namespace UniGLTF getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default); - value = (texDesc.SubAssetKey, texDesc); - if (string.IsNullOrEmpty(value.Item2.UnityObjectName)) + key = desc.SubAssetKey; + if (string.IsNullOrEmpty(desc.UnityObjectName)) { throw new ArgumentNullException(); } diff --git a/Assets/VRM/Runtime/IO/VRMImporterContext.cs b/Assets/VRM/Runtime/IO/VRMImporterContext.cs index 56f7d2fb3..f48a19309 100644 --- a/Assets/VRM/Runtime/IO/VRMImporterContext.cs +++ b/Assets/VRM/Runtime/IO/VRMImporterContext.cs @@ -301,10 +301,9 @@ namespace VRM meta.Title = gltfMeta.title; if (gltfMeta.texture >= 0) { - if (GltfTextureImporter.TryCreateSrgb(Data, gltfMeta.texture, Vector2.zero, Vector2.one, out var value)) + if (GltfTextureImporter.TryCreateSrgb(Data, gltfMeta.texture, Vector2.zero, Vector2.one, out var key, out var desc)) { - var (key, param) = value; - meta.Thumbnail = await TextureFactory.GetTextureAsync(param, awaitCaller) as Texture2D; + meta.Thumbnail = await TextureFactory.GetTextureAsync(desc, awaitCaller) as Texture2D; } } meta.AllowedUser = gltfMeta.allowedUser; diff --git a/Assets/VRM/Runtime/IO/VRMMToonMaterialImporter.cs b/Assets/VRM/Runtime/IO/VRMMToonMaterialImporter.cs index 56c9c95a9..13772d106 100644 --- a/Assets/VRM/Runtime/IO/VRMMToonMaterialImporter.cs +++ b/Assets/VRM/Runtime/IO/VRMMToonMaterialImporter.cs @@ -85,9 +85,9 @@ namespace VRM foreach (var kv in vrmMaterial.textureProperties) { if (VRMMToonTextureImporter.TryGetTextureFromMaterialProperty(data, vrmMaterial, kv.Key, - out var texture)) + out var key, out var desc)) { - textureSlots.Add(kv.Key, texture.Item2); + textureSlots.Add(kv.Key, desc); } } diff --git a/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs b/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs index a05ca5836..cdb3f94d7 100644 --- a/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs +++ b/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs @@ -12,13 +12,13 @@ namespace VRM var vrmMaterial = vrm.materialProperties[materialIdx]; foreach (var kv in vrmMaterial.textureProperties) { - if (TryGetTextureFromMaterialProperty(data, vrmMaterial, kv.Key, out var texture)) + if (TryGetTextureFromMaterialProperty(data, vrmMaterial, kv.Key, out var key, out var desc)) { - yield return texture; + yield return (key, desc); } } } - public static bool TryGetTextureFromMaterialProperty(GltfData data, glTF_VRM_Material vrmMaterial, string textureKey, out (SubAssetKey, TextureDescriptor) texture) + public static bool TryGetTextureFromMaterialProperty(GltfData data, glTF_VRM_Material vrmMaterial, string textureKey, out SubAssetKey key, out TextureDescriptor desc) { // 任意の shader の import を許容する if (/*vrmMaterial.shader == MToon.Utils.ShaderName &&*/ vrmMaterial.textureProperties.TryGetValue(textureKey, out var textureIdx)) @@ -33,13 +33,14 @@ namespace VRM switch (textureKey) { case MToon.Utils.PropBumpMap: - return GltfTextureImporter.TryCreateNormal(data, textureIdx, offset, scale, out texture); + return GltfTextureImporter.TryCreateNormal(data, textureIdx, offset, scale, out key, out desc); default: - return GltfTextureImporter.TryCreateSrgb(data, textureIdx, offset, scale, out texture); + return GltfTextureImporter.TryCreateSrgb(data, textureIdx, offset, scale, out key, out desc); } } - texture = default; + key = default; + desc = default; return false; } diff --git a/Assets/VRM/Runtime/IO/VRMUnlitTransparentZWriteMaterialImporter.cs b/Assets/VRM/Runtime/IO/VRMUnlitTransparentZWriteMaterialImporter.cs index 9d8a57780..dd0792efe 100644 --- a/Assets/VRM/Runtime/IO/VRMUnlitTransparentZWriteMaterialImporter.cs +++ b/Assets/VRM/Runtime/IO/VRMUnlitTransparentZWriteMaterialImporter.cs @@ -48,9 +48,9 @@ namespace VRM if (vrmMaterial.textureProperties.ContainsKey(UnlitTransparentZWriteMainTexturePropName)) { if (VRMMToonTextureImporter.TryGetTextureFromMaterialProperty(data, vrmMaterial, - UnlitTransparentZWriteMainTexturePropName, out var texture)) + UnlitTransparentZWriteMainTexturePropName, out var key, out var desc)) { - textureSlots.Add(MToon.Utils.PropMainTex, texture.Item2); + textureSlots.Add(MToon.Utils.PropMainTex, desc); } } diff --git a/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs b/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs index c8906f937..8a02a9bc0 100644 --- a/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs +++ b/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs @@ -59,20 +59,21 @@ namespace VRM } // Thumbnail - if (TryGetThumbnailTexture(data, vrm, out var thumbnail)) + if (TryGetThumbnailTexture(data, vrm, out var key, out var desc)) { - yield return thumbnail; + yield return (key, desc); } } - private static bool TryGetThumbnailTexture(GltfData data, glTF_VRM_extensions vrm, out (SubAssetKey, TextureDescriptor) texture) + private static bool TryGetThumbnailTexture(GltfData data, glTF_VRM_extensions vrm, out SubAssetKey key, out TextureDescriptor desc) { if (vrm.meta.texture > -1) { - return GltfTextureImporter.TryCreateSrgb(data, vrm.meta.texture, Vector2.zero, Vector2.one, out texture); + return GltfTextureImporter.TryCreateSrgb(data, vrm.meta.texture, Vector2.zero, Vector2.one, out key, out desc); } - texture = default; + key = default; + desc = default; return false; } } diff --git a/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs b/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs index 770ff94bf..9dbba8a44 100644 --- a/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs +++ b/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs @@ -12,170 +12,180 @@ namespace UniVRM10 { public static IEnumerable<(string key, (SubAssetKey, TextureDescriptor))> EnumerateAllTextures(GltfData data, glTFMaterial material, VRMC_materials_mtoon mToon) { - if (TryGetBaseColorTexture(data, material, out var litTex)) + if (TryGetBaseColorTexture(data, material, out var key, out var desc)) { - yield return (MToon10Prop.BaseColorTexture.ToUnityShaderLabName(), litTex); + yield return (MToon10Prop.BaseColorTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetEmissiveTexture(data, material, out var emissiveTex)) + if (TryGetEmissiveTexture(data, material, out key, out desc)) { - yield return (MToon10Prop.EmissiveTexture.ToUnityShaderLabName(), emissiveTex); + yield return (MToon10Prop.EmissiveTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetNormalTexture(data, material, out var normalTex)) + if (TryGetNormalTexture(data, material, out key, out desc)) { - yield return (MToon10Prop.NormalTexture.ToUnityShaderLabName(), normalTex); + yield return (MToon10Prop.NormalTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetShadeMultiplyTexture(data, mToon, out var shadeTex)) + if (TryGetShadeMultiplyTexture(data, mToon, out key, out desc)) { - yield return (MToon10Prop.ShadeColorTexture.ToUnityShaderLabName(), shadeTex); + yield return (MToon10Prop.ShadeColorTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetShadingShiftTexture(data, mToon, out var shadeShiftTex)) + if (TryGetShadingShiftTexture(data, mToon, out key, out desc)) { - yield return (MToon10Prop.ShadingShiftTexture.ToUnityShaderLabName(), shadeShiftTex); + yield return (MToon10Prop.ShadingShiftTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetMatcapTexture(data, mToon, out var matcapTex)) + if (TryGetMatcapTexture(data, mToon, out key, out desc)) { - yield return (MToon10Prop.MatcapTexture.ToUnityShaderLabName(), matcapTex); + yield return (MToon10Prop.MatcapTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetRimMultiplyTexture(data, mToon, out var rimTex)) + if (TryGetRimMultiplyTexture(data, mToon, out key, out desc)) { - yield return (MToon10Prop.RimMultiplyTexture.ToUnityShaderLabName(), rimTex); + yield return (MToon10Prop.RimMultiplyTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetOutlineWidthMultiplyTexture(data, mToon, out var outlineTex)) + if (TryGetOutlineWidthMultiplyTexture(data, mToon, out key, out desc)) { - yield return (MToon10Prop.OutlineWidthMultiplyTexture.ToUnityShaderLabName(), outlineTex); + yield return (MToon10Prop.OutlineWidthMultiplyTexture.ToUnityShaderLabName(), (key, desc)); } - if (TryGetUvAnimationMaskTexture(data, mToon, out var uvAnimMaskTex)) + if (TryGetUvAnimationMaskTexture(data, mToon, out key, out desc)) { - yield return (MToon10Prop.UvAnimationMaskTexture.ToUnityShaderLabName(), uvAnimMaskTex); + yield return (MToon10Prop.UvAnimationMaskTexture.ToUnityShaderLabName(), (key, desc)); } } - private static bool TryGetBaseColorTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetBaseColorTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { try { - return GltfPbrTextureImporter.TryBaseColorTexture(data, src, out pair); + return GltfPbrTextureImporter.TryBaseColorTexture(data, src, out key, out desc); } catch (NullReferenceException) { - pair = default; + key = default; + desc = default; return false; } catch (ArgumentOutOfRangeException) { - pair = default; + key = default; + desc = default; return false; } } - private static bool TryGetEmissiveTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetEmissiveTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { try { - return GltfPbrTextureImporter.TryEmissiveTexture(data, src, out pair); + return GltfPbrTextureImporter.TryEmissiveTexture(data, src, out key, out desc); } catch (NullReferenceException) { - pair = default; + key = default; + desc = default; return false; } catch (ArgumentOutOfRangeException) { - pair = default; + key = default; + desc = default; return false; } } - private static bool TryGetNormalTexture(GltfData data, glTFMaterial src, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetNormalTexture(GltfData data, glTFMaterial src, out SubAssetKey key, out TextureDescriptor desc) { try { - return GltfPbrTextureImporter.TryNormalTexture(data, src, out pair); + return GltfPbrTextureImporter.TryNormalTexture(data, src, out key, out desc); } catch (NullReferenceException) { - pair = default; + key = default; + desc = default; return false; } catch (ArgumentOutOfRangeException) { - pair = default; + key = default; + desc = default; return false; } } - private static bool TryGetShadeMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetShadeMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc) { - return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.ShadeMultiplyTexture), out pair); + return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.ShadeMultiplyTexture), out key, out desc); } - private static bool TryGetShadingShiftTexture(GltfData data, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetShadingShiftTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc) { - return TryGetLinearTexture(data, new Vrm10TextureInfo(mToon.ShadingShiftTexture), out pair); + return TryGetLinearTexture(data, new Vrm10TextureInfo(mToon.ShadingShiftTexture), out key, out desc); } - private static bool TryGetMatcapTexture(GltfData data, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetMatcapTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc) { - return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.MatcapTexture), out pair); + return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.MatcapTexture), out key, out desc); } - private static bool TryGetRimMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetRimMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc) { - return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.RimMultiplyTexture), out pair); + return TryGetSRGBTexture(data, new Vrm10TextureInfo(mToon.RimMultiplyTexture), out key, out desc); } - private static bool TryGetOutlineWidthMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetOutlineWidthMultiplyTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc) { - return TryGetLinearTexture(data, new Vrm10TextureInfo(mToon.OutlineWidthMultiplyTexture), out pair); + return TryGetLinearTexture(data, new Vrm10TextureInfo(mToon.OutlineWidthMultiplyTexture), out key, out desc); } - private static bool TryGetUvAnimationMaskTexture(GltfData data, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetUvAnimationMaskTexture(GltfData data, VRMC_materials_mtoon mToon, out SubAssetKey key, out TextureDescriptor desc) { - return TryGetLinearTexture(data, new Vrm10TextureInfo(mToon.UvAnimationMaskTexture), out pair); + return TryGetLinearTexture(data, new Vrm10TextureInfo(mToon.UvAnimationMaskTexture), out key, out desc); } - private static bool TryGetSRGBTexture(GltfData data, Vrm10TextureInfo info, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetSRGBTexture(GltfData data, Vrm10TextureInfo info, out SubAssetKey key, out TextureDescriptor desc) { try { var (offset, scale) = GetTextureOffsetAndScale(info); - return GltfTextureImporter.TryCreateSrgb(data, info.index, offset, scale, out pair); + return GltfTextureImporter.TryCreateSrgb(data, info.index, offset, scale, out key, out desc); } catch (NullReferenceException) { - pair = default; + key = default; + desc = default; return false; } catch (ArgumentOutOfRangeException) { - pair = default; + key = default; + desc = default; return false; } } - private static bool TryGetLinearTexture(GltfData data, Vrm10TextureInfo info, out (SubAssetKey, TextureDescriptor) pair) + private static bool TryGetLinearTexture(GltfData data, Vrm10TextureInfo info, out SubAssetKey key, out TextureDescriptor desc) { try { var (offset, scale) = GetTextureOffsetAndScale(info); - return GltfTextureImporter.TryCreateLinear(data, info.index, offset, scale, out pair); + return GltfTextureImporter.TryCreateLinear(data, info.index, offset, scale, out key, out desc); } catch (NullReferenceException) { - pair = default; + key = default; + desc = default; return false; } catch (ArgumentOutOfRangeException) { - pair = default; + key = default; + desc = default; return false; } }