diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/EditorMaterial.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/EditorMaterial.cs index 737b695a3..c9d2e3ef0 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/EditorMaterial.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/EditorMaterial.cs @@ -61,7 +61,7 @@ namespace UniGLTF { switch (x.TextureType) { - case GetTextureParam.TextureTypes.NormalMap: + case TextureImportTypes.NormalMap: return x.GltfName; default: diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs index ff13e7718..6857bf7e7 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ScriptedImporterImpl.cs @@ -78,7 +78,7 @@ namespace UniGLTF { switch (texParam.TextureType) { - case GetTextureParam.TextureTypes.StandardMap: + case TextureImportTypes.StandardMap: break; default: diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs index 957a5e469..2bfbd465b 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs @@ -58,7 +58,7 @@ namespace UniGLTF switch (param.TextureType) { - case GetTextureParam.TextureTypes.StandardMap: + case TextureImportTypes.StandardMap: { // write converted texture var subAsset = m_subAssets.FirstOrDefault(x => x.name == param.ConvertedName); diff --git a/Assets/UniGLTF/Editor/UniGLTF/TextureImporterConfigurator.cs b/Assets/UniGLTF/Editor/UniGLTF/TextureImporterConfigurator.cs index 941ea62a7..270c253cb 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/TextureImporterConfigurator.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/TextureImporterConfigurator.cs @@ -66,7 +66,7 @@ namespace UniGLTF { switch (textureInfo.TextureType) { - case GetTextureParam.TextureTypes.NormalMap: + case TextureImportTypes.NormalMap: { if (ExternalMap.TryGetValue(textureInfo.GltfName, out Texture2D external)) { @@ -76,7 +76,7 @@ namespace UniGLTF } break; - case GetTextureParam.TextureTypes.StandardMap: + case TextureImportTypes.StandardMap: { if (ExternalMap.TryGetValue(textureInfo.ConvertedName, out Texture2D external)) { @@ -86,7 +86,7 @@ namespace UniGLTF } break; - case GetTextureParam.TextureTypes.sRGB: + case TextureImportTypes.sRGB: { if (ExternalMap.TryGetValue(textureInfo.GltfName, out Texture2D external)) { diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs index 58798c730..87dd7a26b 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureFactory.cs @@ -56,7 +56,7 @@ namespace UniGLTF if (param.Index0!=null && ExternalMap != null) { var cacheName = param.ConvertedName; - if (param.TextureType == GetTextureParam.TextureTypes.NormalMap) + if (param.TextureType == TextureImportTypes.NormalMap) { cacheName = param.GltfName; if (m_textureCache.TryGetValue(cacheName, out TextureLoadInfo normalInfo)) @@ -236,7 +236,7 @@ namespace UniGLTF switch (param.TextureType) { - case GetTextureParam.TextureTypes.NormalMap: + case TextureImportTypes.NormalMap: { var baseTexture = await GetOrCreateBaseTexture(awaitCaller, param, param.Index0, RenderTextureReadWrite.Linear, false); var converted = NormalConverter.Import(baseTexture.Texture); @@ -246,7 +246,7 @@ namespace UniGLTF return info.Texture; } - case GetTextureParam.TextureTypes.StandardMap: + case TextureImportTypes.StandardMap: { TextureLoadInfo baseTexture = default; if (param.Index0!=null) @@ -277,18 +277,18 @@ namespace UniGLTF public static GetTextureParam CreateSRGB(GltfParser parser, int textureIndex) { - var name = CreateNameExt(parser.GLTF, textureIndex, GetTextureParam.TextureTypes.sRGB); + var name = CreateNameExt(parser.GLTF, textureIndex, TextureImportTypes.sRGB); var sampler = CreateSampler(parser.GLTF, textureIndex); GetTextureBytesAsync getTextureBytesAsync = async () => parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, textureIndex); - return new GetTextureParam(name, sampler, GetTextureParam.TextureTypes.sRGB, default, default, getTextureBytesAsync, default, default, default, default, default); + return new GetTextureParam(name, sampler, TextureImportTypes.sRGB, default, default, getTextureBytesAsync, default, default, default, default, default); } public static GetTextureParam CreateNormal(GltfParser parser, int textureIndex) { - var name = CreateNameExt(parser.GLTF, textureIndex, GetTextureParam.TextureTypes.NormalMap); + var name = CreateNameExt(parser.GLTF, textureIndex, TextureImportTypes.NormalMap); var sampler = CreateSampler(parser.GLTF, textureIndex); GetTextureBytesAsync getTextureBytesAsync = async () => parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, textureIndex); - return new GetTextureParam(name, sampler, GetTextureParam.TextureTypes.NormalMap, default, default, getTextureBytesAsync, default, default, default, default, default); + return new GetTextureParam(name, sampler, TextureImportTypes.NormalMap, default, default, getTextureBytesAsync, default, default, default, default, default); } public static GetTextureParam CreateStandard(GltfParser parser, int? metallicRoughnessTextureIndex, int? occlusionTextureIndex, float metallicFactor, float roughnessFactor) @@ -299,7 +299,7 @@ namespace UniGLTF GetTextureParam.TextureSamplerParam sampler = default; if (metallicRoughnessTextureIndex.HasValue) { - name = CreateNameExt(parser.GLTF, metallicRoughnessTextureIndex.Value, GetTextureParam.TextureTypes.StandardMap); + name = CreateNameExt(parser.GLTF, metallicRoughnessTextureIndex.Value, TextureImportTypes.StandardMap); sampler = CreateSampler(parser.GLTF, metallicRoughnessTextureIndex.Value); getMetallicRoughnessAsync = async () => parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, metallicRoughnessTextureIndex.Value); } @@ -308,13 +308,13 @@ namespace UniGLTF if (occlusionTextureIndex.HasValue) { if(string.IsNullOrEmpty(name.GltfName)){ - name = CreateNameExt(parser.GLTF, occlusionTextureIndex.Value, GetTextureParam.TextureTypes.StandardMap); + name = CreateNameExt(parser.GLTF, occlusionTextureIndex.Value, TextureImportTypes.StandardMap); } sampler = CreateSampler(parser.GLTF, occlusionTextureIndex.Value); getOcclusionAsync = async () => parser.GLTF.GetImageBytesFromTextureIndex(parser.Storage, occlusionTextureIndex.Value); } - return new GetTextureParam(name, sampler, GetTextureParam.TextureTypes.StandardMap, metallicFactor, roughnessFactor, getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default); + return new GetTextureParam(name, sampler, TextureImportTypes.StandardMap, metallicFactor, roughnessFactor, getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default); } public static GetTextureParam Create(GltfParser parser, int index, string prop, float metallicFactor, float roughnessFactor) @@ -333,7 +333,7 @@ namespace UniGLTF } } - public static GetTextureParam.NameExt CreateNameExt(glTF gltf, int textureIndex, GetTextureParam.TextureTypes textureType) + public static GetTextureParam.NameExt CreateNameExt(glTF gltf, int textureIndex, TextureImportTypes textureType) { if (textureIndex < 0 || textureIndex >= gltf.textures.Count) { diff --git a/Assets/VRMShaders/Runtime/GetTextureParam.cs b/Assets/VRMShaders/Runtime/GetTextureParam.cs index 624aa01c6..bdfc7847d 100644 --- a/Assets/VRMShaders/Runtime/GetTextureParam.cs +++ b/Assets/VRMShaders/Runtime/GetTextureParam.cs @@ -19,15 +19,6 @@ namespace VRMShaders public const string OCCLUSION_PROP = "_OcclusionMap"; public const string STANDARD_SUFFIX = ".standard"; - public enum TextureTypes - { - sRGB, - NormalMap, - // Occlusion + Metallic + Smoothness - StandardMap, - Linear, - } - public static string RemoveSuffix(string src) { if (src.EndsWith(NORMAL_SUFFIX)) @@ -64,12 +55,12 @@ namespace VRMShaders public string ConvertedFileName => $"{ConvertedName}.png"; - public static string Convert(string name, TextureTypes textureType) + public static string Convert(string name, TextureImportTypes textureType) { switch (textureType) { - case TextureTypes.StandardMap: return $"{name}{STANDARD_SUFFIX}"; - case TextureTypes.NormalMap: return $"{name}{NORMAL_SUFFIX}"; + case TextureImportTypes.StandardMap: return $"{name}{STANDARD_SUFFIX}"; + case TextureImportTypes.NormalMap: return $"{name}{NORMAL_SUFFIX}"; default: return name; } } @@ -98,7 +89,7 @@ namespace VRMShaders public TextureSamplerParam Sampler; - public readonly TextureTypes TextureType; + public readonly TextureImportTypes TextureType; public readonly float MetallicFactor; public readonly float RoughnessFactor; @@ -112,9 +103,9 @@ namespace VRMShaders /// /// この種類は RGB チャンネルの組み換えが必用 /// - public bool ExtractConverted => TextureType == TextureTypes.StandardMap; + public bool ExtractConverted => TextureType == TextureImportTypes.StandardMap; - public GetTextureParam(NameExt name, TextureSamplerParam sampler, TextureTypes textureType, float metallicFactor, float roughnessFactor, + public GetTextureParam(NameExt name, TextureSamplerParam sampler, TextureImportTypes textureType, float metallicFactor, float roughnessFactor, GetTextureBytesAsync i0, GetTextureBytesAsync i1, GetTextureBytesAsync i2, diff --git a/Assets/VRMShaders/Runtime/TextureImportTypes.cs b/Assets/VRMShaders/Runtime/TextureImportTypes.cs new file mode 100644 index 000000000..7280368ea --- /dev/null +++ b/Assets/VRMShaders/Runtime/TextureImportTypes.cs @@ -0,0 +1,28 @@ +namespace VRMShaders +{ + public enum TextureImportTypes + { + // runtime: + // new Texture2D(linear = false) + // extract: + sRGB, + // runtime: + // new Texture2D(linear = true) + // encode to DXT5nm + // extract: + // TextureImporter.textureType = TextureImporterType.NormalMap; + NormalMap, + // runtime: + // new Texture2D(linear = true) + // converted(Occlusion + Metallic + Smoothness) + // extract: + // converted(Occlusion + Metallic + Smoothness) + // TextureImporter.sRGBTexture = false; + StandardMap, + // runtime: + // new Texture2D(linear = true) + // extract: + // TextureImporter.sRGBTexture = false; + Linear, + } +} diff --git a/Assets/VRMShaders/Runtime/TextureImportTypes.cs.meta b/Assets/VRMShaders/Runtime/TextureImportTypes.cs.meta new file mode 100644 index 000000000..391c88003 --- /dev/null +++ b/Assets/VRMShaders/Runtime/TextureImportTypes.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b30953f01d374784e8e4de02d649cb06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: