您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
61 行
2.4 KiB
61 行
2.4 KiB
using System;
|
|
using NUnit.Framework;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.ShaderGraph.UnitTests
|
|
{
|
|
[TestFixture]
|
|
public 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());
|
|
}*/
|
|
}
|
|
}
|