From dbdb147e2ade5267878cd697efd7e395104f56f8 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 3 Nov 2022 18:27:13 +0900 Subject: [PATCH 1/3] Consider thumbnail image's mimeType when loading the vrm10 model. --- .../UniGLTF/IO/TextureIO/GltfTextureImporter.cs | 2 +- .../IO/Texture/Vrm10TextureDescriptorGenerator.cs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs index 753cecb1a..659288f37 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs @@ -31,7 +31,7 @@ namespace UniGLTF () => { var imageBytes = data.GetBytesFromImage(imageIndex); - return Task.FromResult<(byte[], string)?>((ToArray(imageBytes?.binary ?? default), null)); + return Task.FromResult<(byte[], string)?>((ToArray(imageBytes?.binary ?? default), imageBytes?.mimeType)); }, default, default, default, default, default); return (texDesc.SubAssetKey, texDesc); diff --git a/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs b/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs index b6e55d56c..7a6db9e79 100644 --- a/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs +++ b/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs @@ -10,6 +10,8 @@ namespace UniVRM10 { public sealed class Vrm10TextureDescriptorGenerator : ITextureDescriptorGenerator { + public const string UniqueThumbnailName = "thumbnail__VRM10"; + private readonly GltfData m_data; private TextureDescriptorSet _textureDescriptorSet; @@ -69,8 +71,6 @@ namespace UniVRM10 } } - public const string THUMBNAIL_NAME = "__VRM10_thumbnail__"; - /// /// VRM-1 の thumbnail テクスチャー。gltf.textures ではなく gltf.images の参照であることに注意(sampler等の設定が無い) /// @@ -99,12 +99,7 @@ namespace UniVRM10 // data.GLTF.textures は前処理によりユニーク性がある // unique な名前を振り出す var used = new HashSet(data.GLTF.textures.Select(x => x.name)); - var imageName = gltfImage.name; - if (string.IsNullOrEmpty(imageName)) - { - imageName = THUMBNAIL_NAME; - } - var uniqueName = GlbLowLevelParser.FixNameUnique(used, imageName); + var uniqueName = GlbLowLevelParser.FixNameUnique(used, UniqueThumbnailName); value = GltfTextureImporter.CreateSrgbFromOnlyImage(data, imageIndex, uniqueName, gltfImage.uri); return true; From 29c4686af4e3484611d3081310c165129c6dfd97 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 3 Nov 2022 18:30:09 +0900 Subject: [PATCH 2/3] Suppress warning logs when loading vrm10 models. --- .../Runtime/Texture/Importer/UnityTextureDeserializer.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs b/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs index 2d5a1b174..0dadbec63 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs @@ -17,8 +17,14 @@ namespace VRMShaders break; case "image/jpeg": break; + case "": + Debug.Log($"Texture image MIME type is empty."); + break; + case null: + Debug.Log($"Texture image MIME type is empty."); + break; default: - Debug.LogWarning($"Texture image MIME type `{textureInfo.DataMimeType}` is not supported."); + Debug.Log($"Texture image MIME type `{textureInfo.DataMimeType}` is not supported."); break; } From fd293b5f4c43a716f8df0cf1a0c5bd35ae192eb7 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 3 Nov 2022 18:34:13 +0900 Subject: [PATCH 3/3] fix --- .../Texture/Importer/UnityTextureDeserializer.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs b/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs index 0dadbec63..14ce16d55 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/Texture/Importer/UnityTextureDeserializer.cs @@ -17,14 +17,15 @@ namespace VRMShaders break; case "image/jpeg": break; - case "": - Debug.Log($"Texture image MIME type is empty."); - break; - case null: - Debug.Log($"Texture image MIME type is empty."); - break; default: - Debug.Log($"Texture image MIME type `{textureInfo.DataMimeType}` is not supported."); + if (string.IsNullOrEmpty(textureInfo.DataMimeType)) + { + Debug.Log($"Texture image MIME type is empty."); + } + else + { + Debug.Log($"Texture image MIME type `{textureInfo.DataMimeType}` is not supported."); + } break; }