From 570cef700dfa4115fa183825b50a37491c55843a Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 27 May 2021 15:43:57 +0900 Subject: [PATCH] mv TextureImportParam TextureDescriptor --- .../ScriptedImporter/TextureExtractor.cs | 2 +- .../IO/MaterialIO/GltfPbrMaterialImporter.cs | 8 ++--- .../MaterialImporterParamExtensions.cs | 2 +- .../IO/TextureIO/GltfPbrTextureImporter.cs | 10 +++---- .../GltfTextureDescriptorGenerator.cs | 2 +- .../IO/TextureIO/GltfTextureImporter.cs | 18 +++++------ .../VRM/Runtime/IO/VRMMToonTextureImporter.cs | 4 +-- .../IO/VrmTextureDescriptorGenerator.cs | 4 +-- .../IO/Texture/Vrm10MToonTextureImporter.cs | 24 +++++++-------- .../Vrm10TextureDescriptorGenerator.cs | 10 +++---- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 2 +- .../IO/Editor/TextureImporterConfigurator.cs | 22 +++++++------- .../GLTF/IO/Runtime/MaterialFactory.cs | 2 +- .../GLTF/IO/Runtime/MaterialImportParam.cs | 2 +- ...ureImportParam.cs => TextureDescriptor.cs} | 4 +-- ...aram.cs.meta => TextureDescriptor.cs.meta} | 0 .../GLTF/IO/Runtime/TextureDescriptorSet.cs | 12 ++++---- .../GLTF/IO/Runtime/TextureFactory.cs | 30 +++++++++---------- 18 files changed, 79 insertions(+), 79 deletions(-) rename Assets/VRMShaders/GLTF/IO/Runtime/{TextureImportParam.cs => TextureDescriptor.cs} (90%) rename Assets/VRMShaders/GLTF/IO/Runtime/{TextureImportParam.cs.meta => TextureDescriptor.cs.meta} (100%) diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs index a71934868..bc19ccd19 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs @@ -42,7 +42,7 @@ namespace UniGLTF return Path.GetExtension(uri).ToLower(); } - public void Extract(SubAssetKey key, TextureImportParam param) + public void Extract(SubAssetKey key, TextureDescriptor texDesc) { if (Textures.ContainsKey(key)) { diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs index 438bade49..749b05252 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/GltfPbrMaterialImporter.cs @@ -58,13 +58,13 @@ namespace UniGLTF var src = parser.GLTF.materials[i]; param = new MaterialImportParam(GltfMaterialImporter.GetMaterialName(i, src), ShaderName); - var standardParam = default(TextureImportParam); + var standardTexDesc = default(TextureDescriptor); if (src.pbrMetallicRoughness != null || src.occlusionTexture != null) { if (src.pbrMetallicRoughness.metallicRoughnessTexture != null || src.occlusionTexture != null) { SubAssetKey key; - (key, standardParam) = GltfPbrTextureImporter.StandardTexture(parser, src); + (key, standardTexDesc) = GltfPbrTextureImporter.StandardTexture(parser, src); } if (src.pbrMetallicRoughness.baseColorFactor != null && src.pbrMetallicRoughness.baseColorFactor.Length == 4) @@ -83,7 +83,7 @@ namespace UniGLTF if (src.pbrMetallicRoughness.metallicRoughnessTexture != null && src.pbrMetallicRoughness.metallicRoughnessTexture.index != -1) { param.Actions.Add(material => material.EnableKeyword("_METALLICGLOSSMAP")); - param.TextureSlots.Add("_MetallicGlossMap", standardParam); + param.TextureSlots.Add("_MetallicGlossMap", standardTexDesc); // Set 1.0f as hard-coded. See: https://github.com/dwango/UniVRM/issues/212. param.FloatValues.Add("_Metallic", 1.0f); param.FloatValues.Add("_GlossMapScale", 1.0f); @@ -105,7 +105,7 @@ namespace UniGLTF if (src.occlusionTexture != null && src.occlusionTexture.index != -1) { - param.TextureSlots.Add("_OcclusionMap", standardParam); + param.TextureSlots.Add("_OcclusionMap", standardTexDesc); param.FloatValues.Add("_OcclusionStrength", src.occlusionTexture.strength); } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialImporterParamExtensions.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialImporterParamExtensions.cs index 9f5994e6b..4a6ca5260 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialImporterParamExtensions.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialImporterParamExtensions.cs @@ -6,7 +6,7 @@ namespace UniGLTF { public static class MaterialImporterParamExtensions { - public static IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateSubAssetKeyValue(this MaterialImportParam param) + public static IEnumerable<(SubAssetKey, TextureDescriptor)> EnumerateSubAssetKeyValue(this MaterialImportParam param) { foreach (var kv in param.TextureSlots) { diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs index e0aec5a87..8ae11c0bf 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfPbrTextureImporter.cs @@ -5,7 +5,7 @@ namespace UniGLTF { public sealed class GltfPbrTextureImporter { - public static IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateAllTextures(GltfParser parser, int i) + public static IEnumerable<(SubAssetKey, TextureDescriptor)> EnumerateAllTextures(GltfParser parser, int i) { var m = parser.GLTF.materials[i]; @@ -51,13 +51,13 @@ namespace UniGLTF } } - public static (SubAssetKey, TextureImportParam Param) BaseColorTexture(GltfParser parser, glTFMaterial src) + public static (SubAssetKey, TextureDescriptor) BaseColorTexture(GltfParser parser, glTFMaterial src) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.pbrMetallicRoughness.baseColorTexture); return GltfTextureImporter.CreateSRGB(parser, src.pbrMetallicRoughness.baseColorTexture.index, offset, scale); } - public static (SubAssetKey, TextureImportParam) StandardTexture(GltfParser parser, glTFMaterial src) + public static (SubAssetKey, TextureDescriptor) StandardTexture(GltfParser parser, glTFMaterial src) { var metallicFactor = 1.0f; var roughnessFactor = 1.0f; @@ -75,13 +75,13 @@ namespace UniGLTF roughnessFactor); } - public static (SubAssetKey, TextureImportParam Param) NormalTexture(GltfParser parser, glTFMaterial src) + public static (SubAssetKey, TextureDescriptor) NormalTexture(GltfParser parser, glTFMaterial src) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.normalTexture); return GltfTextureImporter.CreateNormal(parser, src.normalTexture.index, offset, scale); } - public static (SubAssetKey, TextureImportParam Param) EmissiveTexture(GltfParser parser, glTFMaterial src) + public static (SubAssetKey, TextureDescriptor) EmissiveTexture(GltfParser parser, glTFMaterial src) { var (offset, scale) = GltfTextureImporter.GetTextureOffsetAndScale(src.emissiveTexture); return GltfTextureImporter.CreateSRGB(parser, src.emissiveTexture.index, offset, scale); diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureDescriptorGenerator.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureDescriptorGenerator.cs index 2bbcc621b..e4de690a4 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureDescriptorGenerator.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureDescriptorGenerator.cs @@ -51,7 +51,7 @@ namespace UniGLTF /// /// glTF 全体で使うテクスチャーを列挙。 /// - private static IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateAllTextures(GltfParser parser) + private static IEnumerable<(SubAssetKey, TextureDescriptor)> EnumerateAllTextures(GltfParser parser) { for (int i = 0; i < parser.GLTF.materials.Count; ++i) { diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs index 12521f27b..34df1d9d7 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs @@ -29,40 +29,40 @@ namespace UniGLTF } } - public static (SubAssetKey, TextureImportParam Param) CreateSRGB(GltfParser parser, int textureIndex, Vector2 offset, Vector2 scale) + public static (SubAssetKey, TextureDescriptor) CreateSRGB(GltfParser parser, int textureIndex, Vector2 offset, Vector2 scale) { var gltfTexture = parser.GLTF.textures[textureIndex]; var gltfImage = parser.GLTF.images[gltfTexture.source]; var name = TextureImportName.GetUnityObjectName(TextureImportTypes.sRGB, gltfTexture.name, gltfImage.uri); var sampler = TextureSamplerUtil.CreateSampler(parser.GLTF, textureIndex); GetTextureBytesAsync getTextureBytesAsync = () => Task.FromResult(ToArray(parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, textureIndex))); - var param = new TextureImportParam(name, gltfImage.GetExt(), gltfImage.uri, offset, scale, sampler, TextureImportTypes.sRGB, default, default, getTextureBytesAsync, default, default, default, default, default); + var param = new TextureDescriptor(name, gltfImage.GetExt(), gltfImage.uri, offset, scale, sampler, TextureImportTypes.sRGB, default, default, getTextureBytesAsync, default, default, default, default, default); return (param.SubAssetKey, param); } - public static (SubAssetKey, TextureImportParam Param) CreateLinear(GltfParser parser, int textureIndex, Vector2 offset, Vector2 scale) + public static (SubAssetKey, TextureDescriptor) CreateLinear(GltfParser parser, int textureIndex, Vector2 offset, Vector2 scale) { var gltfTexture = parser.GLTF.textures[textureIndex]; var gltfImage = parser.GLTF.images[gltfTexture.source]; var name = TextureImportName.GetUnityObjectName(TextureImportTypes.Linear, gltfTexture.name, gltfImage.uri); var sampler = TextureSamplerUtil.CreateSampler(parser.GLTF, textureIndex); GetTextureBytesAsync getTextureBytesAsync = () => Task.FromResult(ToArray(parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, textureIndex))); - var param = new TextureImportParam(name, gltfImage.GetExt(), gltfImage.uri, offset, scale, sampler, TextureImportTypes.Linear, default, default, getTextureBytesAsync, default, default, default, default, default); + var param = new TextureDescriptor(name, gltfImage.GetExt(), gltfImage.uri, offset, scale, sampler, TextureImportTypes.Linear, default, default, getTextureBytesAsync, default, default, default, default, default); return (param.SubAssetKey, param); } - public static (SubAssetKey, TextureImportParam Param) CreateNormal(GltfParser parser, int textureIndex, Vector2 offset, Vector2 scale) + public static (SubAssetKey, TextureDescriptor) CreateNormal(GltfParser parser, int textureIndex, Vector2 offset, Vector2 scale) { var gltfTexture = parser.GLTF.textures[textureIndex]; var gltfImage = parser.GLTF.images[gltfTexture.source]; var name = TextureImportName.GetUnityObjectName(TextureImportTypes.NormalMap, gltfTexture.name, gltfImage.uri); var sampler = TextureSamplerUtil.CreateSampler(parser.GLTF, textureIndex); GetTextureBytesAsync getTextureBytesAsync = () => Task.FromResult(ToArray(parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, textureIndex))); - var param = new TextureImportParam(name, gltfImage.GetExt(), gltfImage.uri, offset, scale, sampler, TextureImportTypes.NormalMap, default, default, getTextureBytesAsync, default, default, default, default, default); + var param = new TextureDescriptor(name, gltfImage.GetExt(), gltfImage.uri, offset, scale, sampler, TextureImportTypes.NormalMap, default, default, getTextureBytesAsync, default, default, default, default, default); return (param.SubAssetKey, param); } - public static (SubAssetKey, TextureImportParam Param) CreateStandard(GltfParser parser, int? metallicRoughnessTextureIndex, int? occlusionTextureIndex, Vector2 offset, Vector2 scale, float metallicFactor, float roughnessFactor) + public static (SubAssetKey, TextureDescriptor) CreateStandard(GltfParser parser, int? metallicRoughnessTextureIndex, int? occlusionTextureIndex, Vector2 offset, Vector2 scale, float metallicFactor, float roughnessFactor) { string name = default; @@ -88,8 +88,8 @@ namespace UniGLTF getOcclusionAsync = () => Task.FromResult(ToArray(parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, occlusionTextureIndex.Value))); } - var param = new TextureImportParam(name, ".png", null, offset, scale, sampler, TextureImportTypes.StandardMap, metallicFactor, roughnessFactor, getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default); - return (param.SubAssetKey, param); + var texDesc = new TextureDescriptor(name, ".png", null, offset, scale, sampler, TextureImportTypes.StandardMap, metallicFactor, roughnessFactor, getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default); + return (texDesc.SubAssetKey, texDesc); } public static (Vector2, Vector2) GetTextureOffsetAndScale(glTFTextureInfo textureInfo) diff --git a/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs b/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs index 37d84cc75..c051745c2 100644 --- a/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs +++ b/Assets/VRM/Runtime/IO/VRMMToonTextureImporter.cs @@ -7,7 +7,7 @@ namespace VRM { public static class VRMMToonTextureImporter { - public static IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateAllTextures(GltfParser parser, glTF_VRM_extensions vrm, int materialIdx) + public static IEnumerable<(SubAssetKey, TextureDescriptor)> EnumerateAllTextures(GltfParser parser, glTF_VRM_extensions vrm, int materialIdx) { var vrmMaterial = vrm.materialProperties[materialIdx]; foreach (var kv in vrmMaterial.textureProperties) @@ -19,7 +19,7 @@ namespace VRM } } - public static bool TryGetTextureFromMaterialProperty(GltfParser parser, glTF_VRM_extensions vrm, int materialIdx, string textureKey, out (SubAssetKey, TextureImportParam) texture) + public static bool TryGetTextureFromMaterialProperty(GltfParser parser, glTF_VRM_extensions vrm, int materialIdx, string textureKey, out (SubAssetKey, TextureDescriptor) texture) { var vrmMaterial = vrm.materialProperties[materialIdx]; if (vrmMaterial.shader == MToon.Utils.ShaderName && vrmMaterial.textureProperties.TryGetValue(textureKey, out var textureIdx)) diff --git a/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs b/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs index 18f40a630..babf987cd 100644 --- a/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs +++ b/Assets/VRM/Runtime/IO/VrmTextureDescriptorGenerator.cs @@ -32,7 +32,7 @@ namespace VRM } - private static IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateAllTextures(GltfParser parser, glTF_VRM_extensions vrm) + private static IEnumerable<(SubAssetKey, TextureDescriptor)> EnumerateAllTextures(GltfParser parser, glTF_VRM_extensions vrm) { // Materials for (var materialIdx = 0; materialIdx < parser.GLTF.materials.Count; ++materialIdx) @@ -65,7 +65,7 @@ namespace VRM } } - private static bool TryGetThumbnailTexture(GltfParser parser, glTF_VRM_extensions vrm, out (SubAssetKey, TextureImportParam) texture) + private static bool TryGetThumbnailTexture(GltfParser parser, glTF_VRM_extensions vrm, out (SubAssetKey, TextureDescriptor) texture) { if (vrm.meta.texture > -1) { diff --git a/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs b/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs index 30f482a27..bbdeb3531 100644 --- a/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs +++ b/Assets/VRM10/Runtime/IO/Texture/Vrm10MToonTextureImporter.cs @@ -9,7 +9,7 @@ namespace UniVRM10 { public static class Vrm10MToonTextureImporter { - public static IEnumerable<(string key, (SubAssetKey, TextureImportParam))> EnumerateAllTextures(GltfParser parser, glTFMaterial material, VRMC_materials_mtoon mToon) + public static IEnumerable<(string key, (SubAssetKey, TextureDescriptor))> EnumerateAllTextures(GltfParser parser, glTFMaterial material, VRMC_materials_mtoon mToon) { if (TryGetBaseColorTexture(parser, material, out var litTex)) { @@ -58,7 +58,7 @@ namespace UniVRM10 } } - private static bool TryGetBaseColorTexture(GltfParser parser, glTFMaterial src, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetBaseColorTexture(GltfParser parser, glTFMaterial src, out (SubAssetKey, TextureDescriptor) pair) { try { @@ -77,7 +77,7 @@ namespace UniVRM10 } } - private static bool TryGetEmissiveTexture(GltfParser parser, glTFMaterial src, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetEmissiveTexture(GltfParser parser, glTFMaterial src, out (SubAssetKey, TextureDescriptor) pair) { try { @@ -97,7 +97,7 @@ namespace UniVRM10 } - private static bool TryGetNormalTexture(GltfParser parser, glTFMaterial src, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetNormalTexture(GltfParser parser, glTFMaterial src, out (SubAssetKey, TextureDescriptor) pair) { try { @@ -116,37 +116,37 @@ namespace UniVRM10 } } - private static bool TryGetShadeMultiplyTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetShadeMultiplyTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) { return TryGetSRGBTexture(parser, new Vrm10TextureInfo(mToon.ShadeMultiplyTexture), out pair); } - private static bool TryGetShadingShiftTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetShadingShiftTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) { return TryGetLinearTexture(parser, new Vrm10TextureInfo(mToon.ShadingShiftTexture), out pair); } - private static bool TryGetMatcapTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetMatcapTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) { return TryGetSRGBTexture(parser, new Vrm10TextureInfo(mToon.ShadingShiftTexture), out pair); } - private static bool TryGetRimMultiplyTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetRimMultiplyTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) { return TryGetSRGBTexture(parser, new Vrm10TextureInfo(mToon.RimMultiplyTexture), out pair); } - private static bool TryGetOutlineWidthMultiplyTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetOutlineWidthMultiplyTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) { return TryGetLinearTexture(parser, new Vrm10TextureInfo(mToon.OutlineWidthMultiplyTexture), out pair); } - private static bool TryGetUvAnimationMaskTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetUvAnimationMaskTexture(GltfParser parser, VRMC_materials_mtoon mToon, out (SubAssetKey, TextureDescriptor) pair) { return TryGetLinearTexture(parser, new Vrm10TextureInfo(mToon.UvAnimationMaskTexture), out pair); } - private static bool TryGetSRGBTexture(GltfParser parser, Vrm10TextureInfo info, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetSRGBTexture(GltfParser parser, Vrm10TextureInfo info, out (SubAssetKey, TextureDescriptor) pair) { try { @@ -165,7 +165,7 @@ namespace UniVRM10 return false; } } - private static bool TryGetLinearTexture(GltfParser parser, Vrm10TextureInfo info, out (SubAssetKey, TextureImportParam) pair) + private static bool TryGetLinearTexture(GltfParser parser, Vrm10TextureInfo info, out (SubAssetKey, TextureDescriptor) pair) { try { diff --git a/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs b/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs index f8980890d..95718dad2 100644 --- a/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs +++ b/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs @@ -33,7 +33,7 @@ namespace UniVRM10 /// /// glTF 全体で使うテクスチャーを列挙する /// - private static IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateAllTextures(GltfParser parser) + private static IEnumerable<(SubAssetKey, TextureDescriptor)> EnumerateAllTextures(GltfParser parser) { if (!UniGLTF.Extensions.VRMC_vrm.GltfDeserializer.TryGet(parser.GLTF.extensions, out UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm)) { @@ -62,7 +62,7 @@ namespace UniVRM10 } // Thumbnail Texture referenced by VRM Meta. - if (TryGetMetaThumbnailTextureImportParam(parser, vrm, out (SubAssetKey key, TextureImportParam) thumbnail)) + if (TryGetMetaThumbnailTextureImportParam(parser, vrm, out (SubAssetKey key, TextureDescriptor) thumbnail)) { yield return thumbnail; } @@ -71,7 +71,7 @@ namespace UniVRM10 /// /// VRM-1 の thumbnail テクスチャー。gltf.textures ではなく gltf.images の参照であることに注意(sampler等の設定が無い) /// - public static bool TryGetMetaThumbnailTextureImportParam(GltfParser parser, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm, out (SubAssetKey, TextureImportParam) value) + public static bool TryGetMetaThumbnailTextureImportParam(GltfParser parser, UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm, out (SubAssetKey, TextureDescriptor) value) { if (vrm?.Meta?.ThumbnailImage == null) { @@ -88,11 +88,11 @@ namespace UniVRM10 var bytes = parser.GLTF.GetImageBytes(parser.Storage, imageIndex); return Task.FromResult(GltfTextureImporter.ToArray(bytes)); }; - var param = new TextureImportParam(name, gltfImage.GetExt(), gltfImage.uri, Vector2.zero, Vector2.one, default, TextureImportTypes.sRGB, default, default, + var texDesc = new TextureDescriptor(name, gltfImage.GetExt(), gltfImage.uri, Vector2.zero, Vector2.one, default, TextureImportTypes.sRGB, default, default, getThumbnailImageBytesAsync, default, default, default, default, default ); - value = (param.SubAssetKey, param); + value = (texDesc.SubAssetKey, texDesc); return true; } } diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index c961ab03f..5ff75415c 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -281,7 +281,7 @@ namespace UniVRM10 { m_meta.Authors.AddRange(src.Authors); } - if (Vrm10TextureDescriptorGenerator.TryGetMetaThumbnailTextureImportParam(Parser, vrm, out (SubAssetKey, VRMShaders.TextureImportParam Param) kv)) + if (Vrm10TextureDescriptorGenerator.TryGetMetaThumbnailTextureImportParam(Parser, vrm, out (SubAssetKey, VRMShaders.TextureDescriptor Param) kv)) { var texture = await TextureFactory.GetTextureAsync(kv.Param); if (texture is Texture2D tex2D) diff --git a/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs b/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs index 494a597d1..3ec6ad6cf 100644 --- a/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs +++ b/Assets/VRMShaders/GLTF/IO/Editor/TextureImporterConfigurator.cs @@ -38,12 +38,12 @@ namespace VRMShaders textureImporter.SaveAndReimport(); } - public static void ConfigureSampler(TextureImportParam param, TextureImporter textureImporter) + public static void ConfigureSampler(TextureDescriptor texDesc, TextureImporter textureImporter) { - textureImporter.mipmapEnabled = param.Sampler.EnableMipMap; - textureImporter.filterMode = param.Sampler.FilterMode; - textureImporter.wrapModeU = param.Sampler.WrapModesU; - textureImporter.wrapModeV = param.Sampler.WrapModesV; + textureImporter.mipmapEnabled = texDesc.Sampler.EnableMipMap; + textureImporter.filterMode = texDesc.Sampler.FilterMode; + textureImporter.wrapModeU = texDesc.Sampler.WrapModesU; + textureImporter.wrapModeV = texDesc.Sampler.WrapModesV; } class ImporterGetter : IDisposable @@ -84,9 +84,9 @@ namespace VRMShaders } } - static void Configure(TextureImportParam textureInfo, Texture external, TextureImporter importer) + static void Configure(TextureDescriptor texDesc, Texture external, TextureImporter importer) { - switch (textureInfo.TextureType) + switch (texDesc.TextureType) { case TextureImportTypes.NormalMap: { @@ -119,18 +119,18 @@ namespace VRMShaders throw new NotImplementedException(); } - ConfigureSampler(textureInfo, importer); + ConfigureSampler(texDesc, importer); } - public static void Configure(TextureImportParam textureInfo, IReadOnlyDictionary ExternalMap) + public static void Configure(TextureDescriptor texDesc, IReadOnlyDictionary ExternalMap) { - if (ExternalMap.TryGetValue(textureInfo.SubAssetKey, out Texture external)) + if (ExternalMap.TryGetValue(texDesc.SubAssetKey, out Texture external)) { if (ImporterGetter.TryGetImporter(external, out ImporterGetter getter)) { using (getter) { - Configure(textureInfo, external, getter.Importer); + Configure(texDesc, external, getter.Importer); } } } diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/MaterialFactory.cs b/Assets/VRMShaders/GLTF/IO/Runtime/MaterialFactory.cs index 821f063b2..de0bc9ecb 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/MaterialFactory.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/MaterialFactory.cs @@ -7,7 +7,7 @@ using UnityEngine; namespace VRMShaders { - public delegate Task GetTextureAsyncFunc(TextureImportParam param); + public delegate Task GetTextureAsyncFunc(TextureDescriptor texDesc); public class MaterialFactory : IDisposable { diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/MaterialImportParam.cs b/Assets/VRMShaders/GLTF/IO/Runtime/MaterialImportParam.cs index 29e75ae37..447c09f2f 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/MaterialImportParam.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/MaterialImportParam.cs @@ -9,7 +9,7 @@ namespace VRMShaders { public readonly string Name; public readonly string ShaderName; - public readonly Dictionary TextureSlots = new Dictionary(); + public readonly Dictionary TextureSlots = new Dictionary(); public readonly Dictionary FloatValues = new Dictionary(); public readonly Dictionary Colors = new Dictionary(); public readonly Dictionary Vectors = new Dictionary(); diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportParam.cs b/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptor.cs similarity index 90% rename from Assets/VRMShaders/GLTF/IO/Runtime/TextureImportParam.cs rename to Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptor.cs index 0f99d4e0c..218ebcad6 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportParam.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptor.cs @@ -18,7 +18,7 @@ namespace VRMShaders /// /// 入力 glTF ファイルを Import した結果生成される、UnityEngine.Texture のアセット 1 つを確定させる Import 情報。 /// - public readonly struct TextureImportParam + public readonly struct TextureDescriptor { public readonly string UnityObjectName; public readonly string Ext; @@ -46,7 +46,7 @@ namespace VRMShaders /// public SubAssetKey SubAssetKey => new SubAssetKey(SubAssetKey.TextureType, UnityObjectName); - public TextureImportParam(string name, string ext, string uri, Vector2 offset, Vector2 scale, SamplerParam sampler, TextureImportTypes textureType, float metallicFactor, float roughnessFactor, + public TextureDescriptor(string name, string ext, string uri, Vector2 offset, Vector2 scale, SamplerParam sampler, TextureImportTypes textureType, float metallicFactor, float roughnessFactor, GetTextureBytesAsync i0, GetTextureBytesAsync i1, GetTextureBytesAsync i2, diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportParam.cs.meta b/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptor.cs.meta similarity index 100% rename from Assets/VRMShaders/GLTF/IO/Runtime/TextureImportParam.cs.meta rename to Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptor.cs.meta diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptorSet.cs b/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptorSet.cs index 2ec347576..a06ebd2c4 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptorSet.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureDescriptorSet.cs @@ -7,18 +7,18 @@ namespace VRMShaders /// public sealed class TextureDescriptorSet { - private readonly Dictionary _params = new Dictionary(); + private readonly Dictionary _texDescDict = new Dictionary(); - public void Add(TextureImportParam param) + public void Add(TextureDescriptor texDesc) { - if (_params.ContainsKey(param.SubAssetKey)) return; + if (_texDescDict.ContainsKey(texDesc.SubAssetKey)) return; - _params.Add(param.SubAssetKey, param); + _texDescDict.Add(texDesc.SubAssetKey, texDesc); } - public IEnumerable GetEnumerable() + public IEnumerable GetEnumerable() { - foreach (var kv in _params) + foreach (var kv in _texDescDict) { yield return kv.Value; } diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureFactory.cs b/Assets/VRMShaders/GLTF/IO/Runtime/TextureFactory.cs index a9c1e28a9..ac1258a00 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/TextureFactory.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureFactory.cs @@ -81,9 +81,9 @@ namespace VRMShaders /// METALLIC_GLOSS_PROPの追加パラメーター /// gltf の texture index /// - public async Task GetTextureAsync(TextureImportParam param) + public async Task GetTextureAsync(TextureDescriptor texDesc) { - var subAssetKey = param.SubAssetKey; + var subAssetKey = texDesc.SubAssetKey; if (m_externalMap != null && m_externalMap.TryGetValue(subAssetKey, out var externalTexture)) { @@ -95,15 +95,15 @@ namespace VRMShaders return cachedTexture; } - switch (param.TextureType) + switch (texDesc.TextureType) { case TextureImportTypes.NormalMap: { // Runtime/SubAsset 用に変換する - var rawTexture = await LoadTextureAsync(param.Index0, param.Sampler.EnableMipMap, ColorSpace.Linear); + var rawTexture = await LoadTextureAsync(texDesc.Index0, texDesc.Sampler.EnableMipMap, ColorSpace.Linear); var convertedTexture = NormalConverter.Import(rawTexture); convertedTexture.name = subAssetKey.Name; - convertedTexture.SetSampler(param.Sampler); + convertedTexture.SetSampler(texDesc.Sampler); m_textureCache.Add(subAssetKey, convertedTexture); DestroyResource(rawTexture); return convertedTexture; @@ -114,19 +114,19 @@ namespace VRMShaders Texture2D metallicRoughnessTexture = default; Texture2D occlusionTexture = default; - if (param.Index0 != null) + if (texDesc.Index0 != null) { - metallicRoughnessTexture = await LoadTextureAsync(param.Index0, param.Sampler.EnableMipMap, ColorSpace.Linear); + metallicRoughnessTexture = await LoadTextureAsync(texDesc.Index0, texDesc.Sampler.EnableMipMap, ColorSpace.Linear); } - if (param.Index1 != null) + if (texDesc.Index1 != null) { - occlusionTexture = await LoadTextureAsync(param.Index1, param.Sampler.EnableMipMap, ColorSpace.Linear); + occlusionTexture = await LoadTextureAsync(texDesc.Index1, texDesc.Sampler.EnableMipMap, ColorSpace.Linear); } var combinedTexture = OcclusionMetallicRoughnessConverter.Import(metallicRoughnessTexture, - param.MetallicFactor, param.RoughnessFactor, occlusionTexture); + texDesc.MetallicFactor, texDesc.RoughnessFactor, occlusionTexture); combinedTexture.name = subAssetKey.Name; - combinedTexture.SetSampler(param.Sampler); + combinedTexture.SetSampler(texDesc.Sampler); m_textureCache.Add(subAssetKey, combinedTexture); DestroyResource(metallicRoughnessTexture); DestroyResource(occlusionTexture); @@ -135,17 +135,17 @@ namespace VRMShaders case TextureImportTypes.sRGB: { - var rawTexture = await LoadTextureAsync(param.Index0, param.Sampler.EnableMipMap, ColorSpace.sRGB); + var rawTexture = await LoadTextureAsync(texDesc.Index0, texDesc.Sampler.EnableMipMap, ColorSpace.sRGB); rawTexture.name = subAssetKey.Name; - rawTexture.SetSampler(param.Sampler); + rawTexture.SetSampler(texDesc.Sampler); m_textureCache.Add(subAssetKey, rawTexture); return rawTexture; } case TextureImportTypes.Linear: { - var rawTexture = await LoadTextureAsync(param.Index0, param.Sampler.EnableMipMap, ColorSpace.Linear); + var rawTexture = await LoadTextureAsync(texDesc.Index0, texDesc.Sampler.EnableMipMap, ColorSpace.Linear); rawTexture.name = subAssetKey.Name; - rawTexture.SetSampler(param.Sampler); + rawTexture.SetSampler(texDesc.Sampler); m_textureCache.Add(subAssetKey, rawTexture); return rawTexture; }