You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.4 KiB
61 lines
2.4 KiB
using System; |
|
using NUnit.Framework; |
|
using UnityEngine; |
|
|
|
namespace UnityEditor.ShaderGraph.UnitTests |
|
{ |
|
[TestFixture] |
|
class PixelShaderNodeTests |
|
{ |
|
/* private UnityEngine.MaterialGraph.MaterialGraph m_Graph; |
|
private Vector1Node m_InputOne; |
|
private AbsoluteNode m_Abs; |
|
private MetallicMasterNode m_PixelNode; |
|
|
|
[TestFixtureSetUp] |
|
public void RunBeforeAnyTests() |
|
{ |
|
Debug.unityLogger.logHandler = new ConsoleLogHandler(); |
|
} |
|
|
|
[SetUp] |
|
public void TestSetUp() |
|
{ |
|
m_Graph = new UnityEngine.MaterialGraph.MaterialGraph(); |
|
m_PixelNode = new MetallicMasterNode(); |
|
m_InputOne = new Vector1Node(); |
|
m_Abs = new AbsoluteNode(); |
|
|
|
m_Graph.AddNode(m_PixelNode); |
|
m_Graph.AddNode(m_InputOne); |
|
m_Graph.AddNode(m_PixelNode); |
|
m_Graph.AddNode(m_Abs); |
|
|
|
m_InputOne.value = 0.2f; |
|
|
|
m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.NormalSlotId)); |
|
|
|
// m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_Abs.GetSlotReference(Function1Input.InputSlotId)); |
|
//m_Graph.Connect(m_Abs.GetSlotReference(Function1Input.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.AlbedoSlotId)); |
|
} |
|
|
|
[Test] |
|
public void TestNodeGeneratesCorrectNodeCode() |
|
{ |
|
string expected = string.Format("half {0} = 0.2;" + Environment.NewLine |
|
+ "half {1} = abs ({0});" + Environment.NewLine |
|
+ "o.Albedo = {1};" + Environment.NewLine |
|
+ "o.Normal = {0};" + Environment.NewLine |
|
, m_InputOne.GetVariableNameForSlot(Vector1Node.OutputSlotId) |
|
, m_Abs.GetVariableNameForSlot(Function1Input.OutputSlotId)); |
|
|
|
var generator = new ShaderGenerator(); |
|
m_PixelNode.GenerateNodeCode(generator, GenerationMode.ForReals); |
|
|
|
Console.WriteLine(generator.GetShaderString(0)); |
|
|
|
Assert.AreEqual(expected, generator.GetShaderString(0)); |
|
Assert.AreEqual(string.Empty, generator.GetPragmaString()); |
|
}*/ |
|
} |
|
}
|
|
|