Check Editor NormalMap.

This commit is contained in:
Masataka SUMI 2021-05-21 20:01:08 +09:00
parent 751e1697ce
commit c142e670bd

View File

@ -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;
}
}
}