From c4e3f53d5d97c099d0481e84230db0fcc2e0dc58 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 23:52:55 +0900 Subject: [PATCH] Move Test Assets --- Assets/UniGLTF/Tests/Objects.meta | 8 ++++ .../4x4_gray_import_as_linear.png | Bin .../4x4_gray_import_as_linear.png.meta | 17 +++++++- .../4x4_gray_import_as_normal_map.png | Bin .../4x4_gray_import_as_normal_map.png.meta | 17 +++++++- .../4x4_gray_import_as_srgb.png | Bin .../4x4_gray_import_as_srgb.png.meta | 17 +++++++- .../{UniGLTF => Objects}/4x4_non_readable.png | Bin .../4x4_non_readable.png.meta | 0 .../4x4_non_readable_compressed.DDS | Bin .../4x4_non_readable_compressed.DDS.meta | 0 .../{UniGLTF => Objects}/New Material.mat | 0 .../New Material.mat.meta | 0 .../UniGLTF/Tests/UniGLTF/CopyTextureTests.cs | 9 ++--- .../UniGLTF/EditorTextureSerializerTests.cs | 37 ++++++++++-------- Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs | 12 ++++++ .../UniGLTF/Tests/UniGLTF/TestAssets.cs.meta | 3 ++ .../Tests/UniGLTF/TextureBytesTests.cs | 7 +--- 18 files changed, 96 insertions(+), 31 deletions(-) create mode 100644 Assets/UniGLTF/Tests/Objects.meta rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_linear.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_linear.png.meta (86%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_normal_map.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_normal_map.png.meta (86%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_srgb.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_srgb.png.meta (86%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable.png.meta (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable_compressed.DDS (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable_compressed.DDS.meta (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/New Material.mat (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/New Material.mat.meta (100%) create mode 100644 Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs create mode 100644 Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta diff --git a/Assets/UniGLTF/Tests/Objects.meta b/Assets/UniGLTF/Tests/Objects.meta new file mode 100644 index 000000000..895ef31b1 --- /dev/null +++ b/Assets/UniGLTF/Tests/Objects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 257f9efac603801459934018928760de +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png.meta similarity index 86% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png.meta index 34e2b319c..8cff80177 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png.meta +++ b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png.meta @@ -3,7 +3,7 @@ guid: fc1ba24d4a4141d4d9e9ae0a0d3ecd0a TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 0 @@ -24,6 +24,7 @@ TextureImporter: streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -62,6 +63,7 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + cookieLightType: 1 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform @@ -99,6 +101,18 @@ TextureImporter: overridden: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -112,6 +126,7 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] + nameFileIdTable: {} spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png.meta similarity index 86% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png.meta index 4862a8127..aa67d0199 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png.meta +++ b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png.meta @@ -3,7 +3,7 @@ guid: b5d17df8d14f2324692a7c69f24cf658 TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 1 @@ -24,6 +24,7 @@ TextureImporter: streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -62,6 +63,7 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + cookieLightType: 1 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform @@ -99,6 +101,18 @@ TextureImporter: overridden: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -112,6 +126,7 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] + nameFileIdTable: {} spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png.meta similarity index 86% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png.meta index 39acaa02f..c2e9bfc6f 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png.meta +++ b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png.meta @@ -3,7 +3,7 @@ guid: 0f7acf68f1798ae48a5505519abac457 TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 0 @@ -24,6 +24,7 @@ TextureImporter: streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -62,6 +63,7 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + cookieLightType: 1 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform @@ -99,6 +101,18 @@ TextureImporter: overridden: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -112,6 +126,7 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] + nameFileIdTable: {} spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png b/Assets/UniGLTF/Tests/Objects/4x4_non_readable.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_non_readable.png.meta similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable.png.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS b/Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS.meta b/Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS.meta similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS.meta rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/New Material.mat b/Assets/UniGLTF/Tests/Objects/New Material.mat similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/New Material.mat rename to Assets/UniGLTF/Tests/Objects/New Material.mat diff --git a/Assets/UniGLTF/Tests/UniGLTF/New Material.mat.meta b/Assets/UniGLTF/Tests/Objects/New Material.mat.meta similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/New Material.mat.meta rename to Assets/UniGLTF/Tests/Objects/New Material.mat.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs b/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs index 8170541d9..d8304c00b 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs @@ -1,13 +1,10 @@ using NUnit.Framework; -using UnityEditor; using UnityEngine; namespace UniGLTF { public sealed class CopyTextureTests { - private static string AssetPath = "Assets/VRMShaders/GLTF/IO/Tests"; - private static readonly Color32 Black = new Color32(0, 0, 0, 255); private static readonly Color32 Gray = new Color32(127, 127, 127, 255); private static readonly Color32 White = new Color32(255, 255, 255, 255); @@ -32,7 +29,7 @@ namespace UniGLTF [Test] public void CopyFromNonReadableSRgbPng() { - var nonReadableTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable.png"); + var nonReadableTex = TestAssets.LoadAsset("4x4_non_readable.png"); Assert.False(nonReadableTex.isReadable); var copiedTex = TextureConverter.CopyTexture(nonReadableTex, ColorSpace.sRGB, true, null); var pixels = copiedTex.GetPixels32(miplevel: 0); @@ -46,7 +43,7 @@ namespace UniGLTF [Test] public void CopyFromNonReadableSRgbDds() { - var compressedTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable_compressed.dds"); + var compressedTex = TestAssets.LoadAsset("4x4_non_readable_compressed.dds"); Assert.False(compressedTex.isReadable); var copiedTex = TextureConverter.CopyTexture(compressedTex, ColorSpace.sRGB, true, null); var pixels = copiedTex.GetPixels32(miplevel: 0); @@ -60,7 +57,7 @@ namespace UniGLTF [Test] public void CopyAttributes() { - var src = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable.png"); + var src = TestAssets.LoadAsset("4x4_non_readable.png"); var dst = TextureConverter.CopyTexture(src, ColorSpace.sRGB, false, null); Assert.AreEqual(src.name, dst.name); Assert.AreEqual(src.anisoLevel, dst.anisoLevel); diff --git a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs index dbc1349e9..a0a128da1 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs @@ -1,18 +1,16 @@ using NUnit.Framework; -using UnityEditor; using UnityEngine; namespace UniGLTF { public sealed class EditorTextureSerializerTests { - private static readonly string AssetPath = "Assets/UniGLTF/Tests/UniGLTF"; private static readonly string SrgbGrayImageName = "4x4_gray_import_as_srgb"; private static readonly string LinearGrayImageName = "4x4_gray_import_as_linear"; private static readonly string NormalMapGrayImageName = "4x4_gray_import_as_normal_map"; - private static readonly Texture2D SrgbGrayTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/{SrgbGrayImageName}.png"); - private static readonly Texture2D LinearGrayTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/{LinearGrayImageName}.png"); - private static readonly Texture2D NormalMapGrayTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/{NormalMapGrayImageName}.png"); + private static readonly Texture2D SrgbGrayTex = TestAssets.LoadAsset($"{SrgbGrayImageName}.png"); + private static readonly Texture2D LinearGrayTex = TestAssets.LoadAsset($"{LinearGrayImageName}.png"); + private static readonly Texture2D NormalMapGrayTex = TestAssets.LoadAsset($"{NormalMapGrayImageName}.png"); private static readonly Color32 JustGray = new Color32(127, 127, 127, 255); private static readonly Color32 SrgbGrayInSrgb = JustGray; private static readonly Color32 SrgbGrayInLinear = ((Color)SrgbGrayInSrgb).linear; @@ -113,23 +111,28 @@ namespace UniGLTF { // Prepare var root = GameObject.CreatePrimitive(PrimitiveType.Cube); - var mat = new Material(Shader.Find("Standard")); + var mat = new Material(Shader.Find(BuiltInStandardMaterialExporter.TargetShaderName)); mat.SetTexture(propertyName, srcTex); root.GetComponentOrThrow().sharedMaterial = mat; // Export glTF var data = new ExportingGltfData(); - using (var exporter = new gltfExporter(data, new GltfExportSettings - { - InverseAxis = Axes.X, - ExportOnlyBlendShapePosition = false, - UseSparseAccessorForMorphTarget = false, - DivideVertexBuffer = false, - }, textureSerializer: new EditorTextureSerializer())) - { - exporter.Prepare(root); - exporter.Export(); - } + using var exporter = new gltfExporter( + data, + new GltfExportSettings + { + InverseAxis = Axes.X, + ExportOnlyBlendShapePosition = false, + UseSparseAccessorForMorphTarget = false, + DivideVertexBuffer = false, + }, + materialExporter: new BuiltInGltfMaterialExporter(), + textureSerializer: new EditorTextureSerializer() + ); + + exporter.Prepare(root); + exporter.Export(); + var gltf = data.Gltf; Assert.AreEqual(1, gltf.images.Count); var exportedImage = gltf.images[0]; diff --git a/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs new file mode 100644 index 000000000..96319bbf4 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs @@ -0,0 +1,12 @@ +namespace UniGLTF +{ + public static class TestAssets + { + public static readonly string AssetPath = "Assets/UniGLTF/Tests/Objects"; + + public static T LoadAsset(string filename) where T : UnityEngine.Object + { + return UnityEditor.AssetDatabase.LoadAssetAtPath($"{AssetPath}/{filename}"); + } + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta new file mode 100644 index 000000000..ce8bf83a6 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8519ebb2f0f84833a752bb564b59c47c +timeCreated: 1722263712 \ No newline at end of file diff --git a/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs b/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs index f4ef96a2f..f99019151 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs @@ -1,17 +1,14 @@ using NUnit.Framework; -using UnityEditor; using UnityEngine; namespace UniGLTF { public class TextureBytesTests { - static string AssetPath = "Assets/VRMShaders/GLTF/IO/Tests"; - [Test] public void NonReadablePng() { - var nonReadableTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable.png"); + var nonReadableTex = TestAssets.LoadAsset("4x4_non_readable.png"); Assert.False(nonReadableTex.isReadable); var (bytes, mime) = new EditorTextureSerializer().ExportBytesWithMime(nonReadableTex, ColorSpace.sRGB); Assert.NotNull(bytes); @@ -20,7 +17,7 @@ namespace UniGLTF [Test] public void NonReadableDds() { - var readonlyTexture = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable_compressed.dds"); + var readonlyTexture = TestAssets.LoadAsset("4x4_non_readable_compressed.dds"); Assert.False(readonlyTexture.isReadable); var (bytes, mime) = new EditorTextureSerializer().ExportBytesWithMime(readonlyTexture, ColorSpace.sRGB); Assert.NotNull(bytes);