From c142e670bdf8ca0e32d4c4e96794fd4bf48a9abb Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 21 May 2021 20:01:08 +0900 Subject: [PATCH] Check Editor NormalMap. --- .../GLTF/IO/Editor/EditorTextureSerializer.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Assets/VRMShaders/GLTF/IO/Editor/EditorTextureSerializer.cs b/Assets/VRMShaders/GLTF/IO/Editor/EditorTextureSerializer.cs index 5bdb32a2c..88da013ea 100644 --- a/Assets/VRMShaders/GLTF/IO/Editor/EditorTextureSerializer.cs +++ b/Assets/VRMShaders/GLTF/IO/Editor/EditorTextureSerializer.cs @@ -33,6 +33,29 @@ namespace VRMShaders // Equals color space ? if (!IsFileColorSpaceSameWithExportColorSpace(texture2D, textureImporter, exportColorSpace)) return false; + // Each Texture Importer Type Validation + switch (textureImporter.textureType) + { + case TextureImporterType.Default: + break; + case TextureImporterType.NormalMap: + if (!IsCorrectNormalMap(texture2D, textureImporter)) return false; + break; + case TextureImporterType.GUI: + case TextureImporterType.Sprite: + case TextureImporterType.Cursor: + case TextureImporterType.Cubemap: + case TextureImporterType.Cookie: + case TextureImporterType.Lightmap: + case TextureImporterType.HDRI: + case TextureImporterType.Advanced: + case TextureImporterType.SingleChannel: + // Not Supported TextureImporterType + return false; + default: + throw new ArgumentOutOfRangeException(); + } + return true; } @@ -139,5 +162,15 @@ namespace VRMShaders throw new ArgumentOutOfRangeException(nameof(colorSpace), colorSpace, null); } } + + private bool IsCorrectNormalMap(Texture2D texture, TextureImporter textureImporter) + { + if (textureImporter.textureType != TextureImporterType.NormalMap) return false; + + // Is Not generated from HeightMap ? + if (textureImporter.convertToNormalmap) return false; + + return true; + } } }