浏览代码

Merge pull request #1805 from Unity-Technologies/tests/hdrp/distortion

Tests/hdrp/distortion

Merge approved by Julien Ignace
/main
GitHub 7 年前
当前提交
44c7d591
共有 10 个文件被更改,包括 388 次插入1195 次删除
  1. 62
      TestProjects/HDRP_Tests/Assets/GraphicTests/Common/TestRunner/HDRP_GraphicTestRunner.cs
  2. 2
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2101_GI_Metapass.unity.meta
  3. 2
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2102_GI_Emission.unity.meta
  4. 2
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2103_BakeMixed.unity.meta
  5. 398
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2601_ColorTemp.unity
  6. 2
      TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2601_ColorTemp.unity.meta
  7. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2601_ColorTemp.png
  8. 6
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2601_ColorTemp.png.meta
  9. 9
      TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset
  10. 101
      com.unity.testframework.graphics/Editor/SetupGraphicsTestCases.cs

62
TestProjects/HDRP_Tests/Assets/GraphicTests/Common/TestRunner/HDRP_GraphicTestRunner.cs


using UnityEngine.SceneManagement;
using UnityEngine.Events;
#if UNITY_EDITOR
using UnityEditor;
using EditorSceneManagement = UnityEditor.SceneManagement;
#endif
public class HDRP_GraphicTestRunner : IPrebuildSetup
public class HDRP_GraphicTestRunner
{
[UnityTest, Category("HDRP Graphic Tests")]
[PrebuildSetup("SetupGraphicsTestCases")]

yield return null;
ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
}
public void Setup()
{
#if UNITY_EDITOR
// Search for "InitTestSceneXXXXXXXX" generated by test runner and save the path in the EditorPrefs
for (int i=0 ; i<EditorSceneManagement.EditorSceneManager.sceneCount ; ++i)
{
Scene scene = EditorSceneManagement.EditorSceneManager.GetSceneAt(i);
if (scene.name.StartsWith("InitTestScene"))
{
EditorPrefs.SetString("InitTestScene", scene.path);
break;
}
}
string scenesWithAutoLightMap = "";
// For each scene in the build settings, force build of the lightmaps if it has "DoLightmap" label.
foreach( EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
{
SceneAsset sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
var labels = new System.Collections.Generic.List<string>(AssetDatabase.GetLabels(sceneAsset));
if ( labels.Contains("DoLightmap") )
{
EditorSceneManagement.EditorSceneManager.OpenScene(scene.path, EditorSceneManagement.OpenSceneMode.Single);
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
EditorSceneManagement.EditorSceneManager.SaveOpenScenes();
Lightmapping.Clear();
Lightmapping.Bake();
scenesWithAutoLightMap += scene.path + ";";
EditorSceneManagement.EditorSceneManager.SaveOpenScenes();
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.Iterative;
EditorSceneManagement.EditorSceneManager.SaveOpenScenes();
EditorSceneManagement.EditorSceneManager.NewScene(EditorSceneManagement.NewSceneSetup.EmptyScene);
}
}
EditorPrefs.SetString("ScenesWithAutoLightMap", scenesWithAutoLightMap);
// Re-open testrunner scene
string initTestSceneString = EditorPrefs.GetString("InitTestScene");
if (!string.IsNullOrEmpty(initTestSceneString))
{
EditorSceneManagement.EditorSceneManager.OpenScene(initTestSceneString, EditorSceneManagement.OpenSceneMode.Single);
}
#endif
}
#if UNITY_EDITOR

2
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2101_GI_Metapass.unity.meta


fileFormatVersion: 2
guid: 8747b43f8bcf2b44cbc3ece373da65a9
labels:
- DoLightmap
- TestRunnerBake
DefaultImporter:
externalObjects: {}
userData:

2
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2102_GI_Emission.unity.meta


fileFormatVersion: 2
guid: b8f49ca9a12abb4468116e9422139e63
labels:
- DoLightmap
- TestRunnerBake
DefaultImporter:
externalObjects: {}
userData:

2
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2103_BakeMixed.unity.meta


fileFormatVersion: 2
guid: d8cfa4fd9319d2444b3bf6dd836ffe31
labels:
- TestRunnerBake
DefaultImporter:
externalObjects: {}
userData:

398
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2601_ColorTemp.unity
文件差异内容过多而无法显示
查看文件

2
TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/2x_Lighting/2601_ColorTemp.unity.meta


fileFormatVersion: 2
guid: 34a3a4a7a56d3014dad3114e6b523742
labels:
- DoLightmap
- TestRunnerBake
DefaultImporter:
externalObjects: {}
userData:

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2601_ColorTemp.png
文件差异内容过多而无法显示
查看文件

6
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2601_ColorTemp.png.meta


fileFormatVersion: 2
guid: ff5f29743fc35bc4493f02c39adff3dc
guid: 4a66b103486fb5c4eb488b9708f66797
serializedVersion: 6
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0

edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

9
TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset


path: Assets/GraphicTests/Scenes/1x_Materials/1101_Unlit.unity
guid: 7fe3f9e94b4355641ba1534c54d5c356
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1102_Unlit_Distortion.unity
guid: a6e4a81e1988f24459f57a881905a465
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1103_Unlit_Distortion_DepthTest.unity
guid: 27d04b0368c7fef4eb423d76cc0e48dc
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1201_Lit_Features.unity
guid: 51392325eef9416439dc126a37256e6f
- enabled: 1

- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1205_Lit_Transparent_Refraction.unity
guid: 530aef5d08a1569479cc65b219b8f9fb
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1206_Lit_Transparent_Distortion.unity
guid: fc3cc4c68d873e64ca12fcfc828d7ee4
- enabled: 1
path: Assets/GraphicTests/Scenes/1x_Materials/1207_Lit_Displacement.unity
guid: ac4701d765fa26b4f83d2fb9ed6b3c08

101
com.unity.testframework.graphics/Editor/SetupGraphicsTestCases.cs


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.TestTools;
using UnityEngine.SceneManagement;
using UnityEditor;
using EditorSceneManagement = UnityEditor.SceneManagement;
namespace UnityEditor.TestTools.Graphics
{

/// Will also build Lightmaps for specially labelled scenes.
static string bakeLabel = "TestRunnerBake";
private static bool IsBuildingForEditorPlaymode
{
get

}
}
// For each scene in the build settings, force build of the lightmaps if it has "DoLightmap" label.
// Note that in the PreBuildSetup stage, TestRunner has already created a new scene with its testing monobehaviours
Scene trScene = EditorSceneManagement.EditorSceneManager.GetSceneAt(0);
foreach( EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
{
SceneAsset sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
var labels = new System.Collections.Generic.List<string>(AssetDatabase.GetLabels(sceneAsset));
if ( labels.Contains(bakeLabel) )
{
EditorSceneManagement.EditorSceneManager.OpenScene(scene.path, EditorSceneManagement.OpenSceneMode.Additive);
Scene currentScene = EditorSceneManagement.EditorSceneManager.GetSceneAt(1);
EditorSceneManagement.EditorSceneManager.SetActiveScene(currentScene);
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
Lightmapping.Bake();
EditorSceneManagement.EditorSceneManager.SaveScene( currentScene );
EditorSceneManagement.EditorSceneManager.SetActiveScene(trScene);
EditorSceneManagement.EditorSceneManager.CloseScene(currentScene, true);
}
}
}
static string lightmapDataGitIgnore = @"Lightmap-*_comp*
LightingData.*
ReflectionProbe-*";
[MenuItem("Assets/Tests/Toggle Scene for Bake")]
public static void LabelSceneForBake()
{
UnityEngine.Object[] sceneAssets = Selection.GetFiltered(typeof(SceneAsset), SelectionMode.DeepAssets);
EditorSceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
EditorSceneManagement.SceneSetup[] previousSceneSetup = EditorSceneManagement.EditorSceneManager.GetSceneManagerSetup();
foreach (UnityEngine.Object sceneAsset in sceneAssets)
{
List<string> labels = new System.Collections.Generic.List<string>(AssetDatabase.GetLabels(sceneAsset));
string scenePath = AssetDatabase.GetAssetPath(sceneAsset);
string gitIgnorePath = Path.Combine( Path.Combine( Application.dataPath.Substring(0, Application.dataPath.Length-6), scenePath.Substring(0, scenePath.Length-6) ) , ".gitignore" );
if (labels.Contains(bakeLabel))
{
labels.Remove(bakeLabel);
File.Delete(gitIgnorePath);
}
else
{
labels.Add(bakeLabel);
string sceneLightingDataFolder = Path.Combine( Path.GetDirectoryName(scenePath), Path.GetFileNameWithoutExtension(scenePath) );
if ( !AssetDatabase.IsValidFolder(sceneLightingDataFolder) )
AssetDatabase.CreateFolder( Path.GetDirectoryName(scenePath), Path.GetFileNameWithoutExtension(scenePath) );
File.WriteAllText(gitIgnorePath, lightmapDataGitIgnore);
EditorSceneManagement.EditorSceneManager.OpenScene(scenePath, EditorSceneManagement.OpenSceneMode.Single);
EditorSceneManagement.EditorSceneManager.SetActiveScene( EditorSceneManagement.EditorSceneManager.GetSceneAt(0) );
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
EditorSceneManagement.EditorSceneManager.SaveScene( EditorSceneManagement.EditorSceneManager.GetSceneAt(0) );
}
AssetDatabase.SetLabels( sceneAsset, labels.ToArray() );
}
AssetDatabase.Refresh();
if (previousSceneSetup.Length == 0)
EditorSceneManagement.EditorSceneManager.NewScene(EditorSceneManagement.NewSceneSetup.DefaultGameObjects, EditorSceneManagement.NewSceneMode.Single);
else
EditorSceneManagement.EditorSceneManager.RestoreSceneManagerSetup(previousSceneSetup);
}
[MenuItem("Assets/Tests/Toggle Scene for Bake", true)]
public static bool LabelSceneForBake_Test()
{
return IsSceneAssetSelected();
}
public static bool IsSceneAssetSelected()
{
UnityEngine.Object[] sceneAssets = Selection.GetFiltered(typeof(SceneAsset), SelectionMode.DeepAssets);
return sceneAssets.Length != 0;
}
}
}
正在加载...
取消
保存