Upload project file

This commit is contained in:
Misaki
2024-08-15 17:00:11 +09:00
parent 684c51a8c0
commit e441bb7911
162 changed files with 63084 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine.TestTools;
namespace Unity.Rendering.ToonShader.Tests {
public class ShaderCompileTest
{
[Test]
public void CompileLegacyToonShadersDefault() {
string[] guids = AssetDatabase.FindAssets("t:Shader", new[] { LEGACY_SHADERS_PATH});
int numShaders = guids.Length;
Assert.Greater(numShaders,0);
bool shaderHasError = false;
for (int i=0;i<numShaders && !shaderHasError;++i) {
string curAssetPath = AssetDatabase.GUIDToAssetPath(guids[i]);
Shader shader = AssetDatabase.LoadAssetAtPath<Shader>(curAssetPath);
AssetDatabase.ImportAsset(curAssetPath); //Recompile the shader to make sure there are no compile errors
Assert.True(shader.isSupported);
shaderHasError = ShaderUtil.ShaderHasError(shader);
Assert.False(shaderHasError);
}
}
//---------------------------------------------------------------------------------------------------------------------
[Test]
[UnityPlatform(RuntimePlatform.WindowsEditor)]
public void CompileLegacyToonShadersWithRTHS() { //RaytracedHardShadow
string[] guids = AssetDatabase.FindAssets("t:Shader", new[] {LEGACY_SHADERS_PATH});
int numShaders = guids.Length;
Assert.Greater(numShaders,0);
List<Material> materials = new List<Material>();
//Try to compile shader manually
System.Type t = typeof(ShaderUtil);
MethodInfo dynMethod = t.GetMethod("OpenCompiledShader", BindingFlags.NonPublic | BindingFlags.Static);
Assert.NotNull(dynMethod);
if (null == dynMethod)
return;
int defaultMask = (1 << System.Enum.GetNames(typeof(UnityEditor.Rendering.ShaderCompilerPlatform)).Length - 1);
bool shaderHasError = false;
for (int i=0;i<numShaders && !shaderHasError;++i) {
string curAssetPath = AssetDatabase.GUIDToAssetPath(guids[i]);
Shader shader = AssetDatabase.LoadAssetAtPath<Shader>(curAssetPath);
AssetDatabase.ImportAsset(curAssetPath); //Recompile the shader to make sure there are no compile errors
Assert.True(shader.isSupported);
Material mat = new Material(shader);
mat.EnableKeyword("UTS_USE_RAYTRACING_SHADOW");
materials.Add(mat);
const bool INCLUDE_ALL_VARIANTS = false;
dynMethod.Invoke(null, new object[] { shader, 1, defaultMask, INCLUDE_ALL_VARIANTS});
shaderHasError = ShaderUtil.ShaderHasError(shader);
Assert.False(shaderHasError);
}
Shader.WarmupAllShaders();
int numMaterials = materials.Count;
for (int i=0;i<numMaterials;++i) {
Object.DestroyImmediate(materials[i]);
}
}
//---------------------------------------------------------------------------------------------------------------------
private const string LEGACY_SHADERS_PATH = "Packages/com.unity.toonshader/Runtime/Legacy/Shaders";
}
} //end namespace

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7939cc477ee414646826dbb7eca1bd92
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
{
"name": "Unity.Toonshader.EditorTests",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ccd47dbbb8659be4796120a1de309b38
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: