Move Test Assets

This commit is contained in:
Masataka SUMI 2024-07-29 23:52:55 +09:00
parent 3fa8ec8a07
commit c4e3f53d5d
18 changed files with 96 additions and 31 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 257f9efac603801459934018928760de
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

Before

Width:  |  Height:  |  Size: 79 B

After

Width:  |  Height:  |  Size: 79 B

View File

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

View File

Before

Width:  |  Height:  |  Size: 79 B

After

Width:  |  Height:  |  Size: 79 B

View File

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

View File

Before

Width:  |  Height:  |  Size: 79 B

After

Width:  |  Height:  |  Size: 79 B

View File

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

View File

Before

Width:  |  Height:  |  Size: 560 B

After

Width:  |  Height:  |  Size: 560 B

View File

@ -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<Texture2D>($"{AssetPath}/4x4_non_readable.png");
var nonReadableTex = TestAssets.LoadAsset<Texture2D>("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<Texture2D>($"{AssetPath}/4x4_non_readable_compressed.dds");
var compressedTex = TestAssets.LoadAsset<Texture2D>("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<Texture2D>($"{AssetPath}/4x4_non_readable.png");
var src = TestAssets.LoadAsset<Texture2D>("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);

View File

@ -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<Texture2D>($"{AssetPath}/{SrgbGrayImageName}.png");
private static readonly Texture2D LinearGrayTex = AssetDatabase.LoadAssetAtPath<Texture2D>($"{AssetPath}/{LinearGrayImageName}.png");
private static readonly Texture2D NormalMapGrayTex = AssetDatabase.LoadAssetAtPath<Texture2D>($"{AssetPath}/{NormalMapGrayImageName}.png");
private static readonly Texture2D SrgbGrayTex = TestAssets.LoadAsset<Texture2D>($"{SrgbGrayImageName}.png");
private static readonly Texture2D LinearGrayTex = TestAssets.LoadAsset<Texture2D>($"{LinearGrayImageName}.png");
private static readonly Texture2D NormalMapGrayTex = TestAssets.LoadAsset<Texture2D>($"{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<MeshRenderer>().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];

View File

@ -0,0 +1,12 @@
namespace UniGLTF
{
public static class TestAssets
{
public static readonly string AssetPath = "Assets/UniGLTF/Tests/Objects";
public static T LoadAsset<T>(string filename) where T : UnityEngine.Object
{
return UnityEditor.AssetDatabase.LoadAssetAtPath<T>($"{AssetPath}/{filename}");
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8519ebb2f0f84833a752bb564b59c47c
timeCreated: 1722263712

View File

@ -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<Texture2D>($"{AssetPath}/4x4_non_readable.png");
var nonReadableTex = TestAssets.LoadAsset<Texture2D>("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<Texture2D>($"{AssetPath}/4x4_non_readable_compressed.dds");
var readonlyTexture = TestAssets.LoadAsset<Texture2D>("4x4_non_readable_compressed.dds");
Assert.False(readonlyTexture.isReadable);
var (bytes, mime) = new EditorTextureSerializer().ExportBytesWithMime(readonlyTexture, ColorSpace.sRGB);
Assert.NotNull(bytes);