Peter Bay Bastian
7 年前
当前提交
f1dbee8e
共有 7 个文件被更改,包括 68 次插入 和 50 次删除
-
2ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
-
25ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs
-
24ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs
-
3Tests/Editor.meta
-
61Tests/Editor/MaterialUpgraderTests.cs
-
3Tests/Editor/MaterialUpgraderTests.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 0f6887a1ff514ed690ada3786867d216 |
|||
timeCreated: 1512986333 |
|
|||
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")); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 20d5442c0aea41919653fbc75ca174d1 |
|||
timeCreated: 1512986339 |
撰写
预览
正在加载...
取消
保存
Reference in new issue