mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-26 12:55:18 -05:00
VRMShaders.TextureExporter, AssetTextureUtil
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
"UniGLTF",
|
||||
"MeshUtility",
|
||||
"MeshUtility.Editor",
|
||||
"VRMShaders"
|
||||
"VRMShaders",
|
||||
"VRMShaders.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Reflection;
|
||||
using UniGLTF.Animation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRMShaders;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"references": [
|
||||
"UniGLTF",
|
||||
"UniGLTF.Editor",
|
||||
"VRMShaders"
|
||||
"VRMShaders",
|
||||
"VRMShaders.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
|
||||
@@ -50,28 +50,5 @@ namespace UniGLTF
|
||||
var (bytes, mime) = GltfTextureExporter.GetBytesWithMime(readonlyTexture);
|
||||
Assert.NotNull(bytes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExportMetallicSmoothnessOcclusion_Test()
|
||||
{
|
||||
var metallic = new Texture2D(4, 4, TextureFormat.ARGB32, false, true);
|
||||
var occlusion = new Texture2D(4, 4, TextureFormat.ARGB32, false, true);
|
||||
|
||||
{
|
||||
var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
|
||||
Assert.AreEqual(-1, exporter.ExportMetallicSmoothnessOcclusion(null, 0, null));
|
||||
}
|
||||
{
|
||||
var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(null, 0, occlusion));
|
||||
Assert.AreEqual(1, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, null));
|
||||
}
|
||||
{
|
||||
var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, occlusion));
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(null, 0, occlusion));
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniJSON;
|
||||
using UnityEngine;
|
||||
|
||||
using VRMShaders;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"UniVRM.Editor",
|
||||
"VRM.Tests",
|
||||
"VRMShaders",
|
||||
"UniGLTF.Editor"
|
||||
"VRMShaders.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
|
||||
@@ -5,6 +5,7 @@ using UniJSON;
|
||||
using UnityEngine;
|
||||
using MeshUtility;
|
||||
using System;
|
||||
using VRMShaders;
|
||||
|
||||
namespace VRM.Samples
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using UniGLTF;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRMShaders;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"UniUnlit",
|
||||
"UniGLTF",
|
||||
"UniGLTF.Editor",
|
||||
"VRMShaders"
|
||||
"VRMShaders",
|
||||
"VRMShaders.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"MeshUtility",
|
||||
"MeshUtility.Editor",
|
||||
"VRMShaders",
|
||||
"UniGLTF.Editor"
|
||||
"VRMShaders.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using NUnit.Framework;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
using VRMShaders;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
|
||||
8
Assets/VRMShaders/Editor.meta
Normal file
8
Assets/VRMShaders/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58204522f08a6fe4f846a5817a37f902
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,7 +2,7 @@ using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
namespace VRMShaders
|
||||
{
|
||||
public static class AssetTextureUtil
|
||||
{
|
||||
@@ -13,7 +13,8 @@ namespace UniGLTF
|
||||
/// <returns></returns>
|
||||
public static bool CopyIfMaxTextureSizeIsSmaller(Texture src)
|
||||
{
|
||||
var textureImporter = AssetImporter.GetAtPath(UnityPath.FromAsset(src).Value) as TextureImporter;
|
||||
var path = AssetDatabase.GetAssetPath(src);
|
||||
var textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
|
||||
// private メソッド TextureImporter.GetWidthAndHeight を無理やり呼ぶ
|
||||
var getSizeMethod = typeof(TextureImporter).GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
3
Assets/VRMShaders/Editor/VRMShaders.Editor.asmdef
Normal file
3
Assets/VRMShaders/Editor/VRMShaders.Editor.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "VRMShaders.Editor"
|
||||
}
|
||||
7
Assets/VRMShaders/Editor/VRMShaders.Editor.asmdef.meta
Normal file
7
Assets/VRMShaders/Editor/VRMShaders.Editor.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7da8a75dcade2144aab699032d7d7987
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -89,5 +89,28 @@ namespace VRMShaders
|
||||
Is.EqualTo(new Color32(255, 0, 0, 255)));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExportMetallicSmoothnessOcclusion_Test()
|
||||
{
|
||||
var metallic = new Texture2D(4, 4, TextureFormat.ARGB32, false, true);
|
||||
var occlusion = new Texture2D(4, 4, TextureFormat.ARGB32, false, true);
|
||||
|
||||
{
|
||||
var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
|
||||
Assert.AreEqual(-1, exporter.ExportMetallicSmoothnessOcclusion(null, 0, null));
|
||||
}
|
||||
{
|
||||
var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(null, 0, occlusion));
|
||||
Assert.AreEqual(1, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, null));
|
||||
}
|
||||
{
|
||||
var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, occlusion));
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(null, 0, occlusion));
|
||||
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "VRMShaders.Tests",
|
||||
"references": [
|
||||
"VRMShaders"
|
||||
"VRMShaders",
|
||||
"VRMShaders.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
|
||||
Reference in New Issue
Block a user