当前提交
3eb94be0
共有 2046 个文件被更改,包括 5277 次插入 和 5 次删除
-
2SampleScenes/HDTest/GraphicTest/Scripts/MaterialPlacer.cs.meta
-
6ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
-
10SampleScenes/HDTest/SkyFogTest/SkyFogHDRISky.asset.meta
-
10SampleScenes/HDTest/SkyFogTest/SkyFogProceduralSky.asset.meta
-
9Tests/GraphicsTests.meta
-
9Tests/GraphicsTests/Framework.meta
-
12Tests/GraphicsTests/Framework/SetupSceneForRenderPipelineTest.cs.meta
-
12Tests/GraphicsTests/Framework/GotoNextScene.cs.meta
-
13Tests/GraphicsTests/Framework/GotoNextScene.cs
-
9Tests/GraphicsTests/Framework/Editor.meta
-
12Tests/GraphicsTests/Framework/Editor/TestFrameworkCustomBuild.cs.meta
-
12Tests/GraphicsTests/Framework/Editor/TestFramework.cs.meta
-
12Tests/GraphicsTests/Framework/Editor/SetupSceneForRenderPipelineTestEditor.cs.meta
-
22Tests/GraphicsTests/Framework/Editor/SetupSceneForRenderPipelineTestEditor.cs
-
71Tests/GraphicsTests/Framework/Editor/TestFrameworkCustomBuild.cs
-
211Tests/GraphicsTests/Framework/Editor/TestFramework.cs
-
27Tests/GraphicsTests/Framework/SetupSceneForRenderPipelineTest.cs
-
9Tests/GraphicsTests/RenderPipeline.meta
-
9Tests/GraphicsTests/RenderPipeline/HDRenderPipeline.meta
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/4UVPlane.meta
-
26Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/4UVPlane/4UVPlane.fbx
-
93Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/4UVPlane/4UVPlane.fbx.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox.meta
-
55Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Cornell Box.fbx
-
111Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Cornell Box.fbx.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials.meta
-
235Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials/Cornell Box.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials/Cornell Box.mat.meta
-
235Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials/Cornell Box_green.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials/Cornell Box_green.mat.meta
-
235Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials/Cornell Box_red.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Materials/Cornell Box_red.mat.meta
-
84Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Cube.prefab
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Cube.prefab.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/DoubleSidePlane.meta
-
98Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/DoubleSidePlane/DoubleSidePlane.fbx.meta
-
23Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/DoubleSidePlane/DoubleSidePlane.fbx
-
84Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Quad.prefab
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Quad.prefab.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/RoundedCube.meta
-
62Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/RoundedCube/RoundedCube.fbx
-
98Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/RoundedCube/RoundedCube.fbx.meta
-
60Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/RoundedCube/RoundedCube_DoubleSide.fbx
-
98Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/RoundedCube/RoundedCube_DoubleSide.fbx.meta
-
84Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Sphere.prefab
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Sphere.prefab.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Fonts.meta
-
1001Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Fonts/PressStart2P-Regular.ttf
-
22Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Fonts/PressStart2P-Regular.ttf.meta
-
9Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI.meta
-
2Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/HDRI value 1 Shadowed.exr
-
121Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/HDRI value 1 Shadowed.exr.meta
-
1Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/HDRI value 1.exr
-
130Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/HDRI value 1.exr.meta
-
1Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/HDRI value 10000.exr
-
130Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/HDRI value 10000.exr.meta
-
88Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/KirbyCoveWhiteBalancedNoSun.exr.meta
-
130Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/MuirWood - White balanced.exr.meta
-
88Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/Treasure Island - White balanced.exr.meta
-
88Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/Treasure Island_NoSun - White balanced.exr.meta
-
130Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRI/Trinitatis Church - White balanced.exr.meta
-
110Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_Test_Camera.prefab
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_Test_Camera.prefab.meta
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation.meta
-
10Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/HDRP_Default_Material.mat.meta
-
177Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Skybox_MuirWood.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Skybox_MuirWood.mat.meta
-
172Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_00.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_00.mat.meta
-
172Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_01.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_01.mat.meta
-
172Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_02.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_02.mat.meta
-
172Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_03.mat
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Materials/Smoothness Variation/HDRP_Metal_Smooth_03.mat.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 2647470268f148548bb957878139fc56 |
|||
timeCreated: 1507624166 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7d119d7ec4e5e964d92d40232696fa43 |
|||
timeCreated: 1507634536 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: fabcb6233c120475db6fc066c4ff60f4 |
|||
folderAsset: yes |
|||
timeCreated: 1493132725 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8305d4811b3aa624ea663e2d7841e470 |
|||
folderAsset: yes |
|||
timeCreated: 1495206710 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c20dfc007a9a74ad8a2bfd0d59abe398 |
|||
timeCreated: 1493134169 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b96aad4b8199e42ae887b72c26bc8a58 |
|||
timeCreated: 1493732883 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.SceneManagement; |
|||
|
|||
public class GotoNextScene : MonoBehaviour |
|||
{ |
|||
public int m_NextSceneIndex = 0; |
|||
|
|||
void Update() |
|||
{ |
|||
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) |
|||
SceneManager.LoadScene(m_NextSceneIndex); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ac919a67e7c764f70a75900c12043d9b |
|||
folderAsset: yes |
|||
timeCreated: 1493134265 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5e43c15f4f8ef4a6a82779e179ae97b3 |
|||
timeCreated: 1493801452 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ce4414d6bbf59a54686b40bffc0bab08 |
|||
timeCreated: 1454664639 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: a0fc54044084eca4894b2caa330d3f99 |
|||
timeCreated: 1493802113 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Rendering; |
|||
|
|||
[CustomEditor(typeof(SetupSceneForRenderPipelineTest))] |
|||
public class SetupSceneForRenderPipelineTestEditor : Editor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
base.OnInspectorGUI(); |
|||
|
|||
var sceneSetup = target as SetupSceneForRenderPipelineTest; |
|||
if (sceneSetup == null) |
|||
return; |
|||
|
|||
if (GUILayout.Button("Set renderpipe")) |
|||
{ |
|||
GraphicsSettings.renderPipelineAsset = sceneSetup.renderPipeline; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEditor.SceneManagement; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public class TestFrameworkCustomBuild |
|||
{ |
|||
private static readonly string s_TestSceneFolder = "/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes"; |
|||
private static readonly string s_BuildFolder = "/TestScenesBuild"; |
|||
|
|||
[MenuItem("RenderPipeline/TestFramework/Build-iOS")] |
|||
public static void BuildiOS() |
|||
{ |
|||
TestFrameworkCustomBuild builder = new TestFrameworkCustomBuild(); |
|||
builder.Build(BuildTarget.iOS, BuildOptions.AcceptExternalModificationsToPlayer); |
|||
} |
|||
|
|||
[MenuItem("RenderPipeline/TestFramework/Build-iOS", true)] |
|||
|
|||
public static bool ValidateBuildiOS() |
|||
{ |
|||
#if UNITY_STANDALONE_OSX
|
|||
return true; |
|||
#else
|
|||
return false; |
|||
#endif
|
|||
} |
|||
|
|||
public void Build(BuildTarget target, BuildOptions options) |
|||
{ |
|||
var absoluteScenesPath = Application.dataPath + s_TestSceneFolder; |
|||
string[] levels = System.IO.Directory.GetFiles(absoluteScenesPath, "*.unity", System.IO.SearchOption.AllDirectories); |
|||
CheckAndAddGotoNextSceneBehavior(levels); |
|||
|
|||
string savePath = EditorUtility.SaveFolderPanel("Select folder to save project", "", ""); |
|||
BuildPipeline.BuildPlayer(levels, savePath + s_BuildFolder, target, options); |
|||
} |
|||
|
|||
private void CheckAndAddGotoNextSceneBehavior(string[] levels) |
|||
{ |
|||
for (int i = 0; i < levels.Length; ++i) |
|||
{ |
|||
string levelPath = levels[i]; |
|||
var scene = EditorSceneManager.OpenScene(levelPath); |
|||
GameObject[] objects = scene.GetRootGameObjects(); |
|||
bool componentFound = false; |
|||
|
|||
foreach (GameObject go in objects) |
|||
{ |
|||
GotoNextScene component = go.GetComponent<GotoNextScene>(); |
|||
if (component != null) |
|||
{ |
|||
component.m_NextSceneIndex = (i + 1) % levels.Length; |
|||
componentFound = true; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (!componentFound) |
|||
{ |
|||
GameObject gotoNextScene = new GameObject("GotoNextScene"); |
|||
GotoNextScene component = gotoNextScene.AddComponent<GotoNextScene>(); |
|||
component.m_NextSceneIndex = (i + 1) % levels.Length; |
|||
} |
|||
|
|||
EditorSceneManager.SaveScene(scene); |
|||
EditorSceneManager.UnloadSceneAsync(scene); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using UnityEditor.SceneManagement; |
|||
using Object = UnityEngine.Object; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.TestTools; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public class GraphicsTests |
|||
{ |
|||
static readonly string s_RootPath = Directory.GetParent(Directory.GetFiles(Application.dataPath, "SRPMARKER", SearchOption.AllDirectories).First()).ToString(); |
|||
|
|||
// path where the tests live
|
|||
private static readonly string[] s_Path = |
|||
{ |
|||
"Tests", |
|||
"GraphicsTests", |
|||
"RenderPipeline" |
|||
}; |
|||
|
|||
private static readonly string[] s_PipelinePath = |
|||
{ |
|||
"LightweightPipeline", |
|||
"HDRenderPipeline", |
|||
}; |
|||
|
|||
// info that gets generated for use
|
|||
// in a dod way
|
|||
public struct TestInfo |
|||
{ |
|||
public string name; |
|||
public float threshold; |
|||
public string relativePath; |
|||
public int frameWait; |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return name; |
|||
} |
|||
|
|||
} |
|||
|
|||
// collect the scenes that we can use
|
|||
public static class CollectScenes |
|||
{ |
|||
public static IEnumerable scenes |
|||
{ |
|||
get |
|||
{ |
|||
var absoluteScenesPath = s_Path.Aggregate(s_RootPath, Path.Combine); |
|||
|
|||
foreach (var pipelinePath in s_PipelinePath) |
|||
{ |
|||
|
|||
var filesPath = Path.Combine(absoluteScenesPath, pipelinePath); |
|||
|
|||
// find all the scenes
|
|||
var allPaths = System.IO.Directory.GetFiles(filesPath, "*.unity", System.IO.SearchOption.AllDirectories); |
|||
|
|||
// construct all the needed test infos
|
|||
foreach (var path in allPaths) |
|||
{ |
|||
var p = new FileInfo(path); |
|||
var split = s_Path.Aggregate("", Path.Combine); |
|||
split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar); |
|||
var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries); |
|||
|
|||
yield return new TestInfo |
|||
{ |
|||
name = p.Name, |
|||
relativePath = splitPaths.Last(), |
|||
threshold = 0.02f, |
|||
frameWait = 100 |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
[TearDown] |
|||
public void TearDown() |
|||
{ |
|||
var testSetup = Object.FindObjectOfType<SetupSceneForRenderPipelineTest>(); |
|||
if (testSetup == null) |
|||
return; |
|||
|
|||
testSetup.TearDown(); |
|||
} |
|||
|
|||
[UnityTest] |
|||
public IEnumerator TestScene([ValueSource(typeof(CollectScenes), "scenes")]TestInfo testInfo) |
|||
{ |
|||
var prjRelativeGraphsPath = s_Path.Aggregate(s_RootPath, Path.Combine); |
|||
var filePath = Path.Combine(prjRelativeGraphsPath, testInfo.relativePath); |
|||
|
|||
// open the scene
|
|||
EditorSceneManager.OpenScene(filePath); |
|||
|
|||
var testSetup = Object.FindObjectOfType<SetupSceneForRenderPipelineTest> (); |
|||
Assert.IsNotNull(testSetup, "No SetupSceneForRenderPipelineTest in scene " + testInfo.name); |
|||
Assert.IsNotNull(testSetup.cameraToUse, "No configured camera in <SetupSceneForRenderPipelineTest>"); |
|||
|
|||
testSetup.Setup(); |
|||
|
|||
for (int i = 0; i < testInfo.frameWait; ++i) |
|||
{ |
|||
yield return null; |
|||
} |
|||
|
|||
while (UnityEditor.Lightmapping.isRunning) |
|||
{ |
|||
yield return null; |
|||
} |
|||
|
|||
Camera testCamera = testSetup.cameraToUse; |
|||
var rtDesc = new RenderTextureDescriptor ( |
|||
testSetup.width, |
|||
testSetup.height, |
|||
(testSetup.hdr && testCamera.allowHDR) ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32, |
|||
24); |
|||
rtDesc.sRGB = PlayerSettings.colorSpace == ColorSpace.Linear; |
|||
rtDesc.msaaSamples = testSetup.msaaSamples; |
|||
|
|||
// render the scene
|
|||
var tempTarget = RenderTexture.GetTemporary (rtDesc); |
|||
var oldTarget = testSetup.cameraToUse.targetTexture; |
|||
testSetup.cameraToUse.targetTexture = tempTarget; |
|||
testSetup.cameraToUse.Render (); |
|||
testSetup.cameraToUse.targetTexture = oldTarget; |
|||
|
|||
// Readback the rendered texture
|
|||
var oldActive = RenderTexture.active; |
|||
RenderTexture.active = tempTarget; |
|||
var captured = new Texture2D(tempTarget.width, tempTarget.height, TextureFormat.ARGB32, false); |
|||
captured.ReadPixels(new Rect(0, 0, testSetup.width, testSetup.height), 0, 0); |
|||
RenderTexture.active = oldActive; |
|||
|
|||
var templatePath = Path.Combine(s_RootPath, "ImageTemplates"); |
|||
|
|||
// find the reference image
|
|||
var dumpFileLocation = Path.Combine(templatePath, string.Format("{0}.{1}", testInfo.relativePath, "png")); |
|||
if (!File.Exists(dumpFileLocation)) |
|||
{ |
|||
// no reference exists, create it
|
|||
var fileInfo = new FileInfo (dumpFileLocation); |
|||
fileInfo.Directory.Create(); |
|||
|
|||
var generated = captured.EncodeToPNG(); |
|||
File.WriteAllBytes(dumpFileLocation, generated); |
|||
Assert.Fail("Template file not found for {0}, creating it at {1}.", testInfo.name, dumpFileLocation); |
|||
} |
|||
|
|||
var template = File.ReadAllBytes(dumpFileLocation); |
|||
var fromDisk = new Texture2D(2, 2); |
|||
fromDisk.LoadImage(template, false); |
|||
|
|||
var areEqual = CompareTextures(fromDisk, captured, testInfo.threshold); |
|||
|
|||
if (!areEqual) |
|||
{ |
|||
var failedPath = Path.Combine(Directory.GetParent(Application.dataPath).ToString(), "SRP_Failed"); |
|||
Directory.CreateDirectory(failedPath); |
|||
var misMatchLocationResult = Path.Combine(failedPath, string.Format("{0}.{1}", testInfo.name, "png")); |
|||
var misMatchLocationTemplate = Path.Combine(failedPath, string.Format("{0}.template.{1}", testInfo.name, "png")); |
|||
var generated = captured.EncodeToPNG(); |
|||
File.WriteAllBytes(misMatchLocationResult, generated); |
|||
File.WriteAllBytes(misMatchLocationTemplate, template); |
|||
} |
|||
|
|||
Assert.IsTrue(areEqual, "Scene from {0}, did not match .template file.", testInfo.relativePath); |
|||
} |
|||
|
|||
// compare textures, use RMS for this
|
|||
private bool CompareTextures(Texture2D fromDisk, Texture2D captured, float threshold) |
|||
{ |
|||
if (fromDisk == null || captured == null) |
|||
return false; |
|||
|
|||
if (fromDisk.width != captured.width |
|||
|| fromDisk.height != captured.height) |
|||
return false; |
|||
|
|||
var pixels1 = fromDisk.GetPixels(); |
|||
var pixels2 = captured.GetPixels(); |
|||
|
|||
if (pixels1.Length != pixels2.Length) |
|||
return false; |
|||
|
|||
int numberOfPixels = pixels1.Length; |
|||
|
|||
float sumOfSquaredColorDistances = 0; |
|||
for (int i = 0; i < numberOfPixels; i++) |
|||
{ |
|||
Color p1 = pixels1[i]; |
|||
Color p2 = pixels2[i]; |
|||
|
|||
Color diff = p1 - p2; |
|||
diff = diff * diff; |
|||
sumOfSquaredColorDistances += (diff.r + diff.g + diff.b) / 3.0f; |
|||
} |
|||
float rmse = Mathf.Sqrt(sumOfSquaredColorDistances / numberOfPixels); |
|||
return rmse < threshold; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering |
|||
{ |
|||
public class SetupSceneForRenderPipelineTest : MonoBehaviour |
|||
{ |
|||
private RenderPipelineAsset m_OriginalAsset; |
|||
public RenderPipelineAsset renderPipeline; |
|||
public Camera cameraToUse; |
|||
public bool hdr = false; |
|||
public int msaaSamples = 1; |
|||
|
|||
public int width = 1280; |
|||
public int height = 720; |
|||
|
|||
public void Setup() |
|||
{ |
|||
m_OriginalAsset = GraphicsSettings.renderPipelineAsset; |
|||
GraphicsSettings.renderPipelineAsset = renderPipeline; |
|||
} |
|||
|
|||
public void TearDown() |
|||
{ |
|||
GraphicsSettings.renderPipelineAsset = m_OriginalAsset; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: df6fc7164cbe58b4ebafc486f993dd57 |
|||
folderAsset: yes |
|||
timeCreated: 1495194783 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 802cda030a112374494307118f7ab803 |
|||
folderAsset: yes |
|||
timeCreated: 1495194822 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2871da9607c8801419f9a3e693ebf232 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9f68ac02d502ec047b58f5838ec58c6f |
|||
folderAsset: yes |
|||
timeCreated: 1508422901 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: de06e55a01cfe1049bd12a076a266520 |
|||
folderAsset: yes |
|||
timeCreated: 1508854557 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Kaydara FBX Binary � _ FBXHeaderExtension\ FBXHeaderVersionI� x |
|||
FBXVersionI� � EncryptionTypeI � CreationTimeStamp� VersionI� � YearI� � MonthI |
|||
|