浏览代码

Make IShadowManager public and move material upgrader tests outside of package

/namespace
Peter Bay Bastian 7 年前
当前提交
f1dbee8e
共有 7 个文件被更改,包括 68 次插入50 次删除
  1. 2
      ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
  2. 25
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs
  3. 24
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs
  4. 3
      Tests/Editor.meta
  5. 61
      Tests/Editor/MaterialUpgraderTests.cs
  6. 3
      Tests/Editor/MaterialUpgraderTests.cs.meta

2
ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs


abstract public void DisplayShadowMap(CommandBuffer cmd, Vector4 scaleBias, uint slice, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue);
}
interface IShadowManager
public interface IShadowManager
{
// Warning: The shadowRequests array and shadowRequestsCount are modified by this function.
// When called the array contains the indices of lights requesting shadows,

25
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs


using NUnit.Framework;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline

base.Convert(srcMaterial, dstMaterial);
//@TODO: Find a good way of setting up keywords etc from properties.
// Code should be shared with material UI code.
}
[Test]
public void UpgradeMaterial()
{
var newShader = Shader.Find("HDRenderPipeline/Lit");
var mat = new Material(Shader.Find("Standard (Specular setup)"));
var albedo = new Texture2D(1, 1);
var normals = new Texture2D(1, 1);
var baseScale = new Vector2(1, 1);
var color = Color.red;
mat.mainTexture = albedo;
mat.SetTexture("_BumpMap", normals);
mat.color = color;
mat.SetTextureScale("_MainTex", baseScale);
MaterialUpgrader.Upgrade(mat, this, MaterialUpgrader.UpgradeFlags.CleanupNonUpgradedProperties);
Assert.AreEqual(newShader, mat.shader);
Assert.AreEqual(albedo, mat.GetTexture("_BaseColorMap"));
Assert.AreEqual(color, mat.GetColor("_BaseColor"));
Assert.AreEqual(baseScale, mat.GetTextureScale("_BaseColorMap"));
Assert.AreEqual(normals, mat.GetTexture("_NormalMap"));
Assert.IsTrue(mat.IsKeywordEnabled("_NORMALMAP"));
}
}
}

24
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs


using NUnit.Framework;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline

// Code should be shared with material UI code.
}
[Test]
public void UpgradeMaterial()
{
var newShader = Shader.Find("HDRenderPipeline/Lit");
var mat = new Material(Shader.Find("Standard"));
var albedo = new Texture2D(1, 1);
var normals = new Texture2D(1, 1);
var baseScale = new Vector2(1, 1);
var color = Color.red;
mat.mainTexture = albedo;
mat.SetTexture("_BumpMap", normals);
mat.color = color;
mat.SetTextureScale("_MainTex", baseScale);
MaterialUpgrader.Upgrade(mat, this, MaterialUpgrader.UpgradeFlags.CleanupNonUpgradedProperties);
Assert.AreEqual(newShader, mat.shader);
Assert.AreEqual(albedo, mat.GetTexture("_BaseColorMap"));
Assert.AreEqual(color, mat.GetColor("_BaseColor"));
Assert.AreEqual(baseScale, mat.GetTextureScale("_BaseColorMap"));
Assert.AreEqual(normals, mat.GetTexture("_NormalMap"));
Assert.IsTrue(mat.IsKeywordEnabled("_NORMALMAP"));
}
}
}

3
Tests/Editor.meta


fileFormatVersion: 2
guid: 0f6887a1ff514ed690ada3786867d216
timeCreated: 1512986333

61
Tests/Editor/MaterialUpgraderTests.cs


using NUnit.Framework;
using UnityEditor.Experimental.Rendering;
using UnityEditor.Experimental.Rendering.HDPipeline;
using UnityEngine;
namespace ScriptableRenderPipeline.Tests.Editor
{
public class MaterialUpgraderTests
{
[Test]
public void UpgradeStandardSpecularToHDLitMaterial()
{
var newShader = Shader.Find("HDRenderPipeline/Lit");
var mat = new Material(Shader.Find("Standard (Specular setup)"));
var albedo = new Texture2D(1, 1);
var normals = new Texture2D(1, 1);
var baseScale = new Vector2(1, 1);
var color = Color.red;
mat.mainTexture = albedo;
mat.SetTexture("_BumpMap", normals);
mat.color = color;
mat.SetTextureScale("_MainTex", baseScale);
var upgrader = new StandardSpecularToHDLitMaterialUpgrader();
MaterialUpgrader.Upgrade(mat, upgrader, MaterialUpgrader.UpgradeFlags.CleanupNonUpgradedProperties);
Assert.AreEqual(newShader, mat.shader);
Assert.AreEqual(albedo, mat.GetTexture("_BaseColorMap"));
Assert.AreEqual(color, mat.GetColor("_BaseColor"));
Assert.AreEqual(baseScale, mat.GetTextureScale("_BaseColorMap"));
Assert.AreEqual(normals, mat.GetTexture("_NormalMap"));
Assert.IsTrue(mat.IsKeywordEnabled("_NORMALMAP"));
}
[Test]
public void UpgradeStandardToHDLitMaterialUpgrader()
{
var newShader = Shader.Find("HDRenderPipeline/Lit");
var mat = new Material(Shader.Find("Standard"));
var albedo = new Texture2D(1, 1);
var normals = new Texture2D(1, 1);
var baseScale = new Vector2(1, 1);
var color = Color.red;
mat.mainTexture = albedo;
mat.SetTexture("_BumpMap", normals);
mat.color = color;
mat.SetTextureScale("_MainTex", baseScale);
var upgrader = new StandardToHDLitMaterialUpgrader();
MaterialUpgrader.Upgrade(mat, upgrader, MaterialUpgrader.UpgradeFlags.CleanupNonUpgradedProperties);
Assert.AreEqual(newShader, mat.shader);
Assert.AreEqual(albedo, mat.GetTexture("_BaseColorMap"));
Assert.AreEqual(color, mat.GetColor("_BaseColor"));
Assert.AreEqual(baseScale, mat.GetTextureScale("_BaseColorMap"));
Assert.AreEqual(normals, mat.GetTexture("_NormalMap"));
Assert.IsTrue(mat.IsKeywordEnabled("_NORMALMAP"));
}
}
}

3
Tests/Editor/MaterialUpgraderTests.cs.meta


fileFormatVersion: 2
guid: 20d5442c0aea41919653fbc75ca174d1
timeCreated: 1512986339
正在加载...
取消
保存