Tim Cooper
9 年前
当前提交
addd6c34
共有 10 个文件被更改,包括 514 次插入 和 8 次删除
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/TextureNode.cs
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs
-
222MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/DynamicSlotTests.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/DynamicSlotTests.cs.meta
-
23MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs.meta
-
208MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/ShaderGeneratorTests.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/ShaderGeneratorTests.cs.meta
|
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Tests |
|||
{ |
|||
[TestFixture] |
|||
public class DynamicSlotTests |
|||
{ |
|||
private PixelGraph m_Graph; |
|||
private DynamicNode m_DynamicNode; |
|||
private TestNode m_StaticNode; |
|||
|
|||
class DynamicNode : AbstractMaterialNode |
|||
{ |
|||
public DynamicNode() |
|||
{ |
|||
AddSlot(new MaterialSlot("DynIn1", "DynIn1", SlotType.Input, 0, SlotValueType.Dynamic, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("DynIn2", "DynIn2", SlotType.Input, 1, SlotValueType.Dynamic, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("DynOut", "DynOut", SlotType.Output, 0, SlotValueType.Dynamic, Vector4.zero)); |
|||
} |
|||
} |
|||
|
|||
class TestNode : AbstractMaterialNode |
|||
{ |
|||
public TestNode() |
|||
{ |
|||
AddSlot(new MaterialSlot("V1Out", "V1Out", SlotType.Output, 0, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("V2Out", "V2Out", SlotType.Output, 1, SlotValueType.Vector2, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("V3Out", "V3Out", SlotType.Output, 2, SlotValueType.Vector3, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("V4Out", "V4Out", SlotType.Output, 3, SlotValueType.Vector4, Vector4.zero)); |
|||
} |
|||
} |
|||
|
|||
[SetUp] |
|||
public void TestSetUp() |
|||
{ |
|||
m_Graph = new PixelGraph(); |
|||
m_DynamicNode = new DynamicNode(); |
|||
m_Graph.AddNode(m_DynamicNode); |
|||
m_StaticNode = new TestNode(); |
|||
m_Graph.AddNode(m_StaticNode); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV1NoneWorks() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector1, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV1V1Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector1, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV1V2Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV1V3Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector3, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV1V4Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector4, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV2NoneWorks() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV2V1Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV2V2Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV2V3Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV2V4Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV3NoneWorks() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector3, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV3V1Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector3, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV3V2Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV3V3Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector3, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV3V4Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector3, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV4NoneWorks() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector4, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV4V1Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V1Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector4, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV4V2Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V2Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector2, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV4V3Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V3Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector3, dynOut1.concreteValueType); |
|||
} |
|||
|
|||
[Test] |
|||
public void DynamicInputsV4V4Works() |
|||
{ |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn1")); |
|||
m_Graph.Connect(m_StaticNode.GetSlotReference("V4Out"), m_DynamicNode.GetSlotReference("DynIn2")); |
|||
var dynOut1 = m_DynamicNode.FindOutputSlot<MaterialSlot>("DynOut"); |
|||
Assert.AreEqual(ConcreteSlotValueType.Vector4, dynOut1.concreteValueType); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d6e750ecfd4623440a02fd8252326d93 |
|||
timeCreated: 1466512880 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Linq; |
|||
using NUnit.Framework; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Tests |
|||
{ |
|||
[TestFixture] |
|||
public class MaterialNodeTests |
|||
{ |
|||
[Test] |
|||
public void TestCanAddMaterialNodeToMaterialGraph() |
|||
{ |
|||
/*var graph = new PixelGraph(); |
|||
graph.AddNode(new PixelShaderNode()); |
|||
|
|||
var node = new AbstractMaterialGraphTests.TestableMNode(); |
|||
graph.AddNode(node); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.GetNodes<AbstractMaterialNode>().Count());*/ |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8f553306b9101064eb1010e15de5f567 |
|||
timeCreated: 1466414003 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Tests |
|||
{ |
|||
[TestFixture] |
|||
public class ShaderGeneratorTests |
|||
{ |
|||
[Test] |
|||
public void TestTexturePropertyChunkGeneratesValidPropertyStringNotHiddenNotModifiable() |
|||
{ |
|||
var chunk = new TexturePropertyChunk("TexProp", "Description", null, TextureType.White, false, false); |
|||
Assert.AreEqual("[NonModifiableTextureData] TexProp(\"Description\", 2D) = \"white\" {}" , chunk.GetPropertyString()); |
|||
Assert.IsFalse(chunk.modifiable); |
|||
Assert.IsFalse(chunk.hidden); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestTexturePropertyChunkGeneratesValidPropertyStringHiddenNotModifiable() |
|||
{ |
|||
var chunk = new TexturePropertyChunk("TexProp", "Description", null, TextureType.White, true, false); |
|||
Assert.AreEqual("[HideInInspector] [NonModifiableTextureData] TexProp(\"Description\", 2D) = \"white\" {}", chunk.GetPropertyString()); |
|||
Assert.IsFalse(chunk.modifiable); |
|||
Assert.IsTrue(chunk.hidden); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestColorPropertyChunkGeneratesValidPropertyString() |
|||
{ |
|||
var chunk = new ColorPropertyChunk("ColProp", "Description", Color.green, false); |
|||
Assert.AreEqual("ColProp(\"Description\", Color) = (0,1,0,1)", chunk.GetPropertyString()); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestFloatPropertyChunkGeneratesValidPropertyString() |
|||
{ |
|||
var chunk = new FloatPropertyChunk("FloatProp", "Description", 0.3f, false); |
|||
Assert.AreEqual("FloatProp(\"Description\", Float) = 0.3", chunk.GetPropertyString()); |
|||
} |
|||
|
|||
[Test] |
|||
public void VectorPropertyChunkGeneratesValidPropertyString() |
|||
{ |
|||
var chunk = new VectorPropertyChunk("VectorProp", "Description", new Vector4(0, 0, 1, 0), false); |
|||
Assert.AreEqual("VectorProp(\"Description\", Vector) = (0,0,1,0)", chunk.GetPropertyString()); |
|||
} |
|||
|
|||
class TestNode : AbstractMaterialNode |
|||
{ |
|||
public TestNode() |
|||
{ |
|||
AddSlot(new MaterialSlot("V1Out", "V1Out", SlotType.Output, 0, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("V2Out", "V2Out", SlotType.Output, 1, SlotValueType.Vector2, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("V3Out", "V3Out", SlotType.Output, 2, SlotValueType.Vector3, Vector4.zero)); |
|||
AddSlot(new MaterialSlot("V4Out", "V4Out", SlotType.Output, 3, SlotValueType.Vector4, Vector4.zero)); |
|||
} |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput1To1Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V1Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector1); |
|||
Assert.AreEqual(string.Format("{0}", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput1To2Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V1Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector2); |
|||
Assert.AreEqual(string.Format("({0})", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput1To3Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V1Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector3); |
|||
Assert.AreEqual(string.Format("({0})", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput1To4Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V1Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector4); |
|||
Assert.AreEqual(string.Format("({0})", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput2To1Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V2Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector1); |
|||
Assert.AreEqual(string.Format("({0}).x", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput2To2Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V2Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector2); |
|||
Assert.AreEqual(string.Format("{0}", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput2To3CausesError() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V2Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector3); |
|||
Assert.AreEqual("ERROR!", result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput2To4CausesError() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V2Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector4); |
|||
Assert.AreEqual("ERROR!", result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput3To1Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V3Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector1); |
|||
Assert.AreEqual(string.Format("({0}).x", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput3To2Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V3Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector2); |
|||
Assert.AreEqual(string.Format("({0}.xy)", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput3To3Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V3Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector3); |
|||
Assert.AreEqual(string.Format("{0}", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput3To4CausesError() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V3Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector4); |
|||
Assert.AreEqual("ERROR!", result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput4To1Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V4Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector1); |
|||
Assert.AreEqual(string.Format("({0}).x", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput4To2Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V4Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector2); |
|||
Assert.AreEqual(string.Format("({0}.xy)", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput4To3Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V4Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector3); |
|||
Assert.AreEqual(string.Format("({0}.xyz)", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
[Test] |
|||
public void AdaptNodeOutput4To4Works() |
|||
{ |
|||
var node = new TestNode(); |
|||
var slot = node.FindOutputSlot<MaterialSlot>("V4Out"); |
|||
var result = ShaderGenerator.AdaptNodeOutput(node, slot, ConcreteSlotValueType.Vector4); |
|||
Assert.AreEqual(string.Format("{0}", node.GetOutputVariableNameForSlot(slot)), result); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bf6df2fd463c5a3489c65eee884c8488 |
|||
timeCreated: 1466509587 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue