浏览代码

Merge branch 'exposed-prop-subgraph'

# Conflicts:
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphIONode.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphIONode.cs.meta
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphOutputNode.cs
/main
Tim Cooper 7 年前
当前提交
a5c9b0ce
共有 101 个文件被更改,包括 3223 次插入881 次删除
  1. 6
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs
  2. 5
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableSlot.cs
  3. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/ConstantsNode.cs
  4. 12
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/GradientNode.cs
  5. 4
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/ParallaxNode.cs
  6. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs
  7. 16
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/TextureSamplerNode.cs
  8. 4
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs
  9. 10
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/MultiLayerParallaxNode.cs
  10. 12
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/VertexNormalNode.cs
  11. 146
      MaterialGraphProject/Assets/PartyPreview.ShaderGraph
  12. 2
      MaterialGraphProject/Assets/PartyPreview.ShaderGraph.meta
  13. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
  14. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs.meta
  15. 239
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
  16. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractShaderProperty.cs
  17. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialGraph.cs
  18. 655
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs
  19. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/MaterialGraphChange.cs
  20. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightMetallicMasterNode.cs
  21. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightSpecularMasterNode.cs
  22. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightUnlitMasterNode.cs
  23. 163
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs
  24. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Channel/SplitNode.cs
  25. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/HLSLNode.cs
  26. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/ColorNode.cs
  27. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentNode.cs
  28. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalNode.cs
  29. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs
  30. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs
  31. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs
  32. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs
  33. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs
  34. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs
  35. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs
  36. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs
  37. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs
  38. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs
  39. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/CameraDirNode.cs
  40. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/CameraPosNode.cs
  41. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/ScreenPosNode.cs
  42. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/SinTimeNode.cs
  43. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/TimeNode.cs
  44. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector1Node.cs
  45. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector2Node.cs
  46. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector3Node.cs
  47. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector4Node.cs
  48. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs
  49. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixMultiplyNode.cs
  50. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyNode.cs
  51. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs
  52. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VertexInterpolatorNode.cs
  53. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph.meta
  54. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphNode.cs
  55. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs
  56. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphNode.cs
  57. 47
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs
  58. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs.meta
  59. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  60. 68
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  61. 56
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/IMGUISlotEditorView.cs
  62. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/BasicNodeInspector.cs
  63. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphOutputNodeInspector.cs
  64. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  65. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/MasterRemapGraphImporterEditor.cs
  66. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
  67. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporterEditor.cs
  68. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/DynamicSlotTests.cs
  69. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/FixedSlotTests.cs
  70. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
  71. 90
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialSlotTests.cs
  72. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/ShaderGeneratorTests.cs
  73. 24
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateLayeredShaderGraph.cs
  74. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateLayeredShaderGraph.cs.meta
  75. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderGraph.cs
  76. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderGraph.cs.meta
  77. 37
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableGuid.cs
  78. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableGuid.cs.meta
  79. 115
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig
  80. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig.meta
  81. 126
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig
  82. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig.meta
  83. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayerWeightsOutputNode.cs
  84. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayerWeightsOutputNode.cs.meta
  85. 361
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs
  86. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs.meta
  87. 470
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs.orig
  88. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs.orig.meta
  89. 260
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs.orig
  90. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs.orig.meta
  91. 46
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderLayerview.cs
  92. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderLayerview.cs.meta
  93. 395
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs.orig
  94. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs.orig.meta
  95. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes.meta
  96. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime.meta
  97. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs
  98. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs.meta
  99. 153
      MaterialGraphProject/Assets/fresnelstuff.ShaderSubGraph

6
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs


AddEdgeToNodeEdges(edge);
OnEnable();
ValidateGraph();
ValidateGraph();
}
public virtual void ValidateGraph()

//manually modifies serialized data
//of if they delete a node in the inspector
//debug view.
foreach (var edge in edges.ToArray())
//debug view.
foreach (var edge in edges.ToArray())
{
var outputNode = GetNodeFromGuid(edge.outputSlot.nodeGuid);
var inputNode = GetNodeFromGuid(edge.inputSlot.nodeGuid);

5
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableSlot.cs


get { return m_SlotType == SlotType.Output; }
}
public SlotType slotType
{
get { return m_SlotType; }
}
// used via reflection / serialization after deserialize
// to reconstruct this slot.
public SerializableSlot()

2
MaterialGraphProject/Assets/NewNodes/Editor/Keep/ConstantsNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector1MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

12
MaterialGraphProject/Assets/NewNodes/Editor/Keep/GradientNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(TimeInputSlotId, k_TimeInputSlotName, k_TimeInputSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(RGBAOutputSlotId, k_RGBAOutputSlotName, k_RGBAOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(ROutputSlotId, k_ROutputSlotName, k_ROutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(GOutputSlotId, k_GOutputSlotName, k_GOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(BOutputSlotId, k_BOutputSlotName, k_BOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AOutputSlotId, k_AOutputSlotName, k_AOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector1MaterialSlot(TimeInputSlotId, k_TimeInputSlotName, k_TimeInputSlotName, SlotType.Input,0));
AddSlot(new Vector4MaterialSlot(RGBAOutputSlotId, k_RGBAOutputSlotName, k_RGBAOutputSlotName, SlotType.Output, Vector4.zero));
AddSlot(new Vector1MaterialSlot(ROutputSlotId, k_ROutputSlotName, k_ROutputSlotName, SlotType.Output,0));
AddSlot(new Vector1MaterialSlot(GOutputSlotId, k_GOutputSlotName, k_GOutputSlotName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(BOutputSlotId, k_BOutputSlotName, k_BOutputSlotName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(AOutputSlotId, k_AOutputSlotName, k_AOutputSlotName, SlotType.Output, 0));
RemoveSlotsNameNotMatching(new[] { TimeInputSlotId, RGBAOutputSlotId, ROutputSlotId, GOutputSlotId, BOutputSlotId, AOutputSlotId });
m_Gradient = new Gradient();
var colorKeys = m_SerializableColorKeys.Select(k => new GradientColorKey(new Color(k.x, k.y, k.z, 1f), k.w)).ToArray();

4
MaterialGraphProject/Assets/NewNodes/Editor/Keep/ParallaxNode.cs


protected virtual MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
return new Vector1MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, 1);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector4.zero);
return new Vector2MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, Vector2.zero);
}
protected virtual string GetInputSlot1Name()

2
MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.SamplerState, Vector4.zero));
AddSlot(new SamplerStateMaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

16
MaterialGraphProject/Assets/NewNodes/Editor/Keep/TextureSamplerNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRId, kOutputSlotRName, kOutputSlotRName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TextureInputId, kTextureInputName, kTextureInputName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero));
AddSlot(new MaterialSlot(UVInput, kUVInputName, kUVInputName, SlotType.Input, SlotValueType.Vector2, Vector4.zero));
AddSlot(new MaterialSlot(SamplerInput, kSamplerInputName, kSamplerInputName, SlotType.Input, SlotValueType.SamplerState, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, Vector4.zero));
AddSlot(new Vector1MaterialSlot(OutputSlotRId, kOutputSlotRName, kOutputSlotRName, SlotType.Output,0));
AddSlot(new Vector1MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, 0));
AddSlot(new Texture2DMaterialSlot(TextureInputId, kTextureInputName, kTextureInputName, SlotType.Input));
AddSlot(new Vector2MaterialSlot(UVInput, kUVInputName, kUVInputName, SlotType.Input, Vector4.zero));
AddSlot(new SamplerStateMaterialSlot(SamplerInput, kSamplerInputName, kSamplerInputName, SlotType.Input));
RemoveSlotsNameNotMatching(new[] { OutputSlotRGBAId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, TextureInputId, UVInput, SamplerInput });
}

4
MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs


protected virtual MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero);
return new Vector3MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, Vector3.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
return new Vector3MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, Vector4.zero);
}
protected virtual string GetInputSlotName()

10
MaterialGraphProject/Assets/NewNodes/Editor/Kill/MultiLayerParallaxNode.cs


protected virtual MaterialSlot GetInputDepthSlot()
{
return new MaterialSlot(InputDepthSlotId, GetInputSlot1Name(), kInputDepthShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
return new Vector1MaterialSlot(InputDepthSlotId, GetInputSlot1Name(), kInputDepthShaderName, SlotType.Input,0);
return new MaterialSlot(InputFadeRateSlotId, GetInputSlot2Name(), kInputFadeRateShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
return new DynamicVectorMaterialSlot(InputFadeRateSlotId, GetInputSlot2Name(), kInputFadeRateShaderName, SlotType.Input, Vector4.zero);
return new MaterialSlot(InputLayerCountSlotId, GetInputSlot3Name(), kInputLayerCountShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
return new DynamicVectorMaterialSlot(InputLayerCountSlotId, GetInputSlot3Name(), kInputLayerCountShaderName, SlotType.Input, Vector4.zero);
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
return new Texture2DMaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
return new DynamicVectorMaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, Vector4.zero);
}
protected virtual string GetInputSlot1Name()

12
MaterialGraphProject/Assets/NewNodes/Editor/Kill/VertexNormalNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdXYZ, kOutputSlotNameXYZ, kOutputSlotNameXYZ, SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdX, kOutputSlotNameX, kOutputSlotNameX, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(OutputSlotIdXYZ, kOutputSlotNameXYZ, kOutputSlotNameXYZ, SlotType.Output, Vector4.zero));
AddSlot(new Vector1MaterialSlot(OutputSlotIdX, kOutputSlotNameX, kOutputSlotNameX, SlotType.Output,0));
AddSlot(new Vector1MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output,0));
AddSlot(new Vector1MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, 0));
RemoveSlotsNameNotMatching(validSlots);
}

146
MaterialGraphProject/Assets/PartyPreview.ShaderGraph
文件差异内容过多而无法显示
查看文件

2
MaterialGraphProject/Assets/PartyPreview.ShaderGraph.meta


externalObjects: {}
defaultTextures: []
nonModifiableTextures:
- Texture: {fileID: 2800000, guid: e2e7994f2c9b58f40aaebdaabbbd0ad8, type: 3}
- Texture_AE39B836: {fileID: 2800000, guid: e2e7994f2c9b58f40aaebdaabbbd0ad8, type: 3}
userData:
assetBundleName:
assetBundleVariant:

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs


public override void Action(int instanceId, string pathName, string resourceFile)
{
var graph = new UnityEngine.MaterialGraph.MaterialGraph();
// graph.AddNode(new MetallicMasterNode());
graph.AddNode(new LightweightMetallicMasterNode());
File.WriteAllText(pathName, EditorJsonUtility.ToJson(graph));
AssetDatabase.Refresh();
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs.meta


fileFormatVersion: 2
guid: 706886b5adec4e3409ceb9a30e04440e
guid: f329b5b280b7f6f449659f05937ac2f2
timeCreated: 1465559218
licenseType: Pro
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

239
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs


base.OnAfterDeserialize();
}
static ShaderGraphRequirements GetRequierments(AbstractMaterialNode nodeForRequirements)
protected static ShaderGraphRequirements GetRequierments(AbstractMaterialNode nodeForRequirements)
if (nodeForRequirements == null)
return ShaderGraphRequirements.none;
var activeNodeList = ListPool<INode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, nodeForRequirements);

return reqs;
}
static void GenerateSpaceTranslationSurfaceInputs(
protected static void GenerateSpaceTranslationSurfaceInputs(
NeededCoordinateSpace neededSpaces,
ShaderGenerator surfaceInputs,
string objectSpaceName,

return GetShader(node, GenerationMode.Preview, string.Format("hidden/preview/{0}", node.GetVariableNameForNode()), out configuredTextures, out previewMode);
}
public string GetShader(AbstractMaterialNode node, GenerationMode mode, string name, out List<PropertyCollector.TextureInfo> configuredTextures, out PreviewMode previewMode)
protected static void GenerateSurfaceDescriptionStruct(ShaderGenerator surfaceDescriptionStruct, AbstractMaterialNode node, bool isMasterNode)
if (node == null)
throw new ArgumentNullException("node");
var vertexShader = new ShaderGenerator();
var surfaceDescriptionFunction = new ShaderGenerator();
var surfaceDescriptionStruct = new ShaderGenerator();
var shaderFunctionVisitor = new ShaderGenerator();
var surfaceInputs = new ShaderGenerator();
var graphVertexInput = @"
struct GraphVertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 texcoord0 : TEXCOORD0;
float4 lightmapUV : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};";
surfaceInputs.AddShaderChunk("struct SurfaceInputs{", false);
surfaceInputs.Indent();
var requirements = GetRequierments(node);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresNormal, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceNormal, ShaderGeneratorNames.ViewSpaceNormal,
ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.TangentSpaceNormal);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresTangent, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceTangent, ShaderGeneratorNames.ViewSpaceTangent,
ShaderGeneratorNames.WorldSpaceTangent, ShaderGeneratorNames.TangentSpaceTangent);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresBitangent, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceBiTangent, ShaderGeneratorNames.ViewSpaceBiTangent,
ShaderGeneratorNames.WorldSpaceBiTangent, ShaderGeneratorNames.TangentSpaceBiTangent);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresViewDir, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceViewDirection, ShaderGeneratorNames.ViewSpaceViewDirection,
ShaderGeneratorNames.WorldSpaceViewDirection, ShaderGeneratorNames.TangentSpaceViewDirection);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresPosition, surfaceInputs,
ShaderGeneratorNames.ObjectSpacePosition, ShaderGeneratorNames.ViewSpacePosition,
ShaderGeneratorNames.WorldSpacePosition, ShaderGeneratorNames.TangentSpacePosition);
if (requirements.requiresVertexColor)
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.VertexColor), false);
if (requirements.requiresScreenPosition)
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.ScreenPosition), false);
var activeNodeList = ListPool<INode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, node);
previewMode = PreviewMode.Preview2D;
foreach (var pNode in activeNodeList.OfType<AbstractMaterialNode>())
surfaceDescriptionStruct.AddShaderChunk("struct SurfaceDescription{", false);
surfaceDescriptionStruct.Indent();
if (isMasterNode)
if (pNode.previewMode == PreviewMode.Preview3D)
{
previewMode = PreviewMode.Preview3D;
break;
}
foreach (var slot in node.GetInputSlots<MaterialSlot>())
surfaceDescriptionStruct.AddShaderChunk(string.Format("{0} {1};", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType), slot.shaderOutputName), false);
foreach (var channel in requirements.requiresMeshUVs.Distinct())
surfaceInputs.AddShaderChunk(string.Format("half4 {0};", channel.GetUVName()), false);
else
{
foreach (var slot in node.GetOutputSlots<MaterialSlot>())
surfaceDescriptionStruct.AddShaderChunk(string.Format("{0} {1};", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType), node.GetVariableNameForSlot(slot.id)), false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
surfaceInputs.Deindent();
surfaceInputs.AddShaderChunk("};", false);
vertexShader.AddShaderChunk("GraphVertexInput PopulateVertexData(GraphVertexInput v){", false);
vertexShader.Indent();
vertexShader.AddShaderChunk("return v;", false);
vertexShader.Deindent();
vertexShader.AddShaderChunk("}", false);
surfaceDescriptionStruct.AddShaderChunk("void ScaleSurfaceDescription(inout SurfaceDescription surface, float scale){", false);
surfaceDescriptionStruct.Indent();
if (isMasterNode)
{
foreach (var slot in node.GetInputSlots<MaterialSlot>())
surfaceDescriptionStruct.AddShaderChunk( string.Format("surface.{0} = scale * surface.{0};", slot.shaderOutputName), false);
}
else
{
foreach (var slot in node.GetOutputSlots<MaterialSlot>())
surfaceDescriptionStruct.AddShaderChunk(string.Format("surface.{0} = scale * surface.{0};", node.GetVariableNameForSlot(slot.id)), false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
surfaceDescriptionStruct.AddShaderChunk("struct SurfaceDescription{", false);
surfaceDescriptionStruct.AddShaderChunk("void AddSurfaceDescription(inout SurfaceDescription base, in SurfaceDescription add){", false);
if (node is IMasterNode)
if (isMasterNode)
surfaceDescriptionStruct.AddShaderChunk(AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType) + " " + slot.shaderOutputName + ";", false);
{
var str = string.Format("base.{0} = base.{0} + add.{0};", slot.shaderOutputName);
surfaceDescriptionStruct.AddShaderChunk(str, false);
}
surfaceDescriptionStruct.AddShaderChunk(AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType) + " " + node.GetVariableNameForSlot(slot.id) + ";", false);
{
var str = string.Format("base.{0} = base.{0} + add.{0};", node.GetVariableNameForSlot(slot.id));
surfaceDescriptionStruct.AddShaderChunk(str, false);
}
}
surfaceDescriptionFunction.AddShaderChunk("SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) {", false);
protected static void GenerateSurfaceDescription(
AbstractMaterialNode node,
ShaderGenerator surfaceDescriptionFunction,
ShaderGenerator shaderFunctionVisitor,
PropertyCollector shaderProperties,
ShaderGraphRequirements requirements,
GenerationMode mode,
bool isMasterNode,
string functionName = "PopulateSurfaceData",
string surfaceDescriptionName = "SurfaceDescription")
{
var graph = node.owner as AbstractMaterialGraph;
if (graph == null)
return;
surfaceDescriptionFunction.AddShaderChunk(string.Format("{0} {1}(SurfaceInputs IN) {{", surfaceDescriptionName, functionName), false);
surfaceDescriptionFunction.Indent();
if ((requirements.requiresNormal & NeededCoordinateSpace.Object) > 0)

foreach (var channel in requirements.requiresMeshUVs.Distinct())
surfaceDescriptionFunction.AddShaderChunk(string.Format("half4 {0} = IN.{0};", channel.GetUVName()), false);
var shaderProperties = new PropertyCollector();
CollectShaderProperties(shaderProperties, mode);
graph.CollectShaderProperties(shaderProperties, mode);
var activeNodeList = ListPool<INode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, node);
foreach (var activeNode in activeNodeList.OfType<AbstractMaterialNode>())
{
if (activeNode is IGeneratesFunction)

activeNode.CollectShaderProperties(shaderProperties, mode);
}
surfaceDescriptionFunction.AddShaderChunk("SurfaceDescription surface = (SurfaceDescription)0;", false);
if (node is IMasterNode)
surfaceDescriptionFunction.AddShaderChunk(string.Format("{0} surface = ({0})0;", surfaceDescriptionName), false);
if (isMasterNode)
var foundEdges = GetEdges(input.slotReference).ToArray();
var foundEdges = graph.GetEdges(input.slotReference).ToArray();
var fromNode = GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
var fromNode = graph.GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
surfaceDescriptionFunction.AddShaderChunk(string.Format("surface.{0} = {1};", input.shaderOutputName, fromNode.GetVariableNameForSlot(outputRef.slotId)), true);
}
else

surfaceDescriptionFunction.Deindent();
surfaceDescriptionFunction.AddShaderChunk("}", false);
ListPool<INode>.Release(activeNodeList);
}
public string GetShader(AbstractMaterialNode node, GenerationMode mode, string name, out List<PropertyCollector.TextureInfo> configuredTextures, out PreviewMode previewMode)
{
if (node == null)
throw new ArgumentNullException("node");
var vertexShader = new ShaderGenerator();
var surfaceDescriptionFunction = new ShaderGenerator();
var surfaceDescriptionStruct = new ShaderGenerator();
var shaderFunctionVisitor = new ShaderGenerator();
var surfaceInputs = new ShaderGenerator();
var graphVertexInput = @"
struct GraphVertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 texcoord0 : TEXCOORD0;
float4 lightmapUV : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};";
surfaceInputs.AddShaderChunk("struct SurfaceInputs{", false);
surfaceInputs.Indent();
var requirements = GetRequierments(node);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresNormal, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceNormal, ShaderGeneratorNames.ViewSpaceNormal,
ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.TangentSpaceNormal);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresTangent, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceTangent, ShaderGeneratorNames.ViewSpaceTangent,
ShaderGeneratorNames.WorldSpaceTangent, ShaderGeneratorNames.TangentSpaceTangent);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresBitangent, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceBiTangent, ShaderGeneratorNames.ViewSpaceBiTangent,
ShaderGeneratorNames.WorldSpaceBiTangent, ShaderGeneratorNames.TangentSpaceBiTangent);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresViewDir, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceViewDirection, ShaderGeneratorNames.ViewSpaceViewDirection,
ShaderGeneratorNames.WorldSpaceViewDirection, ShaderGeneratorNames.TangentSpaceViewDirection);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresPosition, surfaceInputs,
ShaderGeneratorNames.ObjectSpacePosition, ShaderGeneratorNames.ViewSpacePosition,
ShaderGeneratorNames.WorldSpacePosition, ShaderGeneratorNames.TangentSpacePosition);
if (requirements.requiresVertexColor)
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.VertexColor), false);
if (requirements.requiresScreenPosition)
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.ScreenPosition), false);
var activeNodeList = ListPool<INode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, node);
previewMode = PreviewMode.Preview2D;
foreach (var pNode in activeNodeList.OfType<AbstractMaterialNode>())
{
if (pNode.previewMode == PreviewMode.Preview3D)
{
previewMode = PreviewMode.Preview3D;
break;
}
}
ListPool<INode>.Release(activeNodeList);
foreach (var channel in requirements.requiresMeshUVs.Distinct())
surfaceInputs.AddShaderChunk(string.Format("half4 {0};", channel.GetUVName()), false);
surfaceInputs.Deindent();
surfaceInputs.AddShaderChunk("};", false);
vertexShader.AddShaderChunk("GraphVertexInput PopulateVertexData(GraphVertexInput v){", false);
vertexShader.Indent();
vertexShader.AddShaderChunk("return v;", false);
vertexShader.Deindent();
vertexShader.AddShaderChunk("}", false);
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, node, node is IMasterNode);
var shaderProperties = new PropertyCollector();
GenerateSurfaceDescription(
node,
surfaceDescriptionFunction,
shaderFunctionVisitor,
shaderProperties,
requirements,
mode,
node is IMasterNode);
var finalShader = new ShaderGenerator();
finalShader.AddShaderChunk(string.Format(@"Shader ""{0}""", name), false);

34
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractShaderProperty.cs


namespace UnityEngine.MaterialGraph
{
[Serializable]
public abstract class AbstractShaderProperty<T> : ISerializationCallbackReceiver, IShaderProperty
public abstract class AbstractShaderProperty<T> : IShaderProperty
[SerializeField]
private string m_Description;
[NonSerialized]
private Guid m_Guid;
private string m_GuidSerialized;
private bool m_GeneratePropertyBlock = true;
private bool m_GeneratePropertyBlock = true;
protected AbstractShaderProperty()
{
m_Guid = Guid.NewGuid();
}
private SerializableGuid m_Guid = new SerializableGuid();
public T value
{

get
{
if (string.IsNullOrEmpty(m_Name))
return m_Guid.ToString();
return guid.ToString();
return m_Name;
}
set { m_Name = value; }

public Guid guid
{
get { return m_Guid; }
get { return m_Guid.guid; }
}
public bool generatePropertyBlock

}
public abstract PreviewProperty GetPreviewMaterialProperty();
public virtual void OnBeforeSerialize()
{
m_GuidSerialized = m_Guid.ToString();
}
public virtual void OnAfterDeserialize()
{
if (!string.IsNullOrEmpty(m_GuidSerialized))
m_Guid = new Guid(m_GuidSerialized);
else
m_Guid = Guid.NewGuid();
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialGraph.cs


namespace UnityEngine.MaterialGraph
{
[Serializable]
public class MaterialGraph : AbstractMaterialGraph
public class MaterialGraph : AbstractMaterialGraph, IShaderGraph
{
public IMasterNode masterNode
{

PreviewMode pmode;
return GetShader(masterNode as AbstractMaterialNode, mode, name, out configuredTextures, out pmode);
}
public override void OnAfterDeserialize()
{
base.OnAfterDeserialize();
}
}
}

655
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs


namespace UnityEngine.MaterialGraph
{
public interface IMaterialSlotHasVaule<T>
{
T defaultValue { get; }
T value { get; }
}
public class MaterialSlot : SerializableSlot
public class Vector1MaterialSlot : MaterialSlot, IMaterialSlotHasVaule<float>
SlotValueType m_ValueType;
private float m_Value;
Vector4 m_DefaultValue;
private float m_DefaultValue;
public Vector1MaterialSlot()
{
}
public Vector1MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
float value,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
m_DefaultValue = value;
m_Value = value;
}
public float defaultValue { get { return m_DefaultValue; } }
public float value
{
get { return m_Value; }
set { m_Value = value; }
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return value.ToString();
}
public override SlotValueType valueType { get { return SlotValueType.Vector1; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Vector1; } }
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty
{
m_Name = name,
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(concreteValueType),
m_Vector4 = new Vector4(value, value, value, value),
m_Float = value,
m_Color = new Vector4(value, value, value, value),
};
return pp;
}
}
[Serializable]
public class Vector2MaterialSlot : MaterialSlot, IMaterialSlotHasVaule<Vector2>
{
Vector4 m_CurrentValue;
private Vector2 m_Value;
ConcreteSlotValueType m_ConcreteValueType;
private Vector2 m_DefaultValue;
public Vector2MaterialSlot()
{
}
public Vector2MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
Vector2 value,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
m_Value = value;
}
public Vector2 defaultValue { get { return m_DefaultValue; } }
public Vector2 value
{
get { return m_Value; }
set { m_Value = value; }
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "2 (" + value.x + "," + value.y + ")";
}
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty
{
m_Name = name,
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(concreteValueType),
m_Vector4 = new Vector4(value.x, value.y, 0, 0),
m_Float = value.x,
m_Color = new Vector4(value.x, value.x, 0, 0),
};
return pp;
}
public override SlotValueType valueType { get { return SlotValueType.Vector2; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Vector2; } }
}
[Serializable]
public class Vector3MaterialSlot : MaterialSlot, IMaterialSlotHasVaule<Vector3>
{
string m_ShaderOutputName;
private Vector3 m_Value;
ShaderStage m_ShaderStage;
private Vector3 m_DefaultValue;
public Vector3MaterialSlot()
{
}
public Vector3MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
Vector3 value,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
m_Value = value;
}
public Vector3 defaultValue { get { return m_DefaultValue; } }
public Vector3 value
{
get { return m_Value; }
set { m_Value = value; }
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "3 (" + value.x + "," + value.y + "," + value.z + ")";
}
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty
{
m_Name = name,
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(concreteValueType),
m_Vector4 = new Vector4(value.x, value.y, value.z, 0),
m_Float = value.x,
m_Color = new Vector4(value.x, value.x, value.z, 0),
};
return pp;
}
public override SlotValueType valueType { get { return SlotValueType.Vector3; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Vector3; } }
}
[Serializable]
public class Vector4MaterialSlot : MaterialSlot, IMaterialSlotHasVaule<Vector4>
{
[SerializeField]
private Vector4 m_Value;
[SerializeField]
private Vector4 m_DefaultValue;
public Vector4MaterialSlot()
{
}
public Vector4MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
Vector4 value,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
m_Value = value;
}
public Vector4 defaultValue { get { return m_DefaultValue; } }
public Vector4 value
{
get { return m_Value; }
set { m_Value = value; }
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "4 (" + value.x + "," + value.y + "," + value.z + "," + value.w + ")";
}
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty
{
m_Name = name,
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(concreteValueType),
m_Vector4 = new Vector4(value.x, value.y, value.z, value.w),
m_Float = value.x,
m_Color = new Vector4(value.x, value.x, value.z, value.w),
};
return pp;
}
public override SlotValueType valueType { get { return SlotValueType.Vector4; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Vector4; } }
}
[Serializable]
public class Matrix2MaterialSlot : MaterialSlot
{
public Matrix2MaterialSlot()
{
}
public Matrix2MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "2x2 (1,0,0,1)";
}
public override SlotValueType valueType { get { return SlotValueType.Matrix2; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Matrix2; } }
}
[Serializable]
public class Matrix3MaterialSlot : MaterialSlot
{
public Matrix3MaterialSlot()
{
}
public Matrix3MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "3x3 (1,0,0,0,1,0,0,0,1)";
}
public override SlotValueType valueType { get { return SlotValueType.Matrix3; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Matrix3; } }
}
[Serializable]
public class Matrix4MaterialSlot : MaterialSlot
{
public Matrix4MaterialSlot()
{
}
public Matrix4MaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "4x4 (1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)";
}
public override SlotValueType valueType { get { return SlotValueType.Matrix4; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Matrix4; } }
}
[Serializable]
public class Texture2DMaterialSlot : MaterialSlot
{
public Texture2DMaterialSlot()
{
}
public Texture2DMaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
}
public MaterialSlot() { }
public override SlotValueType valueType { get { return SlotValueType.Texture2D; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Texture2D; } }
}
[Serializable]
public class SamplerStateMaterialSlot : MaterialSlot
{
public SamplerStateMaterialSlot()
{
}
public MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, SlotValueType valueType, Vector4 defaultValue, ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, slotType, hidden)
public SamplerStateMaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
SharedInitialize(shaderOutputName, valueType, defaultValue, shaderStage);
void SharedInitialize(string inShaderOutputName, SlotValueType inValueType, Vector4 inDefaultValue, ShaderStage shaderStage)
public override SlotValueType valueType { get { return SlotValueType.SamplerState; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.SamplerState; } }
}
[Serializable]
public class DynamicVectorMaterialSlot : MaterialSlot, IMaterialSlotHasVaule<Vector4>
{
[SerializeField]
private Vector4 m_Value;
[SerializeField]
private Vector4 m_DefaultValue;
private ConcreteSlotValueType m_ConcreteValueType = ConcreteSlotValueType.Vector4;
public DynamicVectorMaterialSlot()
m_ShaderOutputName = inShaderOutputName;
valueType = inValueType;
m_DefaultValue = inDefaultValue;
m_CurrentValue = inDefaultValue;
}
public DynamicVectorMaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
Vector4 value,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
:base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
m_Value = value;
}
public Vector4 defaultValue { get { return m_DefaultValue; } }
public Vector4 value
{
get { return m_Value; }
set { m_Value = value; }
}
public override SlotValueType valueType { get { return SlotValueType.Dynamic; } }
public override ConcreteSlotValueType concreteValueType
{
get { return m_ConcreteValueType; }
}
public void SetConcreteType(ConcreteSlotValueType valueType)
{
m_ConcreteValueType = valueType;
}
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty
{
m_Name = name,
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(concreteValueType),
m_Vector4 = new Vector4(value.x, value.y, value.z, value.w),
m_Float = value.x,
m_Color = new Vector4(value.x, value.x, value.z, value.w),
};
return pp;
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "4 (" + value.x + "," + value.y + "," + value.z + "," + value.w + ")";
}
}
[Serializable]
public abstract class MaterialSlot : SerializableSlot
{
[SerializeField]
string m_ShaderOutputName;
[SerializeField]
ShaderStage m_ShaderStage;
private bool m_HasError;
protected MaterialSlot() { }
protected MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, slotType, hidden)
{
m_ShaderOutputName = shaderOutputName;
this.shaderStage = shaderStage;
}

set { base.displayName = value; }
}
public Vector4 defaultValue
public string RawDisplayName()
get { return m_DefaultValue; }
set { m_DefaultValue = value; }
return displayName;
public SlotValueType valueType
public static MaterialSlot CreateMaterialSlot(SlotValueType type, int slotId, string displayName, string shaderOutputName, SlotType slotType, Vector4 defaultValue, ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
get { return m_ValueType; }
set
switch (type)
switch (value)
{
case SlotValueType.Vector1:
concreteValueType = ConcreteSlotValueType.Vector1;
break;
case SlotValueType.Vector2:
concreteValueType = ConcreteSlotValueType.Vector2;
break;
case SlotValueType.Vector3:
concreteValueType = ConcreteSlotValueType.Vector3;
break;
case SlotValueType.Matrix2:
concreteValueType = ConcreteSlotValueType.Matrix2;
break;
case SlotValueType.Matrix3:
concreteValueType = ConcreteSlotValueType.Matrix3;
break;
case SlotValueType.Matrix4:
concreteValueType = ConcreteSlotValueType.Matrix4;
break;
case SlotValueType.Texture2D:
concreteValueType = ConcreteSlotValueType.Texture2D;
break;
case SlotValueType.SamplerState:
concreteValueType = ConcreteSlotValueType.SamplerState;
break;
default:
concreteValueType = ConcreteSlotValueType.Vector4;
break;
}
m_ValueType = value;
case SlotValueType.SamplerState:
return new SamplerStateMaterialSlot(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden);
case SlotValueType.Matrix4:
return new Matrix4MaterialSlot(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden);
case SlotValueType.Matrix3:
return new Matrix3MaterialSlot(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden);
case SlotValueType.Matrix2:
return new Matrix2MaterialSlot(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden);
case SlotValueType.Texture2D:
return new Texture2DMaterialSlot(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden);
case SlotValueType.Dynamic:
return new DynamicVectorMaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector4:
return new Vector4MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector3:
return new Vector3MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector2:
return new Vector2MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector1:
return new Vector1MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue.x, shaderStage, hidden);
}
public Vector4 currentValue
{
get { return m_CurrentValue; }
set { m_CurrentValue = value; }
throw new ArgumentOutOfRangeException("type", type, null);
public ConcreteSlotValueType concreteValueType
{
get { return m_ConcreteValueType; }
set { m_ConcreteValueType = value; }
}
public abstract SlotValueType valueType { get; }
public abstract ConcreteSlotValueType concreteValueType { get; }
public string shaderOutputName
{

set { m_ShaderStage = value; }
}
public bool IsCompatibleWithInputSlotType(SlotValueType inputType)
public bool hasError
switch (valueType)
get { return m_HasError; }
set { m_HasError = value; }
}
public bool IsCompatibleWithInputSlotType(ConcreteSlotValueType inputType)
{
switch (concreteValueType)
case SlotValueType.SamplerState:
return inputType == SlotValueType.SamplerState;
case SlotValueType.Matrix4:
return inputType == SlotValueType.Matrix4
|| inputType == SlotValueType.Matrix3
|| inputType == SlotValueType.Matrix2;
case SlotValueType.Matrix3:
return inputType == SlotValueType.Matrix3
|| inputType == SlotValueType.Matrix2;
case SlotValueType.Matrix2:
return inputType == SlotValueType.Matrix2;
case SlotValueType.Texture2D:
return inputType == SlotValueType.Texture2D;
case SlotValueType.Vector4:
return inputType == SlotValueType.Vector4
|| inputType == SlotValueType.Vector3
|| inputType == SlotValueType.Vector2
|| inputType == SlotValueType.Vector1
|| inputType == SlotValueType.Dynamic;
case SlotValueType.Vector3:
return inputType == SlotValueType.Vector3
|| inputType == SlotValueType.Vector2
|| inputType == SlotValueType.Vector1
|| inputType == SlotValueType.Dynamic;
case SlotValueType.Vector2:
return inputType == SlotValueType.Vector2
|| inputType == SlotValueType.Vector1
|| inputType == SlotValueType.Dynamic;
case SlotValueType.Dynamic:
case SlotValueType.Vector1:
return inputType == SlotValueType.Vector4
|| inputType == SlotValueType.Vector3
|| inputType == SlotValueType.Vector2
|| inputType == SlotValueType.Vector1
|| inputType == SlotValueType.Dynamic;
case ConcreteSlotValueType.SamplerState:
return inputType == ConcreteSlotValueType.SamplerState;
case ConcreteSlotValueType.Matrix4:
return inputType == ConcreteSlotValueType.Matrix4
|| inputType == ConcreteSlotValueType.Matrix3
|| inputType == ConcreteSlotValueType.Matrix2;
case ConcreteSlotValueType.Matrix3:
return inputType == ConcreteSlotValueType.Matrix3
|| inputType == ConcreteSlotValueType.Matrix2;
case ConcreteSlotValueType.Matrix2:
return inputType == ConcreteSlotValueType.Matrix2;
case ConcreteSlotValueType.Texture2D:
return inputType == ConcreteSlotValueType.Texture2D;
case ConcreteSlotValueType.Vector4:
return inputType == ConcreteSlotValueType.Vector4
|| inputType == ConcreteSlotValueType.Vector3
|| inputType == ConcreteSlotValueType.Vector2
|| inputType == ConcreteSlotValueType.Vector1;
case ConcreteSlotValueType.Vector3:
return inputType == ConcreteSlotValueType.Vector3
|| inputType == ConcreteSlotValueType.Vector2
|| inputType == ConcreteSlotValueType.Vector1;
case ConcreteSlotValueType.Vector2:
return inputType == ConcreteSlotValueType.Vector2
|| inputType == ConcreteSlotValueType.Vector1;
case ConcreteSlotValueType.Vector1:
return inputType == ConcreteSlotValueType.Vector4
|| inputType == ConcreteSlotValueType.Vector3
|| inputType == ConcreteSlotValueType.Vector2
|| inputType == ConcreteSlotValueType.Vector1;
public string GetDefaultValue(GenerationMode generationMode)
public virtual string GetDefaultValue(GenerationMode generationMode)
{
var matOwner = owner as AbstractMaterialNode;
if (matOwner == null)

return DefaultTextureName;
return Texture2DMaterialSlot.DefaultTextureName;
switch (concreteValueType)
{
case ConcreteSlotValueType.Vector1:
return m_CurrentValue.x.ToString();
case ConcreteSlotValueType.Vector2:
return matOwner.precision + "2 (" + m_CurrentValue.x + "," + m_CurrentValue.y + ")";
case ConcreteSlotValueType.Vector3:
return matOwner.precision + "3 (" + m_CurrentValue.x + "," + m_CurrentValue.y + "," + m_CurrentValue.z + ")";
case ConcreteSlotValueType.Vector4:
return matOwner.precision + "4 (" + m_CurrentValue.x + "," + m_CurrentValue.y + "," + m_CurrentValue.z + "," + m_CurrentValue.w + ")";
case ConcreteSlotValueType.Matrix2:
return matOwner.precision + "2x2 (" + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ")";
case ConcreteSlotValueType.Matrix3:
return matOwner.precision + "3x3 (" + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ")";
case ConcreteSlotValueType.Matrix4:
return matOwner.precision + "4x4 (" + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.w + ", " + m_CurrentValue.w + ", " + m_CurrentValue.w + ", " + m_CurrentValue.w + ")";
default:
return "error";
}
return ConcreteSlotValueAsVariable(matOwner.precision);
}
protected virtual string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return "error";
}
public void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)

{
var prop = new TextureShaderProperty();
prop.overrideReferenceName = DefaultTextureName;
prop.overrideReferenceName = Texture2DMaterialSlot.DefaultTextureName;
prop.modifiable = false;
prop.generatePropertyBlock = true;
properties.AddShaderProperty(prop);

property.generatePropertyBlock = false;
properties.AddShaderProperty(property);
}
protected static PropertyType ConvertConcreteSlotValueTypeToPropertyType(ConcreteSlotValueType slotValue)
{
switch (slotValue)
{
case ConcreteSlotValueType.Texture2D:
return PropertyType.Texture;
case ConcreteSlotValueType.Vector1:
return PropertyType.Float;
case ConcreteSlotValueType.Vector2:
return PropertyType.Vector2;
case ConcreteSlotValueType.Vector3:
return PropertyType.Vector3;
case ConcreteSlotValueType.Vector4:
return PropertyType.Vector4;
case ConcreteSlotValueType.Matrix2:
return PropertyType.Matrix2;
case ConcreteSlotValueType.Matrix3:
return PropertyType.Matrix3;
case ConcreteSlotValueType.Matrix4:
return PropertyType.Matrix4;
case ConcreteSlotValueType.SamplerState:
return PropertyType.SamplerState;
default:
return PropertyType.Vector4;
}
}
public virtual PreviewProperty GetPreviewProperty(string name)
{
return null;
}
}
}

20
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/MaterialGraphChange.cs


public Guid guid { get; private set; }
}
public class LayerAdded : GraphChange
{
public LayerAdded(LayeredShaderGraph.Layer layer)
{
this.layer = layer;
}
public LayeredShaderGraph.Layer layer { get; private set; }
}
public class LayerRemoved : GraphChange
{
public LayerRemoved(Guid id)
{
this.id = id;
}
public Guid id { get; private set; }
}
}

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightMetallicMasterNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, new Vector4(0.5f, 0.5f, 0.5f), ShaderStage.Fragment));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, new Vector4(0,0,1), ShaderStage.Fragment));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.one, ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, new Vector4(0.5f, 0.5f, 0.5f), ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, new Vector3(0,0,1), ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, Vector3.zero, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input,0, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, 0, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, 0, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 0, ShaderStage.Fragment));
// clear out slot names that do not match the slots
// we support

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightSpecularMasterNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, new Vector4(0.5f, 0.5f, 0.5f, 0.5f), ShaderStage.Fragment));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, new Vector4(0,0,1), ShaderStage.Fragment));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(SpecularSlotId, SpecularSlotName, SpecularSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.one, ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, new Vector3(0.5f, 0.5f, 0.5f), ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, new Vector3(0,0,1), ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, Vector3.zero, ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(SpecularSlotId, SpecularSlotName, SpecularSlotName, SlotType.Input, Vector3.zero, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, 0, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input,0, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 1, ShaderStage.Fragment));
// clear out slot names that do not match the slots
// we support

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightUnlitMasterNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(ColorSlotId, ColorSlotName, ColorSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(ColorSlotId, ColorSlotName, ColorSlotName, SlotType.Input, Vector3.zero, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 0, ShaderStage.Fragment));
// clear out slot names that do not match the slots
// we support

163
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs


get { return true; }
}
public virtual bool allowedInMainGraph
{
get { return true; }
}
public virtual bool allowedInLayerGraph
{
get { return true; }
}
public override bool hasError
{
get { return m_HasError; }

return inputSlot.GetDefaultValue(generationMode);
}
private ConcreteSlotValueType FindCommonChannelType(ConcreteSlotValueType from, ConcreteSlotValueType to)
{
if (ImplicitConversionExists(from, to))
return to;
return ConcreteSlotValueType.Error;
}
private static ConcreteSlotValueType ToConcreteType(SlotValueType svt)
{
switch (svt)
{
case SlotValueType.Vector1:
return ConcreteSlotValueType.Vector1;
case SlotValueType.Vector2:
return ConcreteSlotValueType.Vector2;
case SlotValueType.Vector3:
return ConcreteSlotValueType.Vector3;
case SlotValueType.Vector4:
return ConcreteSlotValueType.Vector4;
case SlotValueType.Texture2D:
return ConcreteSlotValueType.Texture2D;
case SlotValueType.Matrix2:
return ConcreteSlotValueType.Matrix2;
case SlotValueType.Matrix3:
return ConcreteSlotValueType.Matrix3;
case SlotValueType.Matrix4:
return ConcreteSlotValueType.Matrix4;
case SlotValueType.SamplerState:
return ConcreteSlotValueType.SamplerState;
}
return ConcreteSlotValueType.Error;
}
private static bool ImplicitConversionExists(ConcreteSlotValueType from, ConcreteSlotValueType to)
{
if (from == to)

private ConcreteSlotValueType ConvertDynamicInputTypeToConcrete(IEnumerable<ConcreteSlotValueType> inputTypes)
{
var concreteSlotValueTypes = inputTypes as IList<ConcreteSlotValueType> ?? inputTypes.ToList();
if (concreteSlotValueTypes.Any(x => x == ConcreteSlotValueType.Error))
return ConcreteSlotValueType.Error;
var inputTypesDistinct = concreteSlotValueTypes.Distinct().ToList();
switch (inputTypesDistinct.Count)
{

return ordered.FirstOrDefault();
break;
}
return ConcreteSlotValueType.Error;
return ConcreteSlotValueType.Vector1;
var isInError = false;
var isInError = false;
inputSlot.hasError = false;
foreach (var edge in edges)
foreach (var edge in edges)
{
var fromSocketRef = edge.outputSlot;
var outputNode = owner.GetNodeFromGuid(fromSocketRef.nodeGuid);

}
}
var dynamicInputSlotsToCompare = DictionaryPool<MaterialSlot, ConcreteSlotValueType>.Get();
var skippedDynamicSlots = ListPool<MaterialSlot>.Get();
var dynamicInputSlotsToCompare = DictionaryPool<DynamicVectorMaterialSlot, ConcreteSlotValueType>.Get();
var skippedDynamicSlots = ListPool<DynamicVectorMaterialSlot>.Get();
var inputType = inputSlot.valueType;
if (inputType != SlotValueType.Dynamic)
inputSlot.concreteValueType = ToConcreteType(inputType);
else
skippedDynamicSlots.Add(inputSlot);
if (inputSlot is DynamicVectorMaterialSlot)
skippedDynamicSlots.Add(inputSlot as DynamicVectorMaterialSlot);
continue;
}

if (outputSlot == null)
continue;
var outputConcreteType = outputSlot.concreteValueType;
// if we have a standard connection... just check the types work!
if (inputType != SlotValueType.Dynamic)
if (outputSlot.hasError)
var inputConcreteType = ToConcreteType(inputType);
inputSlot.concreteValueType = FindCommonChannelType(outputConcreteType, inputConcreteType);
inputSlot.hasError = true;
var outputConcreteType = outputSlot.concreteValueType;
dynamicInputSlotsToCompare.Add(inputSlot, outputConcreteType);
if (inputSlot is DynamicVectorMaterialSlot)
{
dynamicInputSlotsToCompare.Add((DynamicVectorMaterialSlot) inputSlot, outputConcreteType);
continue;
}
// if we have a standard connection... just check the types work!
if (!ImplicitConversionExists(outputConcreteType, inputSlot.concreteValueType))
inputSlot.hasError = true;
}
// we can now figure out the dynamic slotType

dynamicKvP.Key.concreteValueType = dynamicType;
dynamicKvP.Key.SetConcreteType(dynamicType);
skippedSlot.concreteValueType = dynamicType;
skippedSlot.SetConcreteType(dynamicType);
var inputError = GetInputSlots<MaterialSlot>().Any(x => x.concreteValueType == ConcreteSlotValueType.Error);
var inputError = GetInputSlots<MaterialSlot>().Any(x => x.hasError);
// configure the output slots now
// their slotType will either be the default output slotType

{
outputSlot.hasError = false;
outputSlot.concreteValueType = ConcreteSlotValueType.Error;
outputSlot.hasError = true;
if (outputSlot.valueType == SlotValueType.Dynamic)
if (outputSlot is DynamicVectorMaterialSlot)
outputSlot.concreteValueType = dynamicType;
(outputSlot as DynamicVectorMaterialSlot).SetConcreteType(dynamicType);
outputSlot.concreteValueType = ToConcreteType(outputSlot.valueType);
isInError |= GetOutputSlots<MaterialSlot>().Any(x => x.concreteValueType == ConcreteSlotValueType.Error);
isInError |= GetOutputSlots<MaterialSlot>().Any(x => x.hasError);
isInError |= CalculateNodeHasError();
hasError = isInError;

}
ListPool<MaterialSlot>.Release(skippedDynamicSlots);
DictionaryPool<MaterialSlot, ConcreteSlotValueType>.Release(dynamicInputSlotsToCompare);
ListPool<DynamicVectorMaterialSlot>.Release(skippedDynamicSlots);
DictionaryPool<DynamicVectorMaterialSlot, ConcreteSlotValueType>.Release(dynamicInputSlotsToCompare);
}

}
}
public static PropertyType ConvertConcreteSlotValueTypeToPropertyType(ConcreteSlotValueType slotValue)
{
switch (slotValue)
{
case ConcreteSlotValueType.Texture2D:
return PropertyType.Texture;
case ConcreteSlotValueType.Vector1:
return PropertyType.Float;
case ConcreteSlotValueType.Vector2:
return PropertyType.Vector2;
case ConcreteSlotValueType.Vector3:
return PropertyType.Vector3;
case ConcreteSlotValueType.Vector4:
return PropertyType.Vector4;
case ConcreteSlotValueType.Matrix2:
return PropertyType.Matrix2;
case ConcreteSlotValueType.Matrix3:
return PropertyType.Matrix3;
case ConcreteSlotValueType.Matrix4:
return PropertyType.Matrix4;
case ConcreteSlotValueType.SamplerState:
return PropertyType.SamplerState;
default:
return PropertyType.Vector4;
}
}
public virtual void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
var validSlots = GetInputSlots<MaterialSlot>().ToArray();

if (edges.Any())
continue;
var pp = new PreviewProperty
{
m_Name = GetVariableNameForSlot(s.id),
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(s.concreteValueType),
m_Vector4 = s.currentValue,
m_Float = s.currentValue.x,
m_Color = s.currentValue
};
properties.Add(pp);
var item = s.GetPreviewProperty(GetVariableNameForSlot(s.id));
if (item == null)
continue;
properties.Add(item);
}
}

if (foundSlot == null)
return;
// preserve the old current value.
addingSlot.currentValue = foundSlot.currentValue;
// now copy over values :)
if (addingSlot is DynamicVectorMaterialSlot && foundSlot is DynamicVectorMaterialSlot)
(addingSlot as DynamicVectorMaterialSlot).value = (foundSlot as DynamicVectorMaterialSlot).value;
if (addingSlot is Vector1MaterialSlot && foundSlot is Vector1MaterialSlot)
(addingSlot as Vector1MaterialSlot).value = (foundSlot as Vector1MaterialSlot).value;
if (addingSlot is Vector2MaterialSlot && foundSlot is Vector2MaterialSlot)
(addingSlot as Vector2MaterialSlot).value = (foundSlot as Vector2MaterialSlot).value;
if (addingSlot is Vector3MaterialSlot && foundSlot is Vector3MaterialSlot)
(addingSlot as Vector3MaterialSlot).value = (foundSlot as Vector3MaterialSlot).value;
if (addingSlot is Vector4MaterialSlot && foundSlot is Vector4MaterialSlot)
(addingSlot as Vector4MaterialSlot).value = (foundSlot as Vector4MaterialSlot).value;
}
}
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Channel/SplitNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRId, kOutputSlotRName, kOutputSlotRName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector4.zero));
AddSlot(new Vector1MaterialSlot(OutputSlotRId, kOutputSlotRName, kOutputSlotRName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, 0));
RemoveSlotsNameNotMatching(s_ValidSlots);
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/HLSLNode.cs


{
var attribute = GetSlotAttribute(par);
slots.Add(new MaterialSlot(attribute.slotId, par.Name, par.Name, par.IsOut ? SlotType.Output : SlotType.Input,
ConvertTypeToSlotValueType(par), attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden));
slots.Add(MaterialSlot.CreateMaterialSlot(ConvertTypeToSlotValueType(par), attribute.slotId, par.Name, par.Name, par.IsOut ? SlotType.Output : SlotType.Input,
attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden));
m_Slots.Add(attribute);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/ColorNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector3, new Vector4(0, 0, 1, 1)));
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1)));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector3, new Vector4(0, 0, 1, 1)));
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1)));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero, ShaderStage.Vertex));
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero, ShaderStage.Vertex));
RemoveSlotsNameNotMatching(validSlots);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs


public override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector2MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector2.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.one));
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.one));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(
AddSlot(new Vector3MaterialSlot(
SlotValueType.Vector3,
Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(
AddSlot(new Vector3MaterialSlot(
SlotValueType.Vector3,
Vector4.zero));
Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector3, new Vector4(0, 0, 1, 1)));
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1, 1)));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs


}
void SetRow(ref Vector2 row, Vector2 value)
{
{
return;
return;
if (onModified != null)
if (onModified != null)
onModified(this, ModificationScope.Graph);
}

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix2, Vector2.zero));
AddSlot(new Matrix2MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs


[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row1
{
{
get { return m_Row1; }
set { SetRow(ref m_Row1, value); }
}

if (value == row)
return;
row = value;
if (onModified != null)
if (onModified != null)
onModified(this, ModificationScope.Graph);
}

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector3.zero));
AddSlot(new Matrix3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero));
AddSlot(new Matrix4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero));
AddSlot(new Matrix4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/CameraDirNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/CameraPosNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/ScreenPosNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(kOutputSlot2Id, kOutputSlot2Name, kOutputSlot2Name, SlotType.Output, SlotValueType.Vector3, Vector3.zero));
AddSlot(new Vector4MaterialSlot(kOutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(kOutputSlot2Id, kOutputSlot2Name, kOutputSlot2Name, SlotType.Output, Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlot1Id, kOutputSlot2Id });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/SinTimeNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.one));
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.one));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/TimeNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdX, kOutputSlotNameX, kOutputSlotNameX, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
AddSlot(new Vector1MaterialSlot(OutputSlotIdX, kOutputSlotNameX, kOutputSlotNameX, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, 0));
RemoveSlotsNameNotMatching(validSlots);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector1Node.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output,0));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector2Node.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector2, Vector4.zero));
AddSlot(new Vector2MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector3Node.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector4Node.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs


protected MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
return new Matrix4MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input);
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector4, Vector4.zero);
return new Vector4MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, Vector4.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector4, Vector4.zero);
return new Vector4MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, Vector4.zero);
}
protected virtual string GetInputSlot1Name()

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixMultiplyNode.cs


protected MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
return new Matrix4MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input);
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
return new Matrix4MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero);
return new Matrix4MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output);
}
protected virtual string GetInputSlot1Name()

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Property Node")]
public class PropertyNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
public class PropertyNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV, IOnAssetEnabled
{
private Guid m_PropertyGuid;

if (property is FloatShaderProperty)
{
AddSlot(new MaterialSlot(OutputSlotId, "float", "float", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector1MaterialSlot(OutputSlotId, "float", "float", SlotType.Output, 0));
AddSlot(new MaterialSlot(OutputSlotId, "V2", "V2", SlotType.Output, SlotValueType.Vector2, Vector4.zero));
AddSlot(new Vector2MaterialSlot(OutputSlotId, "V2", "V2", SlotType.Output, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotId, "V3", "V3", SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new Vector3MaterialSlot(OutputSlotId, "V3", "V3", SlotType.Output, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotId, "V4", "V4", SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, "V4", "V4", SlotType.Output, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotId, "Color", "Color", SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, "Color", "Color", SlotType.Output, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotId, "RGBA", "RGBA", SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(ROutputSlotId, "R", "R", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(GOutputSlotId, "G", "G", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(BOutputSlotId, "B", "B", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AOutputSlotId, "A", "A", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TOutputSlotId, "T", "T", SlotType.Output, SlotValueType.Texture2D, Vector4.zero));
AddSlot(new MaterialSlot(UVInput, "UV", "UV", SlotType.Input, SlotValueType.Vector2, Vector4.zero));
RemoveSlotsNameNotMatching(new[] {OutputSlotId, ROutputSlotId, GOutputSlotId, BOutputSlotId, AOutputSlotId, TOutputSlotId,UVInput});
AddSlot(new Vector4MaterialSlot(OutputSlotId, "RGBA", "RGBA", SlotType.Output, Vector4.zero));
AddSlot(new Vector1MaterialSlot(ROutputSlotId, "R", "R", SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(GOutputSlotId, "G", "G", SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(BOutputSlotId, "B", "B", SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(AOutputSlotId, "A", "A", SlotType.Output, 0));
AddSlot(new Texture2DMaterialSlot(TOutputSlotId, "T", "T", SlotType.Output));
AddSlot(new Vector2MaterialSlot(UVInput, "UV", "UV", SlotType.Input, Vector4.zero));
RemoveSlotsNameNotMatching(new[] {OutputSlotId, ROutputSlotId, GOutputSlotId, BOutputSlotId, AOutputSlotId, TOutputSlotId, UVInput});
}
}

}
}
public sealed override void UpdateNodeAfterDeserialization()
{
base.UpdateNodeAfterDeserialization();
}
public override string GetVariableNameForSlot(int slotId)
{
if (slotId != TOutputSlotId)

base.OnAfterDeserialize();
if (!string.IsNullOrEmpty(m_PropertyGuidSerialized))
m_PropertyGuid = new Guid(m_PropertyGuidSerialized);
}
public void OnEnable()
{
UpdateNode();
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs


Vector4,
Vector3,
Vector2,
Vector1,
Error
Vector1
}
public static class SlotValueHelper

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VertexInterpolatorNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(InputSlotId, k_InputSlotName, k_InputSlotName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero, ShaderStage.Vertex));
AddSlot(new MaterialSlot(OutputSlotId, k_OutputSlotName, k_OutputSlotName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero, ShaderStage.Fragment));
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, k_InputSlotName, k_InputSlotName, SlotType.Input, Vector4.zero, ShaderStage.Vertex));
AddSlot(new DynamicVectorMaterialSlot(OutputSlotId, k_OutputSlotName, k_OutputSlotName, SlotType.Output, Vector4.zero, ShaderStage.Fragment));
RemoveSlotsNameNotMatching(k_ValidSlots);
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph.meta


fileFormatVersion: 2
guid: 7e981d45b83422d4aa5407e9fe5c7ab5
guid: 605eb5c5a280c014fa0952cd022f2579
timeCreated: 1465559218
licenseType: Pro
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphNode.cs


{
public abstract class AbstractSubGraphNode : AbstractMaterialNode
, IGeneratesFunction
, IOnAssetEnabled
, IMayRequireNormal
, IMayRequireTangent
, IMayRequireBitangent

get { return null; }
}
public virtual void OnEnable()
public virtual void UpdateSlots()
{
var validNames = new List<int>();
if (referencedGraph == null)

}
var id = prop.guid.GetHashCode();
AddSlot(new MaterialSlot(id, prop.displayName, prop.referenceName, SlotType.Input, slotType, prop.defaultValue));
AddSlot(MaterialSlot.CreateMaterialSlot(slotType, id, prop.displayName, prop.referenceName, SlotType.Input, prop.defaultValue));
validNames.Add(id);
}

foreach (var slot in subGraphOutputNode.GetInputSlots<MaterialSlot>())
{
AddSlot(new MaterialSlot(slot.id, slot.displayName, slot.shaderOutputName, SlotType.Output, slot.valueType, slot.defaultValue));
AddSlot(MaterialSlot.CreateMaterialSlot( slot.valueType,slot.id, slot.displayName, slot.shaderOutputName, SlotType.Output, Vector4.zero));
validNames.Add(slot.id);
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs


var helper = new RemapGraphHelper();
helper.remapGraph = value;
m_SerializedRemapGraph = EditorJsonUtility.ToJson(helper, true);
OnEnable();
UpdateSlots();
if (onModified != null)
onModified(this, ModificationScope.Topological);

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphNode.cs


var helper = new SubGraphHelper();
helper.subGraph = value;
m_SerializedSubGraph = EditorJsonUtility.ToJson(helper, true);
OnEnable();
UpdateSlots();
if (onModified != null)
onModified(this, ModificationScope.Topological);

}
else if (inSlot.concreteValueType == ConcreteSlotValueType.Texture2D)
{
prop.overrideReferenceName = MaterialSlot.DefaultTextureName;
prop.overrideReferenceName = Texture2DMaterialSlot.DefaultTextureName;
}
else
{

47
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs


using System;
using System.Reflection;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Experimental.UIElements;
public class SubGraphOutputNode : AbstractSubGraphIONode
public class SubGraphOutputNode : AbstractMaterialNode
{
public SubGraphOutputNode()
{

[SubGraphOutputControl]
int controlDummy { get; set; }
public override int AddSlot()
public virtual int AddSlot()
AddSlot(new MaterialSlot(index, "Output " + index, "Output" + index, SlotType.Input, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector4MaterialSlot(index, "Output " + index, "Output" + index, SlotType.Input, Vector4.zero));
public override void RemoveSlot()
public virtual void RemoveSlot()
{
var index = GetInputSlots<ISlot>().Count();
if (index == 0)

}
public override bool allowedInRemapGraph { get { return false; } }
}
public class SubGraphOutputControlAttribute : Attribute, IControlAttribute
{
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
if (!(node is AbstractSubGraphIONode))
throw new ArgumentException("Node must inherit from AbstractSubGraphIONode.", "node");
return new SubGraphOutputControlView((AbstractSubGraphIONode)node);
}
}
public class SubGraphOutputControlView : VisualElement
{
AbstractSubGraphIONode m_Node;
public SubGraphOutputControlView(AbstractSubGraphIONode node)
{
m_Node = node;
Add(new Button(OnAdd) { text = "Add Slot" });
Add(new Button(OnRemove) { text = "Remove Slot" });
}
void OnAdd()
{
m_Node.AddSlot();
}
void OnRemove()
{
m_Node.RemoveSlot();
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs.meta


fileFormatVersion: 2
guid: ec0207b061e270b4a96a01fbe11c18ca
timeCreated: 1465559219
licenseType: Pro
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

18
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing

}
public class MasterReampGraphEditWindow : AbstractMaterialGraphEditWindow<MasterRemapGraph>
{
public override AbstractMaterialGraph GetMaterialGraph()
{
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}
public class LayeredGraphEditWindow : AbstractMaterialGraphEditWindow<LayeredShaderGraph>
{
public override AbstractMaterialGraph GetMaterialGraph()
{

{
get { return m_GraphObject; }
set
{
{
if (m_GraphObject != null)
DestroyImmediate(m_GraphObject);
m_GraphObject = value;

}
if (typeof(TGraphType) == typeof(UnityEngine.MaterialGraph.MaterialGraph))
UpdateShaderGraphOnDisk(path);
if (typeof(TGraphType) == typeof(LayeredShaderGraph))
UpdateShaderGraphOnDisk(path);
if (typeof(TGraphType) == typeof(SubGraph))

break;
case ConcreteSlotValueType.Vector1:
break;
case ConcreteSlotValueType.Error:
break;
default:
throw new ArgumentOutOfRangeException();
}

private void UpdateShaderGraphOnDisk(string path)
{
var graph = graphObject.graph as UnityEngine.MaterialGraph.MaterialGraph;
var graph = graphObject.graph as IShaderGraph;
if (graph == null)
return;

68
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


using UnityEditor.Graphing.Util;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.Graphing;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector

VisualElement m_Title;
VisualElement m_PropertyItems;
VisualElement m_LayerItems;
VisualElement m_ContentContainer;
AbstractNodeEditorView m_EditorView;

}
bottomContainer.Add(propertiesContainer);
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture };
//if (m_Presenter.graph is LayeredShaderGraph)
{
var layersContainer = new VisualElement {name = "properties"};
{
var header = new VisualElement {name = "header"};
{
var title = new VisualElement {name = "title", text = "Layers"};
header.Add(title);
var addLayerButton = new Button(OnAddLayer) {text = "Add", name = "addButton"};
header.Add(addLayerButton);
}
propertiesContainer.Add(header);
m_LayerItems = new VisualContainer {name = "items"};
propertiesContainer.Add(m_LayerItems);
}
bottomContainer.Add(layersContainer);
}
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture};
bottomContainer.Add(m_Preview);
}
Add(bottomContainer);

// - SubGraphOutputNode
m_TypeMapper = new TypeMapper(typeof(INode), typeof(AbstractNodeEditorView), typeof(StandardNodeEditorView))
{
// { typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) }
// { typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) }
};
}

gm.AddItem(new GUIContent("Vector4"), false, () => AddProperty(new Vector4ShaderProperty()));
gm.AddItem(new GUIContent("Color"), false, () => AddProperty(new ColorShaderProperty()));
gm.AddItem(new GUIContent("Texture"), false, () => AddProperty(new TextureShaderProperty()));
gm.ShowAsContext();
}
gm.ShowAsContext();
}
}
void OnAddLayer()
{
var layerGraph = m_Presenter.graph as LayeredShaderGraph;
if (layerGraph == null)
return;
layerGraph.AddLayer();
}
public void OnChange(GraphInspectorPresenter.ChangeType changeType)

{
m_Graph.onChange -= OnGraphChange;
m_PropertyItems.Clear();
m_LayerItems.Clear();
m_Graph = null;
}
if (m_Presenter.graph != null)

m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));
var layerGraph = m_Presenter.graph as LayeredShaderGraph;
if (layerGraph != null)
foreach (var layer in layerGraph.layers)
m_LayerItems.Add(new ShaderLayerView(layerGraph, layer));
}
}
}
void OnGraphChange(GraphChange change)

var propertyView = m_PropertyItems.OfType<ShaderPropertyView>().FirstOrDefault(v => v.property.guid == propertyRemoved.guid);
if (propertyView != null)
m_PropertyItems.Remove(propertyView);
}
var layerGraph = m_Graph as LayeredShaderGraph;
if (layerGraph == null)
return;
var layerAdded = change as LayerAdded;
if (layerAdded != null)
m_LayerItems.Add(new ShaderLayerView(layerGraph, layerAdded.layer));
var layerRemoved = change as LayerRemoved;
if (layerRemoved != null)
{
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == layerRemoved.id);
if (view != null)
m_LayerItems.Remove(view);
}
}

56
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/IMGUISlotEditorView.cs


using System;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;

return;
var previousWideMode = EditorGUIUtility.wideMode;
EditorGUIUtility.wideMode = true;
var newValue = SlotField(m_Slot);
if (newValue != m_Slot.currentValue)
{
m_Slot.currentValue = newValue;
m_Slot.owner.onModified(m_Slot.owner, ModificationScope.Node);
}
var modified = SlotField(m_Slot);
if (modified)
m_Slot.owner.onModified(m_Slot.owner, ModificationScope.Node);
static Vector4 SlotField(MaterialSlot slot)
public static bool SlotField(MaterialSlot slot)
if (slot.concreteValueType == ConcreteSlotValueType.Vector1)
return new Vector4(EditorGUILayout.FloatField(slot.displayName, slot.currentValue.x), 0, 0, 0);
if (slot.concreteValueType == ConcreteSlotValueType.Vector2)
return EditorGUILayout.Vector2Field(slot.displayName, slot.currentValue);
if (slot.concreteValueType == ConcreteSlotValueType.Vector3)
return EditorGUILayout.Vector3Field(slot.displayName, slot.currentValue);
if (slot.concreteValueType == ConcreteSlotValueType.Vector4)
return EditorGUILayout.Vector4Field(slot.displayName, slot.currentValue);
return Vector4.zero;
EditorGUI.BeginChangeCheck();
if (slot is DynamicVectorMaterialSlot)
{
var dynSlot = slot as DynamicVectorMaterialSlot;
dynSlot.value = EditorGUILayout.Vector4Field(slot.displayName, dynSlot.value);
}
if (slot is Vector1MaterialSlot)
{
var dynSlot = slot as Vector1MaterialSlot;
dynSlot.value = EditorGUILayout.FloatField(slot.displayName, dynSlot.value);
}
if (slot is Vector2MaterialSlot)
{
var dynSlot = slot as Vector2MaterialSlot;
dynSlot.value = EditorGUILayout.Vector2Field(slot.displayName, dynSlot.value);
}
if (slot is Vector3MaterialSlot)
{
var dynSlot = slot as Vector3MaterialSlot;
dynSlot.value = EditorGUILayout.Vector3Field(slot.displayName, dynSlot.value);
}
if (slot is Vector4MaterialSlot)
{
var dynSlot = slot as Vector4MaterialSlot;
dynSlot.value = EditorGUILayout.Vector4Field(slot.displayName, dynSlot.value);
}
return EditorGUI.EndChangeCheck();
}
}
}

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/BasicNodeInspector.cs


using System.Linq;
using UnityEditor.MaterialGraph.Drawing.Inspector;
using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;

if (!slots.Any())
return ModificationScope.Nothing;
EditorGUI.BeginChangeCheck();
var modified = false;
slot.currentValue = EditorGUILayout.Vector4Field(slot.displayName, slot.currentValue);
modified |= IMGUISlotEditorView.SlotField(slot);
return EditorGUI.EndChangeCheck() ? ModificationScope.Node : ModificationScope.Nothing;
return modified ? ModificationScope.Node : ModificationScope.Nothing;
}
}
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphOutputNodeInspector.cs


{
EditorGUI.BeginChangeCheck();
var result = (UISlotValueType)EditorGUILayout.EnumPopup(ToUISlot(slot.valueType));
slot.valueType = ToSlotValueType(result);
var chantedTo = ToSlotValueType(result);
{
MaterialSlot.CreateMaterialSlot(chantedTo, slot.id, slot.RawDisplayName(), slot.shaderOutputName, slot.slotType, Vector4.zero);
}
}
GUILayout.Space(10);

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


if (startSlot == null)
return compatibleAnchors;
var goingBackwards = startSlot.isOutputSlot;
var startStage = startSlot.shaderStage;
if (startStage == ShaderStage.Dynamic)
startStage = NodeUtils.FindEffectiveShaderStage(startSlot.owner, startSlot.isOutputSlot);

continue;
if (candidateSlot.owner == startSlot.owner)
continue;
if (!startSlot.IsCompatibleWithInputSlotType(candidateSlot.valueType))
if (!startSlot.IsCompatibleWithInputSlotType(candidateSlot.concreteValueType))
continue;
if (startStage != ShaderStage.Dynamic)

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/MasterRemapGraphImporterEditor.cs


using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.MaterialGraph.Drawing;
using UnityEngine;

window.Show();
window.ChangeSelection(asset);
}
}
[OnOpenAsset]
static bool OnOpenAsset(int instanceID, int line)
{
var path = AssetDatabase.GetAssetPath(instanceID);
ShowGraphEditWindow(path);
return true;
}
}

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs


using System.IO;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
using UnityEngine.Events;
class ShaderGraphTextGenerator : ICustomShaderImporter
class ShaderGraphImporter : ICustomShaderImporter
public string GetShaderText(string path)
private static string GetShaderText<T>(string path) where T : IShaderGraph
var graph = JsonUtility.FromJson<MaterialGraph>(textGraph);
var graph = JsonUtility.FromJson<T>(textGraph);
var name = Path.GetFileNameWithoutExtension(path);

return null;
}
public string GetShaderText(string path)
{
if (path.EndsWith("LayeredShaderGraph", StringComparison.InvariantCultureIgnoreCase))
return GetShaderText<LayeredShaderGraph>(path);
if (path.EndsWith("shaderGraph", StringComparison.InvariantCultureIgnoreCase))
return GetShaderText<MaterialGraph>(path);
return null;
}
try
{
var textGraph = File.ReadAllText(path, Encoding.UTF8);
var graph = JsonUtility.FromJson<MaterialGraph>(textGraph);
return graph != null;
}
catch (Exception)
{
// ignored
}
return false;
return
path.EndsWith("LayeredShaderGraph", StringComparison.InvariantCultureIgnoreCase)
|| path.EndsWith("shaderGraph", StringComparison.InvariantCultureIgnoreCase);
}
public void OpenAsset(string path)

private static void ShowGraphEditWindow(string path)
internal static void ShowGraphEditWindow(string path)
{
var asset = AssetDatabase.LoadAssetAtPath<Object>(path);
var extension = Path.GetExtension(path);

else if (extension == ".LayeredShaderGraph")
windowType = typeof(LayeredGraphEditWindow);
else if (extension == ".ShaderRemapGraph")
windowType = typeof(MasterRemapGraph);
var windows = Resources.FindObjectsOfTypeAll(windowType);
bool foundWindow = false;
foreach (var w in windows.OfType<IMaterialGraphEditWindow>())

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporterEditor.cs


using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.MaterialGraph.Drawing;
using UnityEngine;

}
}
private static void ShowGraphEditWindow(string path)
private static bool ShowGraphEditWindow(string path)
if (asset == null)
return false;
var windows = Resources.FindObjectsOfTypeAll<SubGraphEditWindow>();
bool foundWindow = false;
foreach (var w in windows)

window.Show();
window.ChangeSelection(asset);
}
return true;
}
[OnOpenAsset]
static bool OnOpenAsset(int instanceID, int line)
{
var path = AssetDatabase.GetAssetPath(instanceID);
ShowGraphEditWindow(path);
return true;
}
}

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/DynamicSlotTests.cs


public DynamicNode()
{
AddSlot(new MaterialSlot(DynIn1, "DynIn1", "DynIn1", SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(DynIn2, "DynIn2", "DynIn2", SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(DynOut, "DynOut", "DynOut", SlotType.Output, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new DynamicVectorMaterialSlot(DynIn1, "DynIn1", "DynIn1", SlotType.Input, Vector4.zero));
AddSlot(new DynamicVectorMaterialSlot(DynIn2, "DynIn2", "DynIn2", SlotType.Input, Vector4.zero));
AddSlot(new DynamicVectorMaterialSlot(DynOut, "DynOut", "DynOut", SlotType.Output, Vector4.zero));
}
}

public TestNode()
{
AddSlot(new MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(V2Out, "V2Out", "V2Out", SlotType.Output, SlotValueType.Vector2, Vector4.zero));
AddSlot(new MaterialSlot(V3Out, "V3Out", "V3Out", SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(V4Out, "V4Out", "V4Out", SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector1MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, 0));
AddSlot(new Vector2MaterialSlot(V2Out, "V2Out", "V2Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(V3Out, "V3Out", "V3Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(V4Out, "V4Out", "V4Out", SlotType.Output, Vector4.zero));
}
}

16
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/FixedSlotTests.cs


public TestNode()
{
AddSlot(new MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(V2Out, "V2Out", "V2Out", SlotType.Output, SlotValueType.Vector2, Vector4.zero));
AddSlot(new MaterialSlot(V3Out, "V3Out", "V3Out", SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(V4Out, "V4Out", "V4Out", SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector1MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, 0));
AddSlot(new Vector2MaterialSlot(V2Out, "V2Out", "V2Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(V3Out, "V3Out", "V3Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(V4Out, "V4Out", "V4Out", SlotType.Output, Vector4.zero));
AddSlot(new MaterialSlot(V1In, "V1In", "V1In", SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(V2In, "V2In", "V2In", SlotType.Input, SlotValueType.Vector2, Vector4.zero));
AddSlot(new MaterialSlot(V3In, "V3In", "V3In", SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(V4In, "V4In", "V4In", SlotType.Input, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector1MaterialSlot(V1In, "V1In", "V1In", SlotType.Input, 0));
AddSlot(new Vector2MaterialSlot(V2In, "V2In", "V2In", SlotType.Input, Vector4.zero));
AddSlot(new Vector3MaterialSlot(V3In, "V3In", "V3In", SlotType.Input, Vector4.zero));
AddSlot(new Vector4MaterialSlot(V4In, "V4In", "V4In", SlotType.Input, Vector4.zero));
}
}

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs


public TestNode()
{
AddSlot(new MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(V1In, "V1In", "V1In", SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector1MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(V1In, "V1In", "V1In", SlotType.Input, 0));
}
}

[Test]
public void ReplacingMaterialSlotPreservesTheOldCurrentValue()
{
m_NodeA.AddSlot(new MaterialSlot(TestNode.V1In, "V1In", "V1In", SlotType.Input, SlotValueType.Vector1, Vector4.one));
m_NodeA.AddSlot(new Vector1MaterialSlot(TestNode.V1In, "V1In", "V1In", SlotType.Input, 0));
var slot = m_NodeA.GetInputSlots<MaterialSlot>().FirstOrDefault();
var slot = m_NodeA.GetInputSlots<Vector1MaterialSlot>().FirstOrDefault();
Assert.AreEqual(Vector4.zero, slot.currentValue);
Assert.AreEqual(Vector4.zero, slot.value);
}
[Test]

Assert.AreEqual("3x3", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(ConcreteSlotValueType.Matrix3));
Assert.AreEqual("4x4", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(ConcreteSlotValueType.Matrix4));
Assert.AreEqual("SamplerState", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(ConcreteSlotValueType.SamplerState));
Assert.AreEqual("Error", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(ConcreteSlotValueType.Error));
}
[Test]

m_NodeA.CollectPreviewMaterialProperties(properties);
var slot = m_NodeA.GetInputSlots<MaterialSlot>().FirstOrDefault();
var slot = m_NodeA.GetInputSlots<Vector1MaterialSlot>().FirstOrDefault();
Assert.AreEqual(1, properties.Count);
var pp = properties.FirstOrDefault();

Assert.AreEqual(slot.currentValue, pp.m_Vector4);
Assert.AreEqual(slot.value, pp.m_Vector4);
}
[Test]

90
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialSlotTests.cs


using System;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Graphing;

class TestNode : AbstractMaterialNode
{
public const int V1In = 1;
public const int V2In = 2;
public const int V3In = 3;
public const int V4In = 4;
public readonly MaterialSlot slot;
public readonly Vector1MaterialSlot slot1;
public readonly Vector2MaterialSlot slot2;
public readonly Vector3MaterialSlot slot3;
public readonly Vector4MaterialSlot slot4;
slot = new MaterialSlot(V1In, "V1In", "V1In", SlotType.Input, SlotValueType.Vector1, Vector4.zero);
AddSlot(slot);
slot1 = new Vector1MaterialSlot(V1In, "V1In", "V1In", SlotType.Input, 0);
AddSlot(slot1);
slot2 = new Vector2MaterialSlot(V2In, "V2In", "V2In", SlotType.Input, Vector2.zero);
AddSlot(slot2);
slot3 = new Vector3MaterialSlot(V3In, "V3In", "V3In", SlotType.Input, Vector3.zero);
AddSlot(slot3);
slot4 = new Vector4MaterialSlot(V4In, "V4In", "V4In", SlotType.Input, Vector4.zero);
AddSlot(slot4);
}
}

}
[Test]
public void CanUpdateMaterialSlotDisplayName()
public void SlotDisplayNameIsCorrect()
var slot = m_NodeA.slot;
slot.displayName = displayName;
slot.valueType = SlotValueType.Vector1;
Assert.AreEqual(displayName + "(1)", slot.displayName);
slot.valueType = SlotValueType.Vector2;
Assert.AreEqual(displayName + "(2)", slot.displayName);
var slot = m_NodeA.slot1;
Assert.AreEqual(displayName + "(1)", m_NodeA.slot1.displayName);
slot.valueType = SlotValueType.Vector3;
Assert.AreEqual(displayName + "(3)", slot.displayName);
Assert.AreEqual(displayName + "(2)", m_NodeA.slot2.displayName);
slot.valueType = SlotValueType.Vector4;
Assert.AreEqual(displayName + "(4)", slot.displayName);
Assert.AreEqual(displayName + "(3)", m_NodeA.slot3.displayName);
slot.valueType = SlotValueType.Dynamic;
Assert.AreEqual(displayName + "(4)", slot.displayName);
Assert.AreEqual(displayName + "(4)", m_NodeA.slot4.displayName);
var slot = m_NodeA.slot;
slot.defaultValue = Vector4.one;
var slot = m_NodeA.slot1;
slot.value = 1;
Assert.AreEqual(Vector4.one, slot.defaultValue);
}

var slot = m_NodeA.slot;
slot.currentValue = Vector4.one;
Assert.AreEqual(Vector4.one, slot.currentValue);
}
[Test]
public void CanUpdateMaterialSlotValueType()
{
var slot = m_NodeA.slot;
slot.valueType = SlotValueType.Vector3;
Assert.AreEqual(SlotValueType.Vector3, slot.valueType);
var slot = m_NodeA.slot1;
slot.value = 1;
Assert.AreEqual(Vector4.one, 1);
}
/* [Test]

public void MaterialSlotReturnsValidDefaultValue()
{
string expected = string.Format("{0}", m_NodeA.GetVariableNameForSlot(TestNode.V1In));
var slot = m_NodeA.slot;
var result = slot.GetDefaultValue(GenerationMode.Preview);
var result = m_NodeA.slot1.GetDefaultValue(GenerationMode.Preview);
slot.valueType = SlotValueType.Vector1;
slot.currentValue = new Vector4(6, 6, 6, 1);
result = slot.GetDefaultValue(GenerationMode.ForReals);
m_NodeA.slot1.value = 6;
result = m_NodeA.slot1.GetDefaultValue(GenerationMode.ForReals);
slot.valueType = SlotValueType.Vector2;
slot.currentValue = new Vector4(6, 6, 6, 1);
result = slot.GetDefaultValue(GenerationMode.ForReals);
m_NodeA.slot2.value = new Vector4(6, 6, 6, 1);
result = m_NodeA.slot1.GetDefaultValue(GenerationMode.ForReals);
slot.valueType = SlotValueType.Vector3;
slot.currentValue = new Vector4(6, 6, 6, 1);
result = slot.GetDefaultValue(GenerationMode.ForReals);
m_NodeA.slot3.value = new Vector4(6, 6, 6, 1);
result = m_NodeA.slot3.GetDefaultValue(GenerationMode.ForReals);
slot.valueType = SlotValueType.Vector4;
slot.currentValue = new Vector4(6, 6, 6, 1);
result = slot.GetDefaultValue(GenerationMode.ForReals);
m_NodeA.slot4.value = new Vector4(6, 6, 6, 1);
result = m_NodeA.slot3.GetDefaultValue(GenerationMode.ForReals);
Assert.AreEqual("half4 (6,6,6,1)", result);
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/ShaderGeneratorTests.cs


public TestNode()
{
AddSlot(new MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(V2Out, "V2Out", "V2Out", SlotType.Output, SlotValueType.Vector2, Vector4.zero));
AddSlot(new MaterialSlot(V3Out, "V3Out", "V3Out", SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(V4Out, "V4Out", "V4Out", SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new Vector1MaterialSlot(V1Out, "V1Out", "V1Out", SlotType.Output, 0));
AddSlot(new Vector2MaterialSlot(V2Out, "V2Out", "V2Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(V3Out, "V3Out", "V3Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(V4Out, "V4Out", "V4Out", SlotType.Output, Vector4.zero));
}
}

24
MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateLayeredShaderGraph.cs


using System.IO;
using UnityEditor.ProjectWindowCallback;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph
{
public class CreateLayeredShaderGraph : EndNameEditAction
{
[MenuItem("Assets/Create/Layered Shader Graph", false, 208)]
public static void CreateLayeredGraph()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateLayeredShaderGraph>(),
"New Layerd Shader Graph.LayeredShaderGraph", null, null);
}
public override void Action(int instanceId, string pathName, string resourceFile)
{
var graph = new LayeredShaderGraph();
graph.AddNode(new LayerWeightsOutputNode());
File.WriteAllText(pathName, EditorJsonUtility.ToJson(graph));
AssetDatabase.Refresh();
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateLayeredShaderGraph.cs.meta


fileFormatVersion: 2
guid: 0c11588a25854ed5bd03171503c84789
timeCreated: 1507403047

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderGraph.cs


using System.Collections.Generic;
namespace UnityEngine.MaterialGraph
{
public interface IShaderGraph
{
string GetShader(string name, GenerationMode mode, out List<PropertyCollector.TextureInfo> configuredTextures);
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderGraph.cs.meta


fileFormatVersion: 2
guid: ad9b7f8f562a4ee59873c8c222874ce7
timeCreated: 1507398800

37
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableGuid.cs


using System;
namespace UnityEngine.MaterialGraph
{
[Serializable]
public class SerializableGuid : ISerializationCallbackReceiver
{
public SerializableGuid()
{
m_Guid = Guid.NewGuid();
}
[NonSerialized]
private Guid m_Guid;
[SerializeField]
private string m_GuidSerialized;
public Guid guid
{
get { return m_Guid; }
}
public virtual void OnBeforeSerialize()
{
m_GuidSerialized = m_Guid.ToString();
}
public virtual void OnAfterDeserialize()
{
if (!string.IsNullOrEmpty(m_GuidSerialized))
m_Guid = new Guid(m_GuidSerialized);
else
m_Guid = Guid.NewGuid();
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableGuid.cs.meta


fileFormatVersion: 2
guid: fb9a23efd2bc46e9a5e34bf5ff0c9768
timeCreated: 1507479217

115
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Matrix/Matrix 2")]
public class Matrix2Node : AbstractMaterialNode, IGeneratesBodyCode
{
const int kOutputSlotId = 0;
const string kOutputSlotName = "Value";
[SerializeField]
Vector2 m_Row0;
[SerializeField]
Vector2 m_Row1;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector2 row0
{
get { return m_Row0; }
set { SetRow(ref m_Row0, value); }
}
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector2 row1
{
get { return m_Row1; }
set { SetRow(ref m_Row1, value); }
}
void SetRow(ref Vector2 row, Vector2 value)
{
if (value == row)
return;
row = value;
if (onModified != null)
onModified(this, ModificationScope.Graph);
}
public Matrix2Node()
{
name = "Matrix2";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Matrix2MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public string propertyName
{
get
{
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode());
}
}
public override string GetVariableNameForSlot(int slotId)
{
return propertyName;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "2 " + name + " = " + precision + "2x2 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row1.x + ", " + m_Row1.y + ");", true);
}
[SerializeField]
string m_Description = string.Empty;
public string description
{
get
{
return string.IsNullOrEmpty(m_Description) ? name : m_Description;
}
set { m_Description = value; }
}
// TODO - Remove Property entries everywhere?
// Matrix cant be a shader property
/*public override PropertyType propertyType
{
get { return PropertyType.Matrix2; }
}*/
/*public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new VectorPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible));
}*/
/*public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
visitor.AddShaderChunk(precision + "2 " + propertyName + ";", true);
}*/
/*public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector2 = m_Value
};
}*/
}
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig.meta


fileFormatVersion: 2
guid: 060d1826a682e4d4e9c45b4b4c93cb51
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

126
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Matrix/Matrix 3")]
public class Matrix3Node : AbstractMaterialNode, IGeneratesBodyCode
{
const int kOutputSlotId = 0;
const string kOutputSlotName = "Value";
[SerializeField]
Vector3 m_Row0;
[SerializeField]
Vector3 m_Row1;
[SerializeField]
Vector3 m_Row2;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row0
{
get { return m_Row0; }
set { SetRow(ref m_Row0, value); }
}
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row1
{
get { return m_Row1; }
set { SetRow(ref m_Row1, value); }
}
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row2
{
get { return m_Row2; }
set { SetRow(ref m_Row2, value); }
}
void SetRow(ref Vector3 row, Vector3 value)
{
if (value == row)
return;
row = value;
if (onModified != null)
onModified(this, ModificationScope.Graph);
}
public Matrix3Node()
{
name = "Matrix3";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
<<<<<<< HEAD:MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector3.zero));
=======
AddSlot(new Matrix3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
>>>>>>> exposed-prop-subgraph:MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public string propertyName
{
get { return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); }
}
public override string GetVariableNameForSlot(int slotId)
{
return propertyName;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "3x3 " + propertyName + " = " + precision + "3x3 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row0.z + ", " + m_Row1.x + ", " + m_Row1.y + ", " + m_Row1.z + ", " + m_Row2.x + ", " + m_Row2.y + ", " + m_Row2.z + ");", true);
}
[SerializeField]
string m_Description = string.Empty;
public string description
{
get
{
return string.IsNullOrEmpty(m_Description) ? name : m_Description;
}
set { m_Description = value; }
}
// TODO - Remove Property entries everywhere?
// Matrix cant be a shader property
/*public override PropertyType propertyType
{
get { return PropertyType.Matrix2; }
}*/
/*public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new VectorPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible));
}*/
/*public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
visitor.AddShaderChunk(precision + "2 " + propertyName + ";", true);
}*/
/*public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector3 = m_Value
};
}*/
}
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig.meta


fileFormatVersion: 2
guid: c8c352d3b6e0d8548ae31d044b0266a8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

34
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayerWeightsOutputNode.cs


using System;
using System.Collections.Generic;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
public class LayerWeightsOutputNode : AbstractMaterialNode, IOnAssetEnabled
{
public LayerWeightsOutputNode()
{
name = "LayerWeights";
}
public override bool allowedInRemapGraph { get { return false; } }
public override bool allowedInSubGraph { get { return false; } }
public void OnEnable()
{
var layeredGraph = owner as LayeredShaderGraph;
if (layeredGraph == null)
return;
var goodSlots = new List<int>();
foreach (var layer in layeredGraph.layers)
{
AddSlot(new Vector1MaterialSlot(layer.guid.GetHashCode(), LayeredShaderGraph.LayerToFunctionName(layer.guid), LayeredShaderGraph.LayerToFunctionName(layer.guid), SlotType.Input,0));
goodSlots.Add(layer.guid.GetHashCode());
}
RemoveSlotsNameNotMatching(goodSlots);
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayerWeightsOutputNode.cs.meta


fileFormatVersion: 2
guid: 789274d827ef4cb2a635638cb2a24718
timeCreated: 1507401785

361
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
public class LayeredShaderGraph : AbstractMaterialGraph, IShaderGraph
{
[Serializable]
public class Layer
{
[SerializeField]
private SerializableGuid m_Guid = new SerializableGuid();
[SerializeField]
private Shader m_Shader;
public Layer()
{}
public Guid guid
{
get { return m_Guid.guid; }
}
public Shader shader
{
get { return m_Shader; }
set { m_Shader = value; }
}
}
[NonSerialized]
private List<Layer> m_Layers = new List<Layer>();
[SerializeField]
List<SerializationHelper.JSONSerializedElement> m_SerializedLayers = new List<SerializationHelper.JSONSerializedElement>();
public IEnumerable<Layer> layers
{
get { return m_Layers; }
}
[NonSerialized]
private LayerWeightsOutputNode m_OutputNode;
public LayerWeightsOutputNode outputNode
{
get
{
// find existing node
if (m_OutputNode == null)
m_OutputNode = GetNodes<LayerWeightsOutputNode>().FirstOrDefault();
return m_OutputNode;
}
}
public override void AddNode(INode node)
{
if (outputNode != null && node is LayerWeightsOutputNode)
{
Debug.LogWarning("Attempting to add second LayerWeightsOutputNode to LayeredShaderGraph. This is not allowed.");
return;
}
base.AddNode(node);
}
public void AddLayer()
{
var layer = new Layer();
m_Layers.Add(layer);
NotifyChange(new LayerAdded(layer));
if (outputNode != null)
outputNode.onModified(outputNode, ModificationScope.Graph);
}
public bool SetLayer(Guid layerId, Shader newShader)
{
try
{
var path = AssetDatabase.GetAssetPath(newShader);
if (!path.EndsWith("shaderGraph", StringComparison.InvariantCultureIgnoreCase))
return false;
var name = Path.GetFileNameWithoutExtension(path);
var textGraph = File.ReadAllText(path, Encoding.UTF8);
var graph = JsonUtility.FromJson<MaterialGraph>(textGraph);
if (graph == null)
return false;
var layer = layers.FirstOrDefault(x => x.guid == layerId);
if (layer == null)
return false;
layer.shader = newShader;
if (outputNode != null)
{
outputNode.OnEnable();
outputNode.onModified(outputNode, ModificationScope.Graph);
}
return true;
}
catch (Exception)
{
// ignored
}
return false;
}
public void RemoveLayer(Guid id)
{
var num = m_Layers.RemoveAll(x => x.guid == id);
if (num > 0)
{
NotifyChange(new LayerRemoved(id));
if (outputNode != null)
outputNode.onModified(outputNode, ModificationScope.Graph);
}
}
public override void OnBeforeSerialize()
{
base.OnBeforeSerialize();
m_SerializedLayers = SerializationHelper.Serialize<Layer>(m_Layers);
}
public override void OnAfterDeserialize()
{
m_OutputNode = null;
m_Layers = SerializationHelper.Deserialize<Layer>(m_SerializedLayers, null);
m_SerializedLayers = null;
base.OnAfterDeserialize();
}
public static string LayerToFunctionName(Guid id)
{
return string.Format("Layer_{0}", GuidEncoder.Encode(id));
}
public string GetShader(string name, GenerationMode mode, out List<PropertyCollector.TextureInfo> configuredTextures)
{
if (outputNode == null)
throw new InvalidOperationException();
var layerMap = new Dictionary<Guid, MaterialGraph>();
foreach (var layer in layers)
{
var path = AssetDatabase.GetAssetPath(layer.shader);
if (!path.EndsWith("shaderGraph", StringComparison.InvariantCultureIgnoreCase))
continue;
var textGraph = File.ReadAllText(path, Encoding.UTF8);
var graph = JsonUtility.FromJson<MaterialGraph>(textGraph);
if (graph == null)
continue;
layerMap[layer.guid] = graph;
}
if (layerMap.Count == 0)
{
configuredTextures = new List<PropertyCollector.TextureInfo>();
return string.Empty;
}
var vertexShader = new ShaderGenerator();
var layerShaders = new ShaderGenerator();
var surfaceDescriptionFunction = new ShaderGenerator();
var surfaceDescriptionStruct = new ShaderGenerator();
var shaderFunctionVisitor = new ShaderGenerator();
var surfaceInputs = new ShaderGenerator();
var graphVertexInput = @"
struct GraphVertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 texcoord0 : TEXCOORD0;
float4 lightmapUV : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};";
surfaceInputs.AddShaderChunk("struct SurfaceInputs{", false);
surfaceInputs.Indent();
var requirements = ShaderGraphRequirements.none;
foreach (var layer in layerMap)
requirements = requirements.Union(GetRequierments(layer.Value.masterNode as AbstractMaterialNode));
requirements = requirements.Union(GetRequierments(outputNode));
GenerateSpaceTranslationSurfaceInputs(requirements.requiresNormal, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceNormal, ShaderGeneratorNames.ViewSpaceNormal,
ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.TangentSpaceNormal);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresTangent, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceTangent, ShaderGeneratorNames.ViewSpaceTangent,
ShaderGeneratorNames.WorldSpaceTangent, ShaderGeneratorNames.TangentSpaceTangent);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresBitangent, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceBiTangent, ShaderGeneratorNames.ViewSpaceBiTangent,
ShaderGeneratorNames.WorldSpaceBiTangent, ShaderGeneratorNames.TangentSpaceBiTangent);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresViewDir, surfaceInputs,
ShaderGeneratorNames.ObjectSpaceViewDirection, ShaderGeneratorNames.ViewSpaceViewDirection,
ShaderGeneratorNames.WorldSpaceViewDirection, ShaderGeneratorNames.TangentSpaceViewDirection);
GenerateSpaceTranslationSurfaceInputs(requirements.requiresPosition, surfaceInputs,
ShaderGeneratorNames.ObjectSpacePosition, ShaderGeneratorNames.ViewSpacePosition,
ShaderGeneratorNames.WorldSpacePosition, ShaderGeneratorNames.TangentSpacePosition);
if (requirements.requiresVertexColor)
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.VertexColor), false);
if (requirements.requiresScreenPosition)
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.ScreenPosition), false);
foreach (var channel in requirements.requiresMeshUVs.Distinct())
surfaceInputs.AddShaderChunk(string.Format("half4 {0};", channel.GetUVName()), false);
surfaceInputs.Deindent();
surfaceInputs.AddShaderChunk("};", false);
vertexShader.AddShaderChunk("GraphVertexInput PopulateVertexData(GraphVertexInput v){", false);
vertexShader.Indent();
vertexShader.AddShaderChunk("return v;", false);
vertexShader.Deindent();
vertexShader.AddShaderChunk("}", false);
var shaderProperties = new PropertyCollector();
var baseGraph = layerMap.Values.FirstOrDefault();
if (baseGraph == null)
{
configuredTextures = new List<PropertyCollector.TextureInfo>();
return string.Empty;
}
var masterNode = baseGraph.masterNode;
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, masterNode as AbstractMaterialNode, true);
foreach (var layer in layerMap)
{
GenerateSurfaceDescription(
layer.Value.masterNode as AbstractMaterialNode,
surfaceDescriptionFunction,
shaderFunctionVisitor,
shaderProperties,
requirements,
mode,
true,
LayerToFunctionName(layer.Key));
}
surfaceDescriptionStruct.AddShaderChunk("struct WeightsSurfaceDescription{", false);
surfaceDescriptionStruct.Indent();
foreach (var slot in outputNode.GetInputSlots<MaterialSlot>())
surfaceDescriptionStruct.AddShaderChunk(AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType) + " " + slot.shaderOutputName + ";", false);
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
GenerateSurfaceDescription(
outputNode,
surfaceDescriptionFunction,
shaderFunctionVisitor,
shaderProperties,
requirements,
mode,
true,
"PopulateWeightsGraph",
"WeightsSurfaceDescription");
string functionName = "PopulateSurfaceData";
string surfaceDescriptionName = "SurfaceDescription";
layerShaders.AddShaderChunk(string.Format("{0} {1}(SurfaceInputs IN) {{", surfaceDescriptionName, functionName), false);
layerShaders.Indent();
layerShaders.AddShaderChunk("WeightsSurfaceDescription weights = PopulateWeightsGraph(IN);", false);
layerShaders.AddShaderChunk("SurfaceDescription result = (SurfaceDescription)0;", false);
foreach (var layer in layerMap)
{
layerShaders.AddShaderChunk(
string.Format(
"{0} {1} = {2}({3});",
surfaceDescriptionName,
LayerToFunctionName(layer.Key) + "_surface",
LayerToFunctionName(layer.Key),
"IN"), false);
layerShaders.AddShaderChunk(
string.Format("ScaleSurfaceDescription({0}_surface, weights.{0});", LayerToFunctionName(layer.Key)), false);
layerShaders.AddShaderChunk(string.Format("AddSurfaceDescription(result, {0}_surface);", LayerToFunctionName(layer.Key)), false);
}
layerShaders.AddShaderChunk("return result;", false);
layerShaders.Deindent();
layerShaders.AddShaderChunk("}", false);
var finalShader = new ShaderGenerator();
finalShader.AddShaderChunk(string.Format(@"Shader ""{0}""", name), false);
finalShader.AddShaderChunk("{", false);
finalShader.Indent();
finalShader.AddShaderChunk("Properties", false);
finalShader.AddShaderChunk("{", false);
finalShader.Indent();
finalShader.AddShaderChunk(shaderProperties.GetPropertiesBlock(2), false);
finalShader.Deindent();
finalShader.AddShaderChunk("}", false);
finalShader.AddShaderChunk("CGINCLUDE", false);
finalShader.AddShaderChunk("#include \"UnityCG.cginc\"", false);
finalShader.AddShaderChunk(shaderFunctionVisitor.GetShaderString(2), false);
finalShader.AddShaderChunk(graphVertexInput, false);
finalShader.AddShaderChunk(surfaceInputs.GetShaderString(2), false);
finalShader.AddShaderChunk(surfaceDescriptionStruct.GetShaderString(2), false);
finalShader.AddShaderChunk(shaderProperties.GetPropertiesDeclaration(2), false);
finalShader.AddShaderChunk(vertexShader.GetShaderString(2), false);
finalShader.AddShaderChunk(surfaceDescriptionFunction.GetShaderString(2), false);
finalShader.AddShaderChunk(layerShaders.GetShaderString(2), false);
finalShader.AddShaderChunk("ENDCG", false);
if (masterNode != null)
{
var subShaders = masterNode.GetSubshader(requirements, null);
foreach (var ss in subShaders)
finalShader.AddShaderChunk(ss, false);
}
finalShader.Deindent();
finalShader.AddShaderChunk("}", false);
configuredTextures = shaderProperties.GetConfiguredTexutres();
return finalShader.GetShaderString(0);
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs.meta


fileFormatVersion: 2
guid: 8ce99f0c764243ab9e2713566d4105af
timeCreated: 1507398692

470
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs.orig


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing
{
public interface IMaterialGraphEditWindow
{
void PingAsset();
void UpdateAsset();
void Repaint();
void ToSubGraph();
void Show();
void Focus();
Object selected { get; set; }
void ChangeSelection(Object newSelection);
}
public abstract class HelperMaterialGraphEditWindow : EditorWindow, IMaterialGraphEditWindow
{
public abstract AbstractMaterialGraph GetMaterialGraph();
public abstract void PingAsset();
public abstract void UpdateAsset();
public abstract void ToSubGraph();
public abstract Object selected { get; set; }
public abstract void ChangeSelection(Object newSelection);
}
public class MaterialGraphEditWindow : AbstractMaterialGraphEditWindow<UnityEngine.MaterialGraph.MaterialGraph>
{
public override AbstractMaterialGraph GetMaterialGraph()
{
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}
public class SubGraphEditWindow : AbstractMaterialGraphEditWindow<SubGraph>
{
public override AbstractMaterialGraph GetMaterialGraph()
{
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}
public class MasterReampGraphEditWindow : AbstractMaterialGraphEditWindow<MasterRemapGraph>
{
public override AbstractMaterialGraph GetMaterialGraph()
{
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}
public class LayeredGraphEditWindow : AbstractMaterialGraphEditWindow<LayeredShaderGraph>
{
public override AbstractMaterialGraph GetMaterialGraph()
{
return inMemoryAsset;
}
}
public abstract class AbstractMaterialGraphEditWindow<TGraphType> : HelperMaterialGraphEditWindow where TGraphType : AbstractMaterialGraph
{
[SerializeField]
Object m_Selected;
[SerializeField]
SerializableGraphObject m_GraphObject;
GraphEditorView m_GraphEditorView;
GraphEditorView graphEditorView
{
get { return m_GraphEditorView; }
set
{
if (m_GraphEditorView != null)
{
rootVisualContainer.Remove(m_GraphEditorView);
m_GraphEditorView.Dispose();
}
m_GraphEditorView = value;
if (m_GraphEditorView != null)
{
m_GraphEditorView.onUpdateAssetClick += UpdateAsset;
m_GraphEditorView.onConvertToSubgraphClick += ToSubGraph;
m_GraphEditorView.onShowInProjectClick += PingAsset;
m_GraphEditorView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
rootVisualContainer.Add(graphEditorView);
}
}
}
protected SerializableGraphObject graphObject
{
get { return m_GraphObject; }
set
{
if (m_GraphObject != null)
DestroyImmediate(m_GraphObject);
m_GraphObject = value;
}
}
public override Object selected
{
get { return m_Selected; }
set { m_Selected = value; }
}
void Update()
{
var materialGraph = GetMaterialGraph();
if (materialGraph == null)
return;
if (graphEditorView == null || graphEditorView.graphPresenter == null)
{
graphEditorView = new GraphEditorView(materialGraph, this, selected.name);
}
if (graphEditorView != null)
graphEditorView.previewSystem.Update();
}
void OnDisable()
{
graphEditorView = null;
}
void OnDestroy()
{
if (EditorUtility.DisplayDialog("Shader Graph Might Have Been Modified", "Do you want to save the changes you made in the shader graph?", "Save", "Don't Save"))
{
UpdateAsset();
}
Undo.ClearUndo(graphObject);
DestroyImmediate(graphObject);
graphEditorView = null;
}
void OnGUI()
{
if (graphEditorView == null)
return;
var presenter = graphEditorView.graphPresenter;
var e = Event.current;
if (e.type == EventType.ValidateCommand && (
e.commandName == "Copy" && presenter.canCopy
|| e.commandName == "Paste" && presenter.canPaste
|| e.commandName == "Duplicate" && presenter.canDuplicate
|| e.commandName == "Cut" && presenter.canCut
|| (e.commandName == "Delete" || e.commandName == "SoftDelete") && presenter.canDelete))
{
e.Use();
}
if (e.type == EventType.ExecuteCommand)
{
if (e.commandName == "Copy")
presenter.Copy();
if (e.commandName == "Paste")
presenter.Paste();
if (e.commandName == "Duplicate")
presenter.Duplicate();
if (e.commandName == "Cut")
presenter.Cut();
if (e.commandName == "Delete" || e.commandName == "SoftDelete")
presenter.Delete();
}
if (e.type == EventType.KeyDown)
{
if (e.keyCode == KeyCode.A)
graphEditorView.graphView.FrameAll();
if (e.keyCode == KeyCode.F)
graphEditorView.graphView.FrameSelection();
if (e.keyCode == KeyCode.O)
graphEditorView.graphView.FrameOrigin();
if (e.keyCode == KeyCode.Tab)
graphEditorView.graphView.FrameNext();
if (e.keyCode == KeyCode.Tab && e.modifiers == EventModifiers.Shift)
graphEditorView.graphView.FramePrev();
}
}
public override void PingAsset()
{
if (selected != null)
EditorGUIUtility.PingObject(selected);
}
public override void UpdateAsset()
{
if (selected != null && graphObject != null)
{
var path = AssetDatabase.GetAssetPath(selected);
if (string.IsNullOrEmpty(path) || graphObject == null)
{
return;
}
if (typeof(TGraphType) == typeof(UnityEngine.MaterialGraph.MaterialGraph))
UpdateShaderGraphOnDisk(path);
if (typeof(TGraphType) == typeof(LayeredShaderGraph))
UpdateShaderGraphOnDisk(path);
if (typeof(TGraphType) == typeof(SubGraph))
UpdateAbstractSubgraphOnDisk<SubGraph>(path);
if (typeof(TGraphType) == typeof(MasterRemapGraph))
UpdateAbstractSubgraphOnDisk<MasterRemapGraph>(path);
}
}
public override void ToSubGraph()
{
string path = EditorUtility.SaveFilePanelInProject("Save subgraph", "New SubGraph", "ShaderSubGraph", "");
path = path.Replace(Application.dataPath, "Assets");
if (path.Length == 0)
return;
var graphPresenter = graphEditorView.graphPresenter;
var selected = graphPresenter.elements.Where(e => e.selected);
var filtered = new List<GraphElementPresenter>();
foreach (var presenter in selected)
{
var nodePresenter = presenter as MaterialNodePresenter;
if (nodePresenter != null)
{
if (!(nodePresenter.node is PropertyNode))
filtered.Add(nodePresenter);
}
else
{
filtered.Add(presenter);
}
}
var deserialized = MaterialGraphPresenter.DeserializeCopyBuffer(JsonUtility.ToJson(MaterialGraphPresenter.CreateCopyPasteGraph(filtered)));
if (deserialized == null)
return;
var graph = new SubGraph();
graph.AddNode(new SubGraphOutputNode());
var nodeGuidMap = new Dictionary<Guid, Guid>();
foreach (var node in deserialized.GetNodes<INode>())
{
var oldGuid = node.guid;
var newGuid = node.RewriteGuid();
nodeGuidMap[oldGuid] = newGuid;
graph.AddNode(node);
}
// remap outputs to the subgraph
var onlyInputInternallyConnected = new List<IEdge>();
var onlyOutputInternallyConnected = new List<IEdge>();
foreach (var edge in deserialized.edges)
{
var outputSlot = edge.outputSlot;
var inputSlot = edge.inputSlot;
Guid remappedOutputNodeGuid;
Guid remappedInputNodeGuid;
var outputRemapExists = nodeGuidMap.TryGetValue(outputSlot.nodeGuid, out remappedOutputNodeGuid);
var inputRemapExists = nodeGuidMap.TryGetValue(inputSlot.nodeGuid, out remappedInputNodeGuid);
// pasting nice internal links!
if (outputRemapExists && inputRemapExists)
{
var outputSlotRef = new SlotReference(remappedOutputNodeGuid, outputSlot.slotId);
var inputSlotRef = new SlotReference(remappedInputNodeGuid, inputSlot.slotId);
graph.Connect(outputSlotRef, inputSlotRef);
}
// one edge needs to go to outside world
else if (outputRemapExists)
{
onlyOutputInternallyConnected.Add(edge);
}
else if (inputRemapExists)
{
onlyInputInternallyConnected.Add(edge);
}
}
var uniqueInputEdges = onlyOutputInternallyConnected.GroupBy(
edge => edge.outputSlot,
edge => edge,
(key, edges) => new {slotRef = key, edges = edges.ToList()});
var inputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>();
foreach (var group in uniqueInputEdges)
{
var inputNode = new PropertyNode();
var sr = group.slotRef;
var fromNode = graphPresenter.graph.GetNodeFromGuid(sr.nodeGuid);
var fromSlot = fromNode.FindOutputSlot<MaterialSlot>(sr.slotId);
switch (fromSlot.concreteValueType)
{
case ConcreteSlotValueType.SamplerState:
break;
case ConcreteSlotValueType.Matrix4:
break;
case ConcreteSlotValueType.Matrix3:
break;
case ConcreteSlotValueType.Matrix2:
break;
case ConcreteSlotValueType.Texture2D:
break;
case ConcreteSlotValueType.Vector4:
break;
case ConcreteSlotValueType.Vector3:
break;
case ConcreteSlotValueType.Vector2:
break;
case ConcreteSlotValueType.Vector1:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
var uniqueOutputEdges = onlyInputInternallyConnected.GroupBy(
edge => edge.inputSlot,
edge => edge,
(key, edges) => new {slot = key, edges = edges.ToList()});
var outputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>();
foreach (var group in uniqueOutputEdges)
{
var outputNode = graph.outputNode;
var slotId = outputNode.AddSlot();
var inputSlotRef = new SlotReference(outputNode.guid, slotId);
foreach (var edge in group.edges)
{
var newEdge = graph.Connect(new SlotReference(nodeGuidMap[edge.outputSlot.nodeGuid], edge.outputSlot.slotId), inputSlotRef);
outputsNeedingConnection.Add(new KeyValuePair<IEdge, IEdge>(edge, newEdge));
}
}
File.WriteAllText(path, EditorJsonUtility.ToJson(graph));
AssetDatabase.ImportAsset(path);
var subGraph = AssetDatabase.LoadAssetAtPath(path, typeof(MaterialSubGraphAsset)) as MaterialSubGraphAsset;
if (subGraph == null)
return;
var subGraphNode = new SubGraphNode();
graphPresenter.graph.AddNode(subGraphNode);
subGraphNode.subGraphAsset = subGraph;
/* foreach (var edgeMap in inputsNeedingConnection)
{
graphPresenter.graph.Connect(edgeMap.Key.outputSlot, new SlotReference(subGraphNode.guid, edgeMap.Value.outputSlot.slotId));
}*/
foreach (var edgeMap in outputsNeedingConnection)
{
graphPresenter.graph.Connect(new SlotReference(subGraphNode.guid, edgeMap.Value.inputSlot.slotId), edgeMap.Key.inputSlot);
}
var toDelete = graphPresenter.elements.Where(e => e.selected).OfType<MaterialNodePresenter>();
graphPresenter.RemoveElements(toDelete, new List<GraphEdgePresenter>());
}
private void UpdateAbstractSubgraphOnDisk<T>(string path) where T : AbstractSubGraph
{
var graph = graphObject.graph as T;
if (graph == null)
return;
File.WriteAllText(path, EditorJsonUtility.ToJson(graph, true));
AssetDatabase.ImportAsset(path);
}
private void UpdateShaderGraphOnDisk(string path)
{
<<<<<<< HEAD
var graph = graphObject.graph as UnityEngine.MaterialGraph.MaterialGraph;
=======
var graph = inMemoryAsset as IShaderGraph;
>>>>>>> exposed-prop-subgraph
if (graph == null)
return;
List<PropertyCollector.TextureInfo> configuredTextures;
graph.GetShader(Path.GetFileNameWithoutExtension(path), GenerationMode.ForReals, out configuredTextures);
var shaderImporter = AssetImporter.GetAtPath(path) as ShaderImporter;
if (shaderImporter == null)
return;
var textureNames = new List<string>();
var textures = new List<Texture>();
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable))
{
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture;
if (texture == null)
continue;
textureNames.Add(textureInfo.name);
textures.Add(texture);
}
shaderImporter.SetDefaultTextures(textureNames.ToArray(), textures.ToArray());
textureNames.Clear();
textures.Clear();
foreach (var textureInfo in configuredTextures.Where(x => !x.modifiable))
{
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture;
if (texture == null)
continue;
textureNames.Add(textureInfo.name);
textures.Add(texture);
}
shaderImporter.SetNonModifiableTextures(textureNames.ToArray(), textures.ToArray());
File.WriteAllText(path, EditorJsonUtility.ToJson(graph, true));
shaderImporter.SaveAndReimport();
AssetDatabase.ImportAsset(path);
}
public override void ChangeSelection(Object newSelection)
{
if (!EditorUtility.IsPersistent(newSelection))
return;
if (selected == newSelection)
return;
selected = newSelection;
var path = AssetDatabase.GetAssetPath(newSelection);
var textGraph = File.ReadAllText(path, Encoding.UTF8);
graphObject = CreateInstance<SerializableGraphObject>();
graphObject.hideFlags = HideFlags.HideAndDontSave;
graphObject.graph = JsonUtility.FromJson<TGraphType>(textGraph);
graphObject.graph.OnEnable();
graphObject.graph.ValidateGraph();
graphEditorView = new GraphEditorView(GetMaterialGraph(), this, selected.name);
titleContent = new GUIContent(selected.name);
Repaint();
}
void OnPostLayout(PostLayoutEvent evt)
{
graphEditorView.UnregisterCallback<PostLayoutEvent>(OnPostLayout);
graphEditorView.graphView.FrameAll();
}
}
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs.orig.meta


fileFormatVersion: 2
guid: 5585390fdc911dd4e938a94c9c579c90
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

260
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs.orig


using System;
using System.Linq;
using UnityEditor.Graphing.Util;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{
public class GraphInspectorView : VisualElement, IDisposable
{
[SerializeField]
GraphInspectorPresenter m_Presenter;
int m_SelectionHash;
VisualElement m_Title;
VisualElement m_PropertyItems;
VisualElement m_LayerItems;
VisualElement m_ContentContainer;
AbstractNodeEditorView m_EditorView;
TypeMapper m_TypeMapper;
Image m_Preview;
VisualElement m_TopContainer;
public GraphInspectorView()
{
AddStyleSheetPath("Styles/MaterialGraph");
m_TopContainer = new VisualElement { name = "top" };
{
var headerContainer = new VisualElement { name = "header" };
{
m_Title = new VisualElement() { name = "title" };
headerContainer.Add(m_Title);
}
m_TopContainer.Add(headerContainer);
m_ContentContainer = new VisualElement { name = "content" };
m_TopContainer.Add(m_ContentContainer);
}
Add(m_TopContainer);
var bottomContainer = new VisualElement { name = "bottom" };
{
var propertiesContainer = new VisualElement { name = "properties" };
{
var header = new VisualElement { name = "header" };
{
var title = new VisualElement { name = "title", text = "Properties" };
header.Add(title);
var addPropertyButton = new Button(OnAddProperty) { text = "Add", name = "addButton" };
header.Add(addPropertyButton);
}
propertiesContainer.Add(header);
m_PropertyItems = new VisualContainer { name = "items" };
propertiesContainer.Add(m_PropertyItems);
}
bottomContainer.Add(propertiesContainer);
<<<<<<< HEAD
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture };
=======
//if (m_Presenter.graph is LayeredShaderGraph)
{
var layersContainer = new VisualElement {name = "properties"};
{
var header = new VisualElement {name = "header"};
{
var title = new VisualElement {name = "title", text = "Layers"};
header.Add(title);
var addLayerButton = new Button(OnAddLayer) {text = "Add", name = "addButton"};
header.Add(addLayerButton);
}
propertiesContainer.Add(header);
m_LayerItems = new VisualContainer {name = "items"};
propertiesContainer.Add(m_LayerItems);
}
bottomContainer.Add(layersContainer);
}
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture};
>>>>>>> exposed-prop-subgraph
bottomContainer.Add(m_Preview);
}
Add(bottomContainer);
// Nodes missing custom editors:
// - PropertyNode
// - SubGraphInputNode
// - SubGraphOutputNode
m_TypeMapper = new TypeMapper(typeof(INode), typeof(AbstractNodeEditorView), typeof(StandardNodeEditorView))
{
// { typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) }
};
}
void OnAddProperty()
{
var gm = new GenericMenu();
<<<<<<< HEAD
gm.AddItem(new GUIContent("Float"), false, () => AddProperty(new FloatShaderProperty()));
gm.AddItem(new GUIContent("Vector2"), false, () => AddProperty(new Vector2ShaderProperty()));
gm.AddItem(new GUIContent("Vector3"), false, () => AddProperty(new Vector3ShaderProperty()));
gm.AddItem(new GUIContent("Vector4"), false, () => AddProperty(new Vector4ShaderProperty()));
gm.AddItem(new GUIContent("Color"), false, () => AddProperty(new ColorShaderProperty()));
gm.AddItem(new GUIContent("Texture"), false, () => AddProperty(new TextureShaderProperty()));
gm.ShowAsContext();
}
void AddProperty(IShaderProperty property)
{
m_Presenter.graph.owner.RegisterCompleteObjectUndo("Add Property");
m_Presenter.graph.AddShaderProperty(property);
=======
gm.AddItem(new GUIContent("Float"), false, () => m_Presenter.graph.AddShaderProperty(new FloatShaderProperty()));
gm.AddItem(new GUIContent("Vector2"), false, () => m_Presenter.graph.AddShaderProperty(new Vector2ShaderProperty()));
gm.AddItem(new GUIContent("Vector3"), false, () => m_Presenter.graph.AddShaderProperty(new Vector3ShaderProperty()));
gm.AddItem(new GUIContent("Vector4"), false, () => m_Presenter.graph.AddShaderProperty(new Vector4ShaderProperty()));
gm.AddItem(new GUIContent("Color"), false, () => m_Presenter.graph.AddShaderProperty(new ColorShaderProperty()));
gm.AddItem(new GUIContent("Texture"), false, () => m_Presenter.graph.AddShaderProperty(new TextureShaderProperty()));
gm.ShowAsContext();
}
void OnAddLayer()
{
var layerGraph = m_Presenter.graph as LayeredShaderGraph;
if (layerGraph == null)
return;
layerGraph.AddLayer();
>>>>>>> exposed-prop-subgraph
}
public void OnChange(GraphInspectorPresenter.ChangeType changeType)
{
if (presenter == null)
{
m_ContentContainer.Clear();
m_SelectionHash = 0;
return;
}
if ((changeType & GraphInspectorPresenter.ChangeType.AssetName) != 0)
m_Title.text = presenter.assetName;
if ((changeType & GraphInspectorPresenter.ChangeType.SelectedNodes) != 0)
{
var selectionHash = UIUtilities.GetHashCode(presenter.selectedNodes.Count, presenter.selectedNodes != null ? presenter.selectedNodes.FirstOrDefault() : null);
if (selectionHash != m_SelectionHash)
{
m_SelectionHash = selectionHash;
m_ContentContainer.Clear();
if (presenter.selectedNodes.Count > 1)
{
var element = new VisualElement {name = "selectionCount", text = string.Format("{0} nodes selected.", presenter.selectedNodes.Count)};
m_ContentContainer.Add(element);
}
else if (presenter.selectedNodes.Count == 1)
{
var node = presenter.selectedNodes.First();
var view = (AbstractNodeEditorView) Activator.CreateInstance(m_TypeMapper.MapType(node.GetType()));
view.node = node;
m_ContentContainer.Add(view);
}
}
}
if ((changeType & GraphInspectorPresenter.ChangeType.PreviewTexture) != 0)
{
m_Preview.image = presenter.previewTexture ?? Texture2D.blackTexture;
}
if ((changeType & GraphInspectorPresenter.ChangeType.Graph) != 0)
{
if (m_Graph != null)
{
m_Graph.onChange -= OnGraphChange;
m_PropertyItems.Clear();
m_LayerItems.Clear();
m_Graph = null;
}
if (m_Presenter.graph != null)
{
m_Graph = m_Presenter.graph;
foreach (var property in m_Graph.properties)
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));
var layerGraph = m_Presenter.graph as LayeredShaderGraph;
if (layerGraph != null)
foreach (var layer in layerGraph.layers)
m_LayerItems.Add(new ShaderLayerView(layerGraph, layer));
m_Graph.onChange += OnGraphChange;
}
}
}
void OnGraphChange(GraphChange change)
{
var propertyAdded = change as ShaderPropertyAdded;
if (propertyAdded != null)
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, propertyAdded.shaderProperty));
var propertyRemoved = change as ShaderPropertyRemoved;
if (propertyRemoved != null)
{
var propertyView = m_PropertyItems.OfType<ShaderPropertyView>().FirstOrDefault(v => v.property.guid == propertyRemoved.guid);
if (propertyView != null)
m_PropertyItems.Remove(propertyView);
}
var layerGraph = m_Graph as LayeredShaderGraph;
if (layerGraph == null)
return;
var layerAdded = change as LayerAdded;
if (layerAdded != null)
m_LayerItems.Add(new ShaderLayerView(layerGraph, layerAdded.layer));
var layerRemoved = change as LayerRemoved;
if (layerRemoved != null)
{
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == layerRemoved.id);
if (view != null)
m_LayerItems.Remove(view);
}
}
AbstractMaterialGraph m_Graph;
public GraphInspectorPresenter presenter
{
get { return m_Presenter; }
set
{
if (m_Presenter == value)
return;
if (m_Presenter != null)
m_Presenter.onChange -= OnChange;
m_Presenter = value;
OnChange(GraphInspectorPresenter.ChangeType.All);
m_Presenter.onChange += OnChange;
}
}
public void Dispose()
{
if (m_Presenter != null)
m_Presenter.onChange -= OnChange;
}
}
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs.orig.meta


fileFormatVersion: 2
guid: d82dd6376c038284f9b84c0cc59b2af4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

46
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderLayerview.cs


using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{
public class ShaderLayerView : VisualElement
{
public LayeredShaderGraph graph { get; }
public LayeredShaderGraph.Layer layer { get; }
public ShaderLayerView(LayeredShaderGraph graph, LayeredShaderGraph.Layer layer)
{
this.graph = graph;
this.layer = layer;
Add(new IMGUIContainer(ValueField) { name = "value" });
Add(new Button(OnClickRemove) { name = "remove", text = "Remove" });
}
void OnClickRemove()
{
graph.RemoveLayer(layer.guid);
NotifyNodes();
}
void ValueField()
{
EditorGUI.BeginChangeCheck();
var newShader = EditorGUILayout.ObjectField("Shader", layer.shader, typeof(Shader), false) as Shader;
if (newShader != layer.shader)
{
if (graph.SetLayer(layer.guid, newShader))
NotifyNodes();
}
}
void NotifyNodes()
{
foreach (var node in graph.GetNodes<PropertyNode>())
node.onModified(node, ModificationScope.Graph);
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderLayerview.cs.meta


fileFormatVersion: 2
guid: e1839e94c8024ee6a36ff3aa05cef37b
timeCreated: 1507451136

395
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs.orig


using System;
using UnityEngine.MaterialGraph;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEditor.Graphing.Util;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Graphing;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
public class MaterialGraphPresenter : GraphViewPresenter
{
PreviewSystem m_PreviewSystem;
public IGraph graph { get; private set; }
protected MaterialGraphPresenter()
{
<<<<<<< HEAD
=======
typeMapper = new GraphTypeMapper(typeof(MaterialNodePresenter));
typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter);
typeMapper[typeof(ColorNode)] = typeof(ColorNodePresenter);
typeMapper[typeof(GradientNode)] = typeof(GradientNodePresenter);
// typeMapper[typeof(ScatterNode)] = typeof(ScatterNodePresenter);
//typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
//typeMapper[typeof(SamplerAssetNode)] = typeof(SamplerAssetNodePresenter);
//typeMapper[typeof(TextureSamplerNode)] = typeof(TextureSamplerNodePresenter);
// typeMapper[typeof(Texture2DNode)] = typeof(TextureAssetNodePresenter);
// typeMapper[typeof(TextureLODNode)] = typeof(TextureLODNodePresenter);
typeMapper[typeof(SamplerStateNode)] = typeof(SamplerStateNodePresenter);
// typeMapper[typeof(CubemapNode)] = typeof(CubeNodePresenter);
// typeMapper[typeof(ToggleNode)] = typeof(ToggleNodePresenter);
typeMapper[typeof(UVNode)] = typeof(UVNodePresenter);
typeMapper[typeof(Vector1Node)] = typeof(Vector1NodePresenter);
typeMapper[typeof(Vector2Node)] = typeof(Vector2NodePresenter);
typeMapper[typeof(Vector3Node)] = typeof(Vector3NodePresenter);
typeMapper[typeof(Vector4Node)] = typeof(Vector4NodePresenter);
typeMapper[typeof(PropertyNode)] = typeof(PropertyNodePresenter);
/* typeMapper[typeof(ScaleOffsetNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(RadialShearNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphereWarpNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphericalIndentationNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboardNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboard3dNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter*/
typeMapper[typeof(SubGraphNode)] = typeof(SubgraphNodePresenter);
typeMapper[typeof(MasterRemapNode)] = typeof(MasterRemapNodePresenter);
// typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter);
typeMapper[typeof(SubGraphOutputNode)] = typeof(SubgraphIONodePresenter);
// typeMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterNodePresenter);
typeMapper[typeof(LevelsNode)] = typeof(LevelsNodePresenter);
typeMapper[typeof(ConstantsNode)] = typeof(ConstantsNodePresenter);
//typeMapper[typeof(SwizzleNode)] = typeof(SwizzleNodePresenter);
typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodePresenter);
// typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
typeMapper[typeof(IfNode)] = typeof(IfNodePresenter);
//typeMapper[typeof(CustomCodeNode)] = typeof(CustomCodePresenter);
typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodePresenter);
typeMapper[typeof(Matrix3Node)] = typeof(Matrix3NodePresenter);
typeMapper[typeof(Matrix4Node)] = typeof(Matrix4NodePresenter);
typeMapper[typeof(MatrixCommonNode)] = typeof(MatrixCommonNodePresenter);
typeMapper[typeof(TransformNode)] = typeof(TransformNodePresenter);
// typeMapper[typeof(ConvolutionFilterNode)] = typeof(ConvolutionFilterNodePresenter);
>>>>>>> exposed-prop-subgraph
}
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)
{
var compatibleAnchors = new List<NodeAnchorPresenter>();
var startAnchorPresenter = startAnchor as GraphAnchorPresenter;
if (startAnchorPresenter == null)
return compatibleAnchors;
var startSlot = startAnchorPresenter.slot as MaterialSlot;
if (startSlot == null)
return compatibleAnchors;
var startStage = startSlot.shaderStage;
if (startStage == ShaderStage.Dynamic)
startStage = NodeUtils.FindEffectiveShaderStage(startSlot.owner, startSlot.isOutputSlot);
foreach (var candidateAnchorPresenter in allChildren.OfType<GraphAnchorPresenter>())
{
if (!candidateAnchorPresenter.IsConnectable())
continue;
if (candidateAnchorPresenter.orientation != startAnchor.orientation)
continue;
if (candidateAnchorPresenter.direction == startAnchor.direction)
continue;
if (nodeAdapter.GetAdapter(candidateAnchorPresenter.source, startAnchor.source) == null)
continue;
var candidateSlot = candidateAnchorPresenter.slot as MaterialSlot;
if (candidateSlot == null)
continue;
if (candidateSlot.owner == startSlot.owner)
continue;
if (!startSlot.IsCompatibleWithInputSlotType(candidateSlot.concreteValueType))
continue;
if (startStage != ShaderStage.Dynamic)
{
var candidateStage = candidateSlot.shaderStage;
if (candidateStage == ShaderStage.Dynamic)
candidateStage = NodeUtils.FindEffectiveShaderStage(candidateSlot.owner, !startSlot.isOutputSlot);
if (candidateStage != ShaderStage.Dynamic && candidateStage != startStage)
continue;
}
compatibleAnchors.Add(candidateAnchorPresenter);
}
return compatibleAnchors;
}
void OnNodeChanged(INode inNode, ModificationScope scope)
{
var dependentNodes = new List<INode>();
NodeUtils.CollectNodesNodeFeedsInto(dependentNodes, inNode);
foreach (var node in dependentNodes)
{
var theElements = m_Elements.OfType<MaterialNodePresenter>().ToList();
var found = theElements.Where(x => x.node.guid == node.guid).ToList();
foreach (var drawableNodeData in found)
drawableNodeData.OnModified(scope);
}
// We might need to do something here
// if (scope == ModificationScope.Topological)
}
public virtual void Initialize(IGraph graph, IMaterialGraphEditWindow container, PreviewSystem previewSystem)
{
m_PreviewSystem = previewSystem;
this.graph = graph;
if (graph == null)
return;
foreach (var node in graph.GetNodes<INode>())
NodeAdded(new NodeAddedGraphChange(node));
foreach (var edge in graph.edges)
EdgeAdded(new EdgeAddedGraphChange(edge));
this.graph.onChange += OnChange;
}
void OnChange(GraphChange change)
{
change.Match(NodeAdded, NodeRemoved, EdgeAdded, EdgeRemoved);
}
void NodeAdded(NodeAddedGraphChange change)
{
var nodePresenter = CreateInstance<MaterialNodePresenter>();
change.node.onModified += OnNodeChanged;
nodePresenter.Initialize(change.node, m_PreviewSystem);
m_Elements.Add(nodePresenter);
}
void NodeRemoved(NodeRemovedGraphChange change)
{
change.node.onModified -= OnNodeChanged;
var nodePresenter = m_Elements.OfType<MaterialNodePresenter>().FirstOrDefault(p => p.node.guid == change.node.guid);
if (nodePresenter != null)
m_Elements.Remove(nodePresenter);
}
void EdgeAdded(EdgeAddedGraphChange change)
{
var edge = change.edge;
var sourceNode = graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);
var sourceSlot = sourceNode.FindOutputSlot<ISlot>(edge.outputSlot.slotId);
var sourceNodePresenter = m_Elements.OfType<MaterialNodePresenter>().FirstOrDefault(x => x.node == sourceNode);
var sourceAnchorPresenter = sourceNodePresenter.outputAnchors.OfType<GraphAnchorPresenter>().FirstOrDefault(x => x.slot.Equals(sourceSlot));
var targetNode = graph.GetNodeFromGuid(edge.inputSlot.nodeGuid);
var targetSlot = targetNode.FindInputSlot<ISlot>(edge.inputSlot.slotId);
var targetNodePresenter = m_Elements.OfType<MaterialNodePresenter>().FirstOrDefault(x => x.node == targetNode);
var targetAnchor = targetNodePresenter.inputAnchors.OfType<GraphAnchorPresenter>().FirstOrDefault(x => x.slot.Equals(targetSlot));
var edgePresenter = CreateInstance<GraphEdgePresenter>();
edgePresenter.Initialize(edge);
edgePresenter.output = sourceAnchorPresenter;
edgePresenter.output.Connect(edgePresenter);
edgePresenter.input = targetAnchor;
edgePresenter.input.Connect(edgePresenter);
m_Elements.Add(edgePresenter);
}
void EdgeRemoved(EdgeRemovedGraphChange change)
{
var edgePresenter = m_Elements.OfType<GraphEdgePresenter>().FirstOrDefault(p => p.edge == change.edge);
if (edgePresenter != null)
{
edgePresenter.output.Disconnect(edgePresenter);
edgePresenter.input.Disconnect(edgePresenter);
m_Elements.Remove(edgePresenter);
}
}
public void AddNode(INode node)
{
graph.owner.RegisterCompleteObjectUndo("Add " + node.name);
graph.AddNode(node);
}
public void RemoveElements(IEnumerable<MaterialNodePresenter> nodes, IEnumerable<GraphEdgePresenter> edges)
{
graph.RemoveElements(nodes.Select(x => x.node as INode), edges.Select(x => x.edge));
graph.ValidateGraph();
}
public void Connect(GraphAnchorPresenter left, GraphAnchorPresenter right)
{
if (left != null && right != null)
{
graph.owner.RegisterCompleteObjectUndo("Connect Edge");
graph.Connect(left.slot.slotReference, right.slot.slotReference);
}
}
internal static CopyPasteGraph CreateCopyPasteGraph(IEnumerable<GraphElementPresenter> selection)
{
var graph = new CopyPasteGraph();
foreach (var presenter in selection)
{
var nodePresenter = presenter as MaterialNodePresenter;
if (nodePresenter != null)
{
graph.AddNode(nodePresenter.node);
foreach (var edge in NodeUtils.GetAllEdges(nodePresenter.node))
graph.AddEdge(edge);
}
var edgePresenter = presenter as GraphEdgePresenter;
if (edgePresenter != null)
graph.AddEdge(edgePresenter.edge);
}
return graph;
}
internal static CopyPasteGraph DeserializeCopyBuffer(string copyBuffer)
{
try
{
return JsonUtility.FromJson<CopyPasteGraph>(copyBuffer);
}
catch
{
// ignored. just means copy buffer was not a graph :(
return null;
}
}
void InsertCopyPasteGraph(CopyPasteGraph copyGraph)
{
if (copyGraph == null || graph == null)
return;
var addedNodes = new List<INode>();
var nodeGuidMap = new Dictionary<Guid, Guid>();
foreach (var node in copyGraph.GetNodes<INode>())
{
var oldGuid = node.guid;
var newGuid = node.RewriteGuid();
nodeGuidMap[oldGuid] = newGuid;
var drawState = node.drawState;
var position = drawState.position;
position.x += 30;
position.y += 30;
drawState.position = position;
node.drawState = drawState;
graph.AddNode(node);
addedNodes.Add(node);
}
// only connect edges within pasted elements, discard
// external edges.
foreach (var edge in copyGraph.edges)
{
var outputSlot = edge.outputSlot;
var inputSlot = edge.inputSlot;
Guid remappedOutputNodeGuid;
Guid remappedInputNodeGuid;
if (nodeGuidMap.TryGetValue(outputSlot.nodeGuid, out remappedOutputNodeGuid)
&& nodeGuidMap.TryGetValue(inputSlot.nodeGuid, out remappedInputNodeGuid))
{
var outputSlotRef = new SlotReference(remappedOutputNodeGuid, outputSlot.slotId);
var inputSlotRef = new SlotReference(remappedInputNodeGuid, inputSlot.slotId);
graph.Connect(outputSlotRef, inputSlotRef);
}
}
graph.ValidateGraph();
if (onSelectionChanged != null)
onSelectionChanged(addedNodes);
}
public bool canCopy
{
get { return elements.Any(e => e.selected); }
}
public void Copy()
{
var graph = CreateCopyPasteGraph(elements.Where(e => e.selected));
EditorGUIUtility.systemCopyBuffer = JsonUtility.ToJson(graph, true);
}
public bool canCut
{
get { return canCopy; }
}
public void Cut()
{
Copy();
graph.owner.RegisterCompleteObjectUndo("Cut");
RemoveElements(elements.OfType<MaterialNodePresenter>().Where(e => e.selected), elements.OfType<GraphEdgePresenter>().Where(e => e.selected));
}
public bool canPaste
{
get { return DeserializeCopyBuffer(EditorGUIUtility.systemCopyBuffer) != null; }
}
public void Paste()
{
var pastedGraph = DeserializeCopyBuffer(EditorGUIUtility.systemCopyBuffer);
graph.owner.RegisterCompleteObjectUndo("Paste");
InsertCopyPasteGraph(pastedGraph);
}
public bool canDuplicate
{
get { return canCopy; }
}
public void Duplicate()
{
var deserializedGraph = DeserializeCopyBuffer(JsonUtility.ToJson(CreateCopyPasteGraph(elements.Where(e => e.selected)), true));
graph.owner.RegisterCompleteObjectUndo("Duplicate");
InsertCopyPasteGraph(deserializedGraph);
}
public bool canDelete
{
get { return canCopy; }
}
public void Delete()
{
graph.owner.RegisterCompleteObjectUndo("Delete");
RemoveElements(elements.OfType<MaterialNodePresenter>().Where(e => e.selected), elements.OfType<GraphEdgePresenter>().Where(e => e.selected));
}
public override void AddElement(EdgePresenter edge)
{
Connect(edge.output as GraphAnchorPresenter, edge.input as GraphAnchorPresenter);
}
public delegate void OnSelectionChanged(IEnumerable<INode> presenters);
public OnSelectionChanged onSelectionChanged;
public void UpdateSelection(IEnumerable<MaterialNodePresenter> presenters)
{
if (graph == null)
return;
if (onSelectionChanged != null)
onSelectionChanged(presenters.Select(x => x.node as INode));
}
public override void AddElement(GraphElementPresenter element)
{
throw new ArgumentException("Not supported on Serializable Graph, data comes from data store");
}
public override void RemoveElement(GraphElementPresenter element)
{
throw new ArgumentException("Not supported on Serializable Graph, data comes from data store");
}
}
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs.orig.meta


fileFormatVersion: 2
guid: bc4af21039c3d6b44a2ed6820e5c23ce
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes.meta


fileFormatVersion: 2
guid: 7e4695133ddd49cf97b1629ca5537e5b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
MaterialGraphProject/Assets/UnityShaderEditor/Runtime.meta


fileFormatVersion: 2
guid: c196fa3d7b5ae4049afeb1cd0400d9b6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

42
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class SubgraphIONodeControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var ioNode = node as SubGraphOutputNode;
if (ioNode == null)
return;
if (GUILayout.Button("Add Slot"))
ioNode.AddSlot();
if (GUILayout.Button("Remove Slot"))
ioNode.RemoveSlot();
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class SubgraphIONodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<SubgraphIONodeControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs.meta


fileFormatVersion: 2
guid: b8c4dd0c197664d5ebf80f433981c6b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

153
MaterialGraphProject/Assets/fresnelstuff.ShaderSubGraph


{
"m_SerializableNodes": [
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.SubGraphInputNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"fee15ca4-2990-4a82-819a-e7c1cc065b84\",\n \"m_Name\": \"SubGraphInputs\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": 0.0,\n \"y\": 0.0,\n \"width\": 0.0,\n \"height\": 0.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": -1,\\n \\\"m_DisplayName\\\": \\\"Input 1\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Input1\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.SubGraphOutputNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"0af42f22-ed9f-46b9-bb7a-0ebb795ab356\",\n \"m_Name\": \"SubGraphOutputs\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": 0.0,\n \"y\": 0.0,\n \"width\": 0.0,\n \"height\": 0.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"Output 1\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Output1\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.CamDirNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"527ef353-4a94-4a32-a911-4578a7a7357d\",\n \"m_Name\": \"CameraDirection\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2806.62744140625,\n \"y\": 547.4772338867188,\n \"width\": 304.0,\n \"height\": 258.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Output\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Output\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.WorldSpaceNormalNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ab1fea28-c9be-4835-8e64-9fab4f96ab28\",\n \"m_Name\": \"WorldNormal\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2806.63818359375,\n \"y\": 827.5852661132813,\n \"width\": 308.0,\n \"height\": 258.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Normal\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 7,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 1.0,\\n \\\"w\\\": 1.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 1.0,\\n \\\"w\\\": 1.0\\n },\\n \\\"m_ConcreteValueType\\\": 6,\\n \\\"m_ShaderOutputName\\\": \\\"Normal\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.DotNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\",\n \"m_Name\": \"DotProduct\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2426.489501953125,\n \"y\": 736.7769165039063,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 7,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 6,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 7,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 6,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.SubtractNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"b6e0606d-0952-49e8-8d46-cebb582d47c1\",\n \"m_Name\": \"Subtract\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2075.592529296875,\n \"y\": 739.856201171875,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 1.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.PowerNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\",\n \"m_Name\": \"Power\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -1690.9185791015625,\n \"y\": 960.6397705078125,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 3.1700000762939455,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.MultiplyNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\",\n \"m_Name\": \"Multiply\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2013.73779296875,\n \"y\": 1107.570068359375,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.TimeNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ab5b6501-3879-40aa-9597-55a1403fac4c\",\n \"m_Name\": \"Time\",\n \"m_DrawState\": {\n \"m_Expanded\": false,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -3085.012939453125,\n \"y\": 1369.556640625,\n \"width\": 313.0,\n \"height\": 142.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Time\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Time\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"Time/20\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time/20\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"Time\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"Time * 2\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time * 2\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\": \\\"Time * 3\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time * 3\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.SinNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"5c3aacb1-762e-4e14-a4db-8dcc4848ca6f\",\n \"m_Name\": \"Sin\",\n \"m_DrawState\": {\n \"m_Expanded\": false,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2718.04931640625,\n \"y\": 1334.964111328125,\n \"width\": 297.0,\n \"height\": 88.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"argument\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"argument\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.MaterialGraph.AddNode",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_GuidSerialized\": \"c099bbe1-c642-4cb3-a7bf-daea22f9b1aa\",\n \"m_Name\": \"Add\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2344.2314453125,\n \"y\": 1313.0528564453125,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 1.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 2.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}"
}
],
"m_SerializableEdges": [
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"527ef353-4a94-4a32-a911-4578a7a7357d\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"ab1fea28-c9be-4835-8e64-9fab4f96ab28\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"b6e0606d-0952-49e8-8d46-cebb582d47c1\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"b6e0606d-0952-49e8-8d46-cebb582d47c1\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"c099bbe1-c642-4cb3-a7bf-daea22f9b1aa\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 3,\n \"m_NodeGUIDSerialized\": \"ab5b6501-3879-40aa-9597-55a1403fac4c\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"5c3aacb1-762e-4e14-a4db-8dcc4848ca6f\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"5c3aacb1-762e-4e14-a4db-8dcc4848ca6f\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"c099bbe1-c642-4cb3-a7bf-daea22f9b1aa\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": -1,\n \"m_NodeGUIDSerialized\": \"fee15ca4-2990-4a82-819a-e7c1cc065b84\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\"\n }\n}"
},
{
"typeInfo": {
"fullName": "UnityEngine.Graphing.Edge",
"assemblyName": "Assembly-CSharp"
},
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"0af42f22-ed9f-46b9-bb7a-0ebb795ab356\"\n }\n}"
}
]
}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存