浏览代码

Merge pull request #2 from stramit/NewUI

New ui
/main
GitHub 8 年前
当前提交
dc7e686b
共有 385 个文件被更改,包括 2394 次插入1042 次删除
  1. 2
      .gitignore
  2. 10
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/CopySelected.cs
  3. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DeleteSelected.cs
  4. 430
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/GraphEditWindow.cs
  5. 11
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NullInputProxy.cs
  6. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs.meta
  7. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/UnitTests/SerializedGraphTests.cs
  8. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableNode.cs
  9. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/IGraph.cs
  10. 22
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/INode.cs
  11. 13
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  12. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/2DPreview.template
  13. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/shader.template
  14. 40
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/PropertyNodeTests.cs
  15. 28
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs
  16. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs
  17. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function1InputTests.cs
  18. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function2InputTests.cs
  19. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function3InputTests.cs
  20. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs
  21. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
  22. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialSlotTests.cs
  23. 41
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs
  24. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyGeneratorTests.cs
  25. 41
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs
  26. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/ShaderGeneratorTests.cs
  27. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
  28. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialOptions.cs
  29. 58
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/PixelGraph.cs
  30. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Interfaces/Interfaces.cs
  31. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/BlendNode.cs
  32. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ColorNode.cs
  33. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/CombineNode.cs
  34. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/DivNode.cs
  35. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/FunctionMultiInput.cs
  36. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/LengthNode.cs
  37. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/LerpNode.cs
  38. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MultiplyNode.cs
  39. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/NormalNode.cs
  40. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/NormalizeNode.cs
  41. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PowerNode.cs
  42. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
  43. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/QuantizeNode.cs
  44. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ScreenPosNode.cs
  45. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SinNode.cs
  46. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SmoothStepNode.cs
  47. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SubtractNode.cs
  48. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SwizzleNode.cs
  49. 49
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/TextureNode.cs
  50. 29
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UVNode.cs
  51. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector1Node.cs
  52. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector2Node.cs
  53. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector3Node.cs
  54. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector4Node.cs
  55. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ViewDirectionNode.cs
  56. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/WorldPosNode.cs
  57. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraph.cs
  58. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs
  59. 24
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs
  60. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyGenerator.cs
  61. 231
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs
  62. 2
      MaterialGraphProject/ProjectSettings/ProjectVersion.txt
  63. 120
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodePreviewDrawData.cs
  64. 110
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs
  65. 244
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs
  66. 315
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  67. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs.meta
  68. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/COPIED.meta
  69. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData.meta
  70. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer.meta
  71. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators.meta
  72. 44
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs
  73. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs.meta
  74. 15
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs
  75. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs.meta
  76. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles.meta
  77. 25
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/UIUtilities.cs
  78. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/UIUtilities.cs.meta
  79. 9
      MaterialGraphProject/Assets/NewUI.meta
  80. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer.meta
  81. 164
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs
  82. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs.meta
  83. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles.meta
  84. 295
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/New Shader Graph.ShaderGraph
  85. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/New Shader Graph.ShaderGraph.meta
  86. 300
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/blah.ShaderGraph
  87. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/blah.ShaderGraph.meta
  88. 271
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/new.ShaderGraph
  89. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/new.ShaderGraph.meta
  90. 36
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/something.ShaderGraph
  91. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/something.ShaderGraph.meta

2
.gitignore


MaterialGraphProject/.vs
MaterialGraphProject/.vscode
MaterialGraphProject/MaterialGraphProject.userprefs

10
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/CopySelected.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Experimental;
using UnityEngine;
using UnityEngine.Graphing;
/*
namespace UnityEditor.Graphing.Drawing
{
[Serializable]

parent.Repaint();
}
}
}
}*/

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DeleteSelected.cs


using System.Collections.Generic;
using UnityEditor.Experimental;
/*using System.Collections.Generic;
using UnityEngine;
namespace UnityEditor.Graphing.Drawing

}
}
}
*/

430
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/GraphEditWindow.cs


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor.Experimental;
using UnityEditor.MaterialGraph;
using UnityEngine;
using UnityEngine.MaterialGraph;
using Object = UnityEngine.Object;
namespace UnityEditor.Graphing.Drawing
{

public static void OpenMenu()
{
GetWindow<GraphEditWindow>();
}
}
public abstract class AbstractGraphEditWindow<T> : EditorWindow, ISerializationCallbackReceiver where T : class, IGraphAsset
{
public RenderTexture rt;
[NonSerialized]
private T m_LastSelection;
[SerializeField]
private ScriptableObject m_LastSelectedGraphSerialized;
[NonSerialized]
private Canvas2D m_Canvas;
[NonSerialized]
private EditorWindow m_HostWindow;
[NonSerialized]
private GraphDataSource m_DataSource;
private bool shouldRepaint
{
get
{
return m_LastSelection != null && m_LastSelection.shouldRepaint;
}
}
void Update()
{
if (shouldRepaint)
Repaint();
}
void OnSelectionChange()
{
if (Selection.activeObject == null || !EditorUtility.IsPersistent(Selection.activeObject))
return;
if (Selection.activeObject is ScriptableObject)
{
var selection = Selection.activeObject as T;
if (selection != m_LastSelection)
{
var graph = selection.graph;
graph.OnEnable();
graph.ValidateGraph();
m_LastSelection = selection;
Rebuild();
Repaint();
}
}
}
private void InitializeCanvas()
{
if (m_Canvas == null)
{
m_DataSource = new GraphDataSource();
m_Canvas = new Canvas2D(this, m_HostWindow, m_DataSource);
// draggable manipulator allows to move the canvas around. Note that individual elements can have the draggable manipulator on themselves
m_Canvas.AddManipulator(new Draggable(2, EventModifiers.None));
m_Canvas.AddManipulator(new Draggable(0, EventModifiers.Alt));
// make the canvas zoomable
m_Canvas.AddManipulator(new Zoomable());
// allow framing the selection when hitting "F" (frame) or "A" (all). Basically shows how to trap a key and work with the canvas selection
m_Canvas.AddManipulator(new Frame(Frame.FrameType.All));
m_Canvas.AddManipulator(new Frame(Frame.FrameType.Selection));
// The following manipulator show how to work with canvas2d overlay and background rendering
m_Canvas.AddManipulator(new RectangleSelect());
m_Canvas.AddManipulator(new ScreenSpaceGrid());
m_Canvas.AddManipulator(new ContextualMenu(DoContextMenu));
m_Canvas.AddManipulator(new DeleteSelected(m_DataSource.DeleteElements));
m_Canvas.AddManipulator(new CopySelected());
}
Rebuild();
}
private class AddNodeCreationObject : object
{
public Vector2 m_Pos;
public readonly Type m_Type;
public AddNodeCreationObject(Type t, Vector2 p) { m_Type = t; m_Pos = p; }
};
private void AddNode(object obj)
{
var posObj = obj as AddNodeCreationObject;
if (posObj == null)
return;
INode node;
try
{
node = Activator.CreateInstance(posObj.m_Type) as INode;
}
catch (Exception e)
{
Debug.LogWarningFormat("Could not construct instance of: {0} - {1}", posObj.m_Type, e);
return;
}
if (node == null)
return;
var drawstate = node.drawState;
drawstate.position = new Rect(posObj.m_Pos.x, posObj.m_Pos.y, drawstate.position.width, drawstate.position.height);
node.drawState = drawstate;
m_DataSource.Addnode(node);
Rebuild();
Repaint();
}
public virtual bool CanAddToNodeMenu(Type type) { return true; }
protected bool DoContextMenu(Event @event, Canvas2D parent, Object customData)
{
var gm = new GenericMenu();
foreach (Type type in Assembly.GetAssembly(typeof(AbstractMaterialNode)).GetTypes())
{
if (type.IsClass && !type.IsAbstract && (type.IsSubclassOf(typeof(AbstractMaterialNode))))
{
var attrs = type.GetCustomAttributes(typeof(TitleAttribute), false) as TitleAttribute[];
if (attrs != null && attrs.Length > 0 && CanAddToNodeMenu(type))
{
gm.AddItem(new GUIContent(attrs[0].m_Title), false, AddNode, new AddNodeCreationObject(type, parent.MouseToCanvas(@event.mousePosition)));
}
}
}
//gm.AddSeparator("");
// gm.AddItem(new GUIContent("Convert To/SubGraph"), true, ConvertSelectionToSubGraph);
gm.ShowAsContext();
return true;
}
private void ConvertSelectionToSubGraph()
{
if (m_Canvas.dataSource == null)
return;
var dataSource = m_Canvas.dataSource as GraphDataSource;
if (dataSource == null)
return;
var asset = dataSource.graphAsset;
if (asset == null)
return;
var targetGraph = asset.graph;
if (targetGraph == null)
return;
if (!m_Canvas.selection.Any())
return;
var serialzied = CopySelected.SerializeSelectedElements(m_Canvas);
var deserialized = CopySelected.DeserializeSelectedElements(serialzied);
if (deserialized == null)
return;
string path = EditorUtility.SaveFilePanelInProject("Save subgraph", "New SubGraph", "ShaderSubGraph", "");
path = path.Replace(Application.dataPath, "Assets");
if (path.Length == 0)
return;
var graphAsset = CreateInstance<MaterialSubGraphAsset>();
graphAsset.name = Path.GetFileName(path);
graphAsset.PostCreate();
var graph = graphAsset.subGraph;
if (graphAsset.graph == null)
return;
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 inputEdgeNeedsRemap = new List<IEdge>();
var outputEdgeNeedsRemap = 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)
{
inputEdgeNeedsRemap.Add(edge);
}
else if (inputRemapExists)
{
outputEdgeNeedsRemap.Add(edge);
}
}
// we do a grouping here as the same output can
// point to multiple inputs
var uniqueOutputs = outputEdgeNeedsRemap.GroupBy(edge => edge.outputSlot);
var inputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>();
foreach (var group in uniqueOutputs)
{
var inputNode = graph.inputNode;
var slotId = inputNode.AddSlot();
var outputSlotRef = new SlotReference(inputNode.guid, slotId);
foreach (var edge in group)
{
var newEdge = graph.Connect(outputSlotRef, new SlotReference(nodeGuidMap[edge.inputSlot.nodeGuid], edge.inputSlot.slotId));
inputsNeedingConnection.Add(new KeyValuePair<IEdge, IEdge>(edge, newEdge));
}
}
var uniqueInputs = inputEdgeNeedsRemap.GroupBy(edge => edge.inputSlot);
var outputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>();
foreach (var group in uniqueInputs)
{
var outputNode = graph.outputNode;
var slotId = outputNode.AddSlot();
var inputSlotRef = new SlotReference(outputNode.guid, slotId);
foreach (var edge in group)
{
var newEdge = graph.Connect(new SlotReference(nodeGuidMap[edge.outputSlot.nodeGuid], edge.outputSlot.slotId), inputSlotRef);
outputsNeedingConnection.Add(new KeyValuePair<IEdge, IEdge>(edge, newEdge));
}
}
AssetDatabase.CreateAsset(graphAsset, path);
var subGraphNode = new SubGraphNode();
targetGraph.AddNode(subGraphNode);
subGraphNode.subGraphAsset = graphAsset;
foreach (var edgeMap in inputsNeedingConnection)
{
targetGraph.Connect(edgeMap.Key.outputSlot, new SlotReference(subGraphNode.guid, edgeMap.Value.outputSlot.slotId));
}
foreach (var edgeMap in outputsNeedingConnection)
{
targetGraph.Connect(new SlotReference(subGraphNode.guid, edgeMap.Value.inputSlot.slotId), edgeMap.Key.inputSlot);
}
var toDelete = m_Canvas.selection.Where(x => x is DrawableNode).ToList();
dataSource.DeleteElements(toDelete);
targetGraph.ValidateGraph();
m_Canvas.ReloadData();
m_Canvas.Invalidate();
m_Canvas.selection.Clear();
var toSelect = m_Canvas.elements.OfType<DrawableNode>().FirstOrDefault(x => x.m_Node == subGraphNode);
if (toSelect != null)
{
toSelect.selected = true;
m_Canvas.selection.Add(toSelect);
}
m_Canvas.Repaint();
}
private void Rebuild()
{
if (m_Canvas == null || m_LastSelection == null)
return;
m_DataSource.graphAsset = m_LastSelection;
m_Canvas.ReloadData();
}
void OnGUI()
{
m_HostWindow = this;
if (m_Canvas == null)
{
InitializeCanvas();
}
if (m_LastSelection == null || m_LastSelection.graph == null)
{
GUILayout.Label("No Graph selected");
return;
}
m_Canvas.OnGUI(this, new Rect(0, 0, position.width - 250, position.height));
if (GUI.Button(new Rect(position.width - 250, 0, 250, 50), "Convert to Sub-Graph"))
ConvertSelectionToSubGraph();
if (GUI.Button(new Rect(position.width - 250, 70, 250, 50), "Export"))
Export(false);
if (GUI.Button(new Rect(position.width - 250, 140, 250, 50), "Export - quick"))
Export(true);
EditorGUI.ObjectField(new Rect(position.width - 250, 210, 250, 50), rt, typeof(RenderTexture), false);
}
private string m_LastPath;
public void Export(bool quickExport)
{
var path = quickExport ? m_LastPath : EditorUtility.SaveFilePanelInProject("Export shader to file...", "shader.shader", "shader", "Enter file name");
m_LastPath = path; // For quick exporting
if (!string.IsNullOrEmpty(path))
ExportShader(m_DataSource.graphAsset as MaterialGraphAsset, path);
else
EditorUtility.DisplayDialog("Export Shader Error", "Cannot export shader", "Ok");
}
public static Shader ExportShader(MaterialGraphAsset graphAsset, string path)
{
if (graphAsset == null)
return null;
var materialGraph = graphAsset.graph as PixelGraph;
if (materialGraph == null)
return null;
List<PropertyGenerator.TextureInfo> configuredTextures;
var shaderString = ShaderGenerator.GenerateSurfaceShader(materialGraph.pixelMasterNode, new MaterialOptions(), materialGraph.name, false, out configuredTextures);
File.WriteAllText(path, shaderString);
AssetDatabase.Refresh(); // Investigate if this is optimal
var shader = AssetDatabase.LoadAssetAtPath(path, typeof(Shader)) as Shader;
if (shader == null)
return null;
var shaderImporter = AssetImporter.GetAtPath(path) as ShaderImporter;
if (shaderImporter == null)
return null;
var textureNames = new List<string>();
var textures = new List<Texture>();
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable == TexturePropertyChunk.ModifiableState.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 == TexturePropertyChunk.ModifiableState.NonModifiable))
{
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());
shaderImporter.SaveAndReimport();
return shaderImporter.GetShader();
}
/*public void RenderOptions(MaterialGraph graph)
{
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.BeginVertical();
m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, EditorStyles.textArea, GUILayout.width(250), GUILayout.ExpandHeight(true));
graph.materialOptions.DoGUI();
EditorGUILayout.Separator();
m_NodeExpanded = MaterialGraphStyles.Header("Selected", m_NodeExpanded);
if (m_NodeExpanded)
DrawableMaterialNode.OnGUI(m_Canvas.selection);
GUILayout.EndScrollView();
if (GUILayout.Button("Export"))
m_DataSource.Export(false);
GUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
}*/
public void OnBeforeSerialize()
{
var o = m_LastSelection as ScriptableObject;
if (o != null)
m_LastSelectedGraphSerialized = o;
}
public void OnAfterDeserialize()
{
if (m_LastSelectedGraphSerialized != null)
m_LastSelection = m_LastSelectedGraphSerialized as T;
m_LastSelectedGraphSerialized = null;
}
}
}

11
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NullInputProxy.cs


using UnityEditor.Experimental;
using UnityEngine;
using UnityEngine.Graphing;
/*
namespace UnityEditor.Graphing.Drawing
{
public class NullInputProxy : CanvasElement

//TODO: FIX
/*var changed = m_Node.DrawSlotDefaultInput(rect, m_InputSlot);
if (changed)
DrawableMaterialNode.RepaintDependentNodes(m_Node);*/
DrawableMaterialNode.RepaintDependentNodes(m_Node);*
}
public override void UpdateModel(UpdateType t)

base.UpdateModel(t);
}
}
}
}*/

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs.meta


fileFormatVersion: 2
guid: 194f855484623804c819a9132a24268f
timeCreated: 1445419780
timeCreated: 1476707366
licenseType: Pro
MonoImporter:
serializedVersion: 2

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/UnitTests/SerializedGraphTests.cs


node.name = "Test Node";
var drawState = node.drawState;
var newPos = new Rect(10, 10, 10, 10);
var newPos = new Rect(10, 10, 0, 0);
drawState.position = newPos;
drawState.expanded = false;
node.drawState = drawState;

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableNode.cs


public DrawingData drawState
{
get { return m_DrawData; }
set { m_DrawData = value; }
set
{
m_DrawData = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public virtual bool hasError { get; protected set; }

public virtual void ValidateNode()
{}
public OnNodeModified onModified { get; set; }
public IEnumerable<T> GetInputSlots<T>() where T : ISlot
{

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/IGraph.cs


{
public interface IGraph : IOnAssetEnabled
{
IEnumerable<T> GetNodes<T>() where T: INode;
IEnumerable<T> GetNodes<T>() where T : INode;
IEnumerable<IEdge> edges { get; }
void AddNode(INode node);
void RemoveNode(INode node);

INode GetNodeFromGuid(Guid guid);
T GetNodeFromGuid<T>(Guid guid) where T: INode;
T GetNodeFromGuid<T>(Guid guid) where T : INode;
IEnumerable<IEdge> GetEdges(SlotReference s);
void ValidateGraph();
}

22
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/INode.cs


namespace UnityEngine.Graphing
{
public enum ModificationScope
{
Nothing,
Node,
Graph
}
public delegate void OnNodeModified(INode node, ModificationScope scope);
OnNodeModified onModified { get; set; }
IEnumerable<T> GetInputSlots<T>() where T: ISlot;
IEnumerable<T> GetOutputSlots<T>() where T: ISlot;
IEnumerable<T> GetSlots<T>() where T: ISlot;
IEnumerable<T> GetInputSlots<T>() where T : ISlot;
IEnumerable<T> GetOutputSlots<T>() where T : ISlot;
IEnumerable<T> GetSlots<T>() where T : ISlot;
T FindSlot<T>(int slotId) where T: ISlot;
T FindInputSlot<T>(int slotId) where T: ISlot;
T FindOutputSlot<T>(int slotId) where T: ISlot;
T FindSlot<T>(int slotId) where T : ISlot;
T FindInputSlot<T>(int slotId) where T : ISlot;
T FindOutputSlot<T>(int slotId) where T : ISlot;
IEnumerable<ISlot> GetInputsWithNoConnection();
DrawingData drawState { get; set; }
bool hasError { get; }

13
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


using RMGUI.GraphView;
namespace UnityEditor.MaterialGraph
namespace UnityEditor.MaterialGraph.Drawing
{
public class MaterialGraphEditWindow : AbstractGraphEditWindow<IMaterialGraphAsset>
{

GetWindow<MaterialGraphEditWindow>();
}
public override AbstractGraphDataSource CreateDataSource()
{
return CreateInstance<MaterialGraphDataSource>();
}
public override GraphView CreateGraphView()
{
return new MaterialGraphView();
}
}
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/2DPreview.template


}
SubShader {
Blend One Zero
Pass {
CGPROGRAM
#pragma vertex vert

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/shader.template


#pragma glsl
#pragma debug
${LightingFunction}
${ShaderFunctions}
${ShaderPropertyUsages}

40
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/PropertyNodeTests.cs


namespace UnityEditor.MaterialGraph.IntegrationTests
{
[TestFixtureSetUp]
public void RunBeforeAnyTests()
{

"IntegrationTests",
"Textures",
"MudDiffuse.tif"
};
private static Texture2D FindTestTexture()

m_TextureNode.textureType = TextureType.Bump;
m_TextureNode.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new PropertyGenerator();
m_TextureNode.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_TextureNode.GeneratePropertyBlock(generator, GenerationMode.ForReals);
+ m_TextureNode.propertyName
+ "(\""
+ m_TextureNode.description
+ "\", 2D) = \"bump\" {}"
+ Environment.NewLine;
+ m_TextureNode.propertyName
+ "(\""
+ m_TextureNode.description
+ "\", 2D) = \"bump\" {}"
+ Environment.NewLine;
+ "(\""
+ m_TextureNode.description
+ "\", 2D) = \"bump\" {}"
+ Environment.NewLine;
+ "(\""
+ m_TextureNode.description
+ "\", 2D) = \"bump\" {}"
+ Environment.NewLine;
m_TextureNode.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_TextureNode.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(expected2, generator.GetShaderString(0));
}

m_TextureNode.defaultTexture = null;
m_TextureNode.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new ShaderGenerator();
m_TextureNode.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_TextureNode.GeneratePropertyUsages(generator, GenerationMode.ForReals);
+ m_TextureNode.propertyName
+ ";"
+ Environment.NewLine;
+ m_TextureNode.propertyName
+ ";"
+ Environment.NewLine;
m_TextureNode.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_TextureNode.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}
}

28
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs


using System.IO;
using System.Linq;
using NUnit.Framework;
using UnityEditor.Graphing.Drawing;
using UnityEditor.MaterialGraph.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
using Object = UnityEngine.Object;

foreach (var p in filePaths)
{
yield return new TestInfo
{
name = p.Name,
info = p,
threshold = 0.02f
};
{
name = p.Name,
info = p,
threshold = 0.02f
};
private Shader m_Shader;
private Material m_PreviewMaterial;
private Texture2D m_Captured;

var graphAsset = AssetDatabase.LoadAssetAtPath<MaterialGraphAsset>(filePath);
Assert.IsNotNull(graphAsset, "Graph asset not found");
var shaderString = ShaderGenerator.GenerateSurfaceShader(materialGraph.pixelMasterNode, graphAsset.options, materialGraph.name, false, out configuredTextures);
var shaderString = materialGraph.masterNode.GetShader(graphAsset.options, GenerationMode.ForReals, out configuredTextures);
Assert.IsFalse(AbstractMaterialNodeUI.ShaderHasError(m_Shader), "Shader has error");
//Assert.IsFalse(AbstractMaterialNodeUI.ShaderHasError(m_Shader), "Shader has error");
m_PreviewMaterial = new Material(m_Shader)
{

const int res = 256;
var generator = new MaterialGraphPreviewGenerator();
var rendered = generator.DoRenderPreview(m_PreviewMaterial, PreviewMode.Preview3D, new Rect(0, 0, res, res), 10) as RenderTexture;
RenderTexture.active = null; //can help avoid errors
RenderTexture.active = null; //can help avoid errors
// find the reference image
var dumpFileLocation = Path.Combine(templatePath, string.Format("{0}.{1}", file.Name, "png"));
if (!File.Exists(dumpFileLocation))

}
var template = File.ReadAllBytes(dumpFileLocation);
m_FromDisk = new Texture2D(2,2);
m_FromDisk = new Texture2D(2, 2);
m_FromDisk.LoadImage(template, false);
var areEqual = CompareTextures(m_FromDisk, m_Captured, testInfo.threshold);

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


var graph = new PixelGraph();
Assert.AreEqual(0, graph.GetNodes<AbstractMaterialNode>().Count());
var psn = new PixelShaderNode();
var psn = new MetallicMasterNode();
Assert.IsInstanceOf(typeof(PixelShaderNode), graph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.IsNotNull(graph.pixelMasterNode);
Assert.AreEqual(1, graph.activeNodes.Count());
Assert.IsInstanceOf(typeof(MetallicMasterNode), graph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.IsNotNull(graph.masterNode);
Assert.AreEqual(1, graph.GetNodes<INode>().Count());
public void TestCanOnlyAddOnePixelShaderNode()
public void TestCanAddMultipleMasterNode()
var psn = new PixelShaderNode();
var psn = new MetallicMasterNode();
var psn2 = new PixelShaderNode();
var psn2 = new SpecularMasterNode();
Assert.AreEqual(1, graph.GetNodes<AbstractMaterialNode>().Count());
Assert.AreEqual(2, graph.GetNodes<AbstractMaterialNode>().Count());
}
}
}

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function1InputTests.cs


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

m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_TestNode);
m_Graph.AddNode(new PixelShaderNode());
m_Graph.AddNode(new MetallicMasterNode());
m_Graph.Connect(m_TestNode.GetSlotReference(Function1Input.OutputSlotId), m_Graph.pixelMasterNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_TestNode.GetSlotReference(Function1Input.OutputSlotId), m_Graph.masterNode.GetSlotReference(MetallicMasterNode.NormalSlotId));
}
[Test]

);
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeCode(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeCode(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}

+ "}" + Environment.NewLine;
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function2InputTests.cs


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

m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_InputTwo);
m_Graph.AddNode(m_TestNode);
m_Graph.AddNode(new PixelShaderNode());
m_Graph.AddNode(new MetallicMasterNode());
m_InputOne.value = 0.2f;
m_InputTwo.value = 0.3f;

m_Graph.Connect(m_TestNode.GetSlotReference(Function2Input.OutputSlotId), m_Graph.pixelMasterNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_TestNode.GetSlotReference(Function2Input.OutputSlotId), m_Graph.masterNode.GetSlotReference(MetallicMasterNode.NormalSlotId));
}
[Test]

);
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeCode(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeCode(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}

+ "}" + Environment.NewLine;
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}

+ "\t}" + Environment.NewLine;
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(1));
}
}

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function3InputTests.cs


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

m_Graph.AddNode(m_InputTwo);
m_Graph.AddNode(m_InputThree);
m_Graph.AddNode(m_TestNode);
m_Graph.AddNode(new PixelShaderNode());
m_Graph.AddNode(new MetallicMasterNode());
m_InputOne.value = 0.2f;
m_InputTwo.value = 0.3f;

m_Graph.Connect(m_InputTwo.GetSlotReference(Vector1Node.OutputSlotId), m_TestNode.GetSlotReference(Function3Input.InputSlot2Id));
m_Graph.Connect(m_InputThree.GetSlotReference(Vector1Node.OutputSlotId), m_TestNode.GetSlotReference(Function3Input.InputSlot3Id));
m_Graph.Connect(m_TestNode.GetSlotReference(Function3Input.OutputSlotId), m_Graph.pixelMasterNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_TestNode.GetSlotReference(Function3Input.OutputSlotId), m_Graph.masterNode.GetSlotReference(MetallicMasterNode.NormalSlotId));
}
[Test]

, Environment.NewLine);
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeCode(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeCode(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}

+ "}" + Environment.NewLine;
ShaderGenerator visitor = new ShaderGenerator();
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.SurfaceShader);
m_TestNode.GenerateNodeFunction(visitor, GenerationMode.ForReals);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs


graph.PostCreate();
Assert.AreEqual(1, graph.currentGraph.GetNodes<AbstractMaterialNode>().Count());
Assert.IsInstanceOf(typeof(PixelShaderNode), graph.currentGraph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.AreEqual(0, graph.currentGraph.GetNodes<AbstractMaterialNode>().Count());
}
}
}

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


string expected = string.Format("{0}", m_NodeA.GetVariableNameForSlot(TestNode.V1In));
var slot = m_NodeA.GetInputSlots<MaterialSlot>().FirstOrDefault();
var result = m_NodeA.GetSlotValue(slot.id, GenerationMode.Preview2D);
var result = m_NodeA.GetSlotValue(slot.id, GenerationMode.Preview);
Assert.AreEqual(expected, result);
}

string expected = string.Format("{0} {1};{2}", AbstractMaterialNode.OutputPrecision.@fixed, m_NodeA.GetVariableNameForSlot(TestNode.V1In), Environment.NewLine);
var visitor = new ShaderGenerator();
m_NodeA.precision = AbstractMaterialNode.OutputPrecision.@fixed;
m_NodeA.GeneratePropertyUsages(visitor, GenerationMode.Preview2D);
m_NodeA.GeneratePropertyUsages(visitor, GenerationMode.Preview);
m_NodeA.GeneratePropertyUsages(visitor, GenerationMode.Preview2D);
m_NodeA.GeneratePropertyUsages(visitor, GenerationMode.Preview);
m_NodeA.GeneratePropertyUsages(visitor, GenerationMode.Preview2D);
m_NodeA.GeneratePropertyUsages(visitor, GenerationMode.Preview);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}
}

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


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

var slot = m_NodeA.slot;
var visitor = new ShaderGenerator();
slot.GeneratePropertyUsages(visitor, GenerationMode.Preview2D);
slot.GeneratePropertyUsages(visitor, GenerationMode.Preview);
Assert.AreEqual(expected, visitor.GetShaderString(0));
}

string expected = string.Format("{0}", m_NodeA.GetVariableNameForSlot(TestNode.V1In));
var slot = m_NodeA.slot;
var result = slot.GetDefaultValue(GenerationMode.Preview2D);
var result = slot.GetDefaultValue(GenerationMode.Preview);
result = slot.GetDefaultValue(GenerationMode.SurfaceShader);
result = slot.GetDefaultValue(GenerationMode.ForReals);
result = slot.GetDefaultValue(GenerationMode.SurfaceShader);
result = slot.GetDefaultValue(GenerationMode.ForReals);
result = slot.GetDefaultValue(GenerationMode.SurfaceShader);
result = slot.GetDefaultValue(GenerationMode.ForReals);
result = slot.GetDefaultValue(GenerationMode.SurfaceShader);
result = slot.GetDefaultValue(GenerationMode.ForReals);
Assert.AreEqual("half4 (6,6,6,1)", result);
}

var slot = new MaterialSlot(0, string.Empty, string.Empty, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
Assert.Throws<Exception>(() => slot.GeneratePropertyUsages(new ShaderGenerator(), GenerationMode.Preview2D));
Assert.Throws<Exception>(() => slot.GetDefaultValue(GenerationMode.Preview2D));
Assert.Throws<Exception>(() => slot.GeneratePropertyUsages(new ShaderGenerator(), GenerationMode.Preview));
Assert.Throws<Exception>(() => slot.GetDefaultValue(GenerationMode.Preview));
}
}
}

41
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs


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

private PixelGraph m_Graph;
private Vector1Node m_InputOne;
private AbsoluteNode m_Abs;
private PixelShaderNode m_PixelNode;
private MetallicMasterNode m_PixelNode;
[TestFixtureSetUp]
public void RunBeforeAnyTests()

public void TestSetUp()
{
m_Graph = new PixelGraph();
m_PixelNode = new MetallicMasterNode();
m_PixelNode = new PixelShaderNode();
m_PixelNode.lightFunction = new PBRMetalicLightFunction();
m_Graph.AddNode(m_PixelNode);
m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_PixelNode);
m_Graph.AddNode(m_Abs);

m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_PixelNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.NormalSlotId));
m_Graph.Connect(m_Abs.GetSlotReference(Function1Input.OutputSlotId), m_PixelNode.GetSlotReference(PBRMetalicLightFunction.AlbedoSlotId));
m_Graph.Connect(m_Abs.GetSlotReference(Function1Input.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.AlbedoSlotId));
[Test]
public void TestNodeGeneratesLightFuntionProperly()
{
var generator = new ShaderGenerator();
m_PixelNode.GenerateLightFunction(generator);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
Assert.AreEqual(PBRMetalicLightFunction.LightFunctionName, generator.GetPragmaString());
}
[Test]
public void TestNodeGenerateSurfaceOutputProperly()
{
var generator = new ShaderGenerator();
m_PixelNode.GenerateSurfaceOutput(generator);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
Assert.AreEqual(PBRMetalicLightFunction.SurfaceOutputStructureName, generator.GetPragmaString());
}
[Test]
public void TestNodeGeneratesCorrectNodeCode()

, m_Abs.GetVariableNameForSlot(Function1Input.OutputSlotId));
var generator = new ShaderGenerator();
m_PixelNode.GenerateNodeCode(generator, GenerationMode.SurfaceShader);
m_PixelNode.GenerateNodeCode(generator, GenerationMode.ForReals);
}
[Test]
public void TestPixelShaderNodeReturnsBuiltinPBRLights()
{
var lightingFuncs = PixelShaderNode.GetLightFunctions();
Assert.AreEqual(1, lightingFuncs.OfType<PBRMetalicLightFunction>().Count());
Assert.AreEqual(1, lightingFuncs.OfType<PBRSpecularLightFunction>().Count());
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyGeneratorTests.cs


Debug.logger.logHandler = new ConsoleLogHandler();
}
private const string kPropertyName = "ThePropertyName";
private const string kPropertyDescription = "ThePropertyDescription";

Assert.AreEqual(kPropertyName, infos[0].name);
Assert.AreEqual(0, infos[0].textureId);
Assert.AreEqual(TexturePropertyChunk.ModifiableState.Modifiable, infos[0].modifiable);
}
}
}

41
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs


m_Vector1Node.value = 0.6f;
m_Vector1Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new PropertyGenerator();
m_Vector1Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector1Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector1Node.propertyName

+ Environment.NewLine;
m_Vector1Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector1Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector1Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_Vector1Node.value = 0.6f;
m_Vector1Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new ShaderGenerator();
m_Vector1Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector1Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector1Node.precision

+ Environment.NewLine;
m_Vector1Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector1Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector1Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_Vector2Node.value = value;
m_Vector2Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new PropertyGenerator();
m_Vector2Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector2Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector2Node.propertyName

+ Environment.NewLine;
m_Vector2Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector2Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector2Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_Vector2Node.value = value;
m_Vector2Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new ShaderGenerator();
m_Vector2Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector2Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector2Node.precision

+ Environment.NewLine;
m_Vector2Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector2Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector2Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
[Test]
public void TestVector3NodeTypeIsCorrect()
{

m_Vector3Node.value = value;
m_Vector3Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new PropertyGenerator();
m_Vector3Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector3Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector3Node.propertyName

+ Environment.NewLine;
m_Vector3Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector3Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector3Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_Vector3Node.value = value;
m_Vector3Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new ShaderGenerator();
m_Vector3Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector3Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector3Node.precision

+ Environment.NewLine;
m_Vector3Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector3Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector3Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_Vector4Node.value = value;
m_Vector4Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new PropertyGenerator();
m_Vector4Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector4Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector4Node.propertyName

+ Environment.NewLine;
m_Vector4Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector4Node.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_Vector4Node.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_Vector4Node.value = value;
m_Vector4Node.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new ShaderGenerator();
m_Vector4Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector4Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_Vector4Node.precision

+ Environment.NewLine;
m_Vector4Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector4Node.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_Vector4Node.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_ColorNode.color = value;
m_ColorNode.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new PropertyGenerator();
m_ColorNode.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_ColorNode.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_ColorNode.propertyName

+ Environment.NewLine;
m_ColorNode.exposedState = PropertyNode.ExposedState.Exposed;
m_ColorNode.GeneratePropertyBlock(generator, GenerationMode.SurfaceShader);
m_ColorNode.GeneratePropertyBlock(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}

m_ColorNode.color = value;
m_ColorNode.exposedState = PropertyNode.ExposedState.NotExposed;
var generator = new ShaderGenerator();
m_ColorNode.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_ColorNode.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
var expected = m_ColorNode.precision

+ Environment.NewLine;
m_ColorNode.exposedState = PropertyNode.ExposedState.Exposed;
m_ColorNode.GeneratePropertyUsages(generator, GenerationMode.SurfaceShader);
m_ColorNode.GeneratePropertyUsages(generator, GenerationMode.ForReals);
Assert.AreEqual(expected, generator.GetShaderString(0));
}
}

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


[Test]
public void AdaptNodeOutput2To4PreviewWorks()
{
var node = new TestNode();
var expected = string.Format("half4({0}.x, {0}.y, 0.0, 0.0)", node.GetVariableNameForSlot(TestNode.V2Out));
var result = ShaderGenerator.AdaptNodeOutputForPreview(node, TestNode.V2Out, ConcreteSlotValueType.Vector4);

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs


return m_PixelGraph.GetMaterial();
}*/
m_PixelGraph.AddNode(new PixelShaderNode());
//m_PixelGraph.AddNode(new PixelShaderNode());
}
}
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialOptions.cs


using System;
using UnityEngine;
namespace UnityEngine.MaterialGraph
{

58
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/PixelGraph.cs


using System;
using System.Collections.Generic;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

[NonSerialized]
private PixelShaderNode m_PixelMasterNode;
public PixelShaderNode pixelMasterNode
public AbstractMasterNode masterNode
get
{
// find existing node
if (m_PixelMasterNode == null)
m_PixelMasterNode = GetNodes<AbstractMaterialNode>().FirstOrDefault(x => x.GetType() == typeof(PixelShaderNode)) as PixelShaderNode;
return m_PixelMasterNode;
}
}
[NonSerialized]
private List<INode> m_ActiveNodes = new List<INode>();
public IEnumerable<AbstractMaterialNode> activeNodes
{
get
{
m_ActiveNodes.Clear();
NodeUtils.DepthFirstCollectNodesFromNode(m_ActiveNodes, pixelMasterNode);
return m_ActiveNodes.OfType<AbstractMaterialNode>();
}
get { return GetNodes<AbstractMasterNode>().FirstOrDefault(); }
get { return "Graph_ " + pixelMasterNode.GetVariableNameForNode(); }
}
public override void OnAfterDeserialize()
{
base.OnAfterDeserialize();
m_PixelMasterNode = null;
get { return "Graph_ " + masterNode.GetVariableNameForNode(); }
public override void AddNode(INode node)
{
if (pixelMasterNode != null && node is PixelShaderNode)
{
Debug.LogWarning("Attempting to add second PixelShaderNode to PixelGraph. This is not allowed.");
return;
}
base.AddNode(node);
}
/*
public Material GetMaterial()
{
if (pixelMasterNode == null)
return null;
var material = pixelMasterNode.previewMaterial;
AbstractMaterialNode.UpdateMaterialProperties(pixelMasterNode, material);
return material;
}*/
}
}

21
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Interfaces/Interfaces.cs


public enum GenerationMode
{
Preview2D,
Preview3D,
SurfaceShader
Preview,
ForReals
public static bool IsPreview(this GenerationMode mode) { return mode == GenerationMode.Preview2D || mode == GenerationMode.Preview3D; }
public static bool Is2DPreview(this GenerationMode mode) { return mode == GenerationMode.Preview2D; }
public static bool Is3DPreview(this GenerationMode mode) { return mode == GenerationMode.Preview3D; }
public static bool IsPreview(this GenerationMode mode) { return mode == GenerationMode.Preview; }
}
public interface IGeneratesBodyCode

public interface IGeneratesVertexToFragmentBlock
{
void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode);
}
public interface IGeneratesVertexShaderBlock
{
void GenerateVertexShaderBlock(ShaderGenerator visitor, GenerationMode generationMode);
}
public interface IGenerateProperties
{
void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode);

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/BlendNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Art/Blend Node")]

17
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ColorNode.cs


UpdateNodeAfterDeserialization();
}
public override bool hasPreview
{
get { return true; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));

public Color color
{
get { return m_Color; }
set { m_Color = value; }
set
{
if (m_Color == value)
return;
m_Color = value;
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/CombineNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Art/Combine Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/DivNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Div Node")]

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/FunctionMultiInput.cs


using System.Linq;
using UnityEngine;
using System.Collections.Generic;
namespace UnityEditor.MaterialGraph
{
/*public abstract class FunctionMultiInput : BaseMaterialNode, IGeneratesBodyCode

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/LengthNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Length Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/LerpNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Lerp Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MultiplyNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Multiply Node")]

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/NormalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Normal Node")]
public class NormalNode : AbstractMaterialNode
public interface IRequiresNormal
{ }
[Title("Input/World Normal Node")]
public class NormalNode : AbstractMaterialNode, IRequiresNormal
{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Normal";

name = "Normal";
name = "World Normal";
UpdateNodeAfterDeserialization();
}

public override string GetVariableNameForSlot(int slotId)
{
return "o.Normal";
return "IN.worldNormal";
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/NormalizeNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Normalize Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PowerNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Power Node")]

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs


using System.Collections.Generic;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

return m_Exposed;
}
set { m_Exposed = value; }
set
{
if (m_Exposed == value)
return;
m_Exposed = value;
}
}
public string description

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/QuantizeNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Quantize Node")]

16
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ScreenPosNode.cs


namespace UnityEngine.MaterialGraph
{
public interface IRequiresScreenPosition
{ }
public class ScreenPosNode : AbstractMaterialNode, IGeneratesVertexToFragmentBlock
public class ScreenPosNode : AbstractMaterialNode, IRequiresScreenPosition
{
public ScreenPosNode()
{

public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
get { return PreviewMode.Preview2D; }
}

public override string GetVariableNameForSlot(int slotId)
{
return "IN.screenPos";
}
public void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
string temp = precision + "4 screenPos";
if (generationMode == GenerationMode.Preview2D)
temp += " : TEXCOORD1";
temp += ";";
visitor.AddShaderChunk(temp, true);
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SinNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Sin Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SmoothStepNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/SmoothStep Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SubtractNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Subtract Node")]

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SwizzleNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Channels/Swizzle Node")]

49
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/TextureNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Texture Node")]
public class TextureNode : PropertyNode, IGeneratesBodyCode, IGeneratesVertexShaderBlock, IGeneratesVertexToFragmentBlock
public class TextureNode : PropertyNode, IGeneratesBodyCode, IRequiresMeshUV
{
protected const string kUVSlotName = "UV";
protected const string kOutputSlotRGBAName = "RGBA";

{
public Texture2D texture;
}
public override bool hasPreview { get { return true; } }
#if UNITY_EDITOR

}
set
{
if (defaultTexture == value)
return;
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
public Texture2D defaultTexture {get;set;}
public Texture2D defaultTexture {get; set; }
set { m_TextureType = value; }
set
{
if (m_TextureType == value)
return;
m_TextureType = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public TextureNode()

public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(GetPreviewProperty());
}
public void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
if (uvSlot == null)
return;
var edges = owner.GetEdges(uvSlot.slotReference);
if (!edges.Any())
UVNode.StaticGenerateVertexToFragmentBlock(visitor, generationMode);
}
public void GenerateVertexShaderBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
if (uvSlot == null)
return;
var edges = owner.GetEdges(uvSlot.slotReference);
if (!edges.Any())
UVNode.GenerateVertexShaderBlock(visitor);
}
// Properties

29
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UVNode.cs


namespace UnityEngine.MaterialGraph
{
interface IRequiresMeshUV
{ }
public class UVNode : AbstractMaterialNode, IGeneratesVertexToFragmentBlock, IGeneratesVertexShaderBlock, IGeneratesBodyCode
public class UVNode : AbstractMaterialNode, IGeneratesBodyCode, IRequiresMeshUV
{
public const int OutputSlotId = 0;
private const string kOutputSlotName = "UV";

{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
public static void StaticGenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
string temp = "half4 meshUV0";
if (generationMode == GenerationMode.Preview2D)
temp += " : TEXCOORD0";
temp += ";";
visitor.AddShaderChunk(temp, true);
}
public void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
StaticGenerateVertexToFragmentBlock(visitor, generationMode);
}
public static void GenerateVertexShaderBlock(ShaderGenerator visitor)
{
visitor.AddShaderChunk("o.meshUV0 = v.texcoord;", true);
}
public void GenerateVertexShaderBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
GenerateVertexShaderBlock(visitor);
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector1Node.cs


public float value
{
get { return m_Value; }
set { m_Value = value; }
set
{
if (m_Value == value)
return;
m_Value = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector2Node.cs


public Vector2 value
{
get { return m_Value; }
set { m_Value = value; }
set
{
if (m_Value == value)
return;
m_Value = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector3Node.cs


public Vector3 value
{
get { return m_Value; }
set { m_Value = value; }
set
{
if (m_Value == value)
return;
m_Value = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Vector4Node.cs


public Vector4 value
{
get { return m_Value; }
set { m_Value = value; }
set
{
if (m_Value == value)
return;
m_Value = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)

15
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ViewDirectionNode.cs


namespace UnityEngine.MaterialGraph
{
interface IRequiresViewDirection : IRequiresWorldPosition
{}
public class ViewDirectionNode : AbstractMaterialNode, IGeneratesVertexToFragmentBlock
public class ViewDirectionNode : AbstractMaterialNode, IRequiresViewDirection
{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "ViewDirection";

public override string GetVariableNameForSlot(int slotId)
{
return "IN.viewDir";
}
public void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
if (generationMode == GenerationMode.Preview2D)
throw new InvalidEnumArgumentException(string.Format("Trying to generate 2D preview on {0}. This is not supported!", this));
visitor.AddShaderChunk("float3 viewDir;", true);
return "worldViewDir";
}
}
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/WorldPosNode.cs


namespace UnityEngine.MaterialGraph
{
interface IRequiresWorldPosition
{ }
public class WorldPosNode : AbstractMaterialNode, IGeneratesVertexToFragmentBlock
public class WorldPosNode : AbstractMaterialNode, IRequiresWorldPosition
{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "WorldPos";

public override string GetVariableNameForSlot(int slotId)
{
return "IN.worldPos";
}
public void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk(precision + "3 worldPos;", true);
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraph.cs


, IGeneratesBodyCode
, IGeneratesFunction
, IGenerateProperties
, IGeneratesVertexShaderBlock
, IGeneratesVertexToFragmentBlock
{
[NonSerialized]
private SubGraphInputNode m_InputNode;

{
foreach (var node in usedNodes)
{
if (node is IGeneratesVertexShaderBlock)
(node as IGeneratesVertexShaderBlock).GenerateVertexShaderBlock(visitor, generationMode);
//TODO: Fix
//if (node is IGeneratesVertexShaderBlock)
// (node as IGeneratesVertexShaderBlock).GenerateVertexShaderBlock(visitor, generationMode);
}
}

{
if (node is IGeneratesVertexToFragmentBlock)
(node as IGeneratesVertexToFragmentBlock).GenerateVertexToFragmentBlock(visitor, generationMode);
//TODO: Fix
//if (node is IGeneratesVertexToFragmentBlock)
// (node as IGeneratesVertexToFragmentBlock).GenerateVertexToFragmentBlock(visitor, generationMode);
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs


public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
if (generationMode == GenerationMode.SurfaceShader)
if (generationMode == GenerationMode.ForReals)
return;
foreach (var slot in GetOutputSlots<MaterialSlot>())

{
properties.Add(
new PreviewProperty
{
m_Name = GetVariableNameForSlot(slot.id),
m_PropType = PropertyType.Vector4,
m_Vector4 = slot.defaultValue
}
{
m_Name = GetVariableNameForSlot(slot.id),
m_PropType = PropertyType.Vector4,
m_Vector4 = slot.defaultValue
}
);
}
}

24
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs


public class SubGraphNode : AbstractMaterialNode
, IGeneratesBodyCode
, IGeneratesFunction
, IGeneratesVertexShaderBlock
, IGeneratesVertexToFragmentBlock
, IOnAssetEnabled
{
[SerializeField]

[SerializeField]
private int serializedVersion = 0;
const int kCurrentSerializedVersion = 1;
private void DoUpgrade()
{
var helper = new SubGraphHelper();

m_SerializedSubGraph = EditorJsonUtility.ToJson(helper, true);
serializedVersion = kCurrentSerializedVersion;
m_SubGraphAssetGuid = string.Empty;
mark dirty damn
mark dirty damn
public MaterialSubGraphAsset subGraphAsset {get; set;}
public MaterialSubGraphAsset subGraphAsset {get; set; }
#endif
private SubGraph subGraph

foreach (var slot in GetInputSlots<MaterialSlot>())
{
var varName = subGraphInputNode.GetVariableNameForSlot(slot.id);
var varValue = GetSlotValue(slot.id, GenerationMode.SurfaceShader);
var varValue = GetSlotValue(slot.id, GenerationMode.ForReals);
var outDimension = ConvertConcreteSlotValueTypeToString(slot.concreteValueType);
outputString.AddShaderChunk(

// Step 4...
// Using the inputs we can now generate the shader body :)
var bodyGenerator = new ShaderGenerator();
subGraph.GenerateNodeCode(bodyGenerator, GenerationMode.SurfaceShader);
subGraph.GenerateNodeCode(bodyGenerator, GenerationMode.ForReals);
var subGraphOutputNode = subGraphAsset.subGraph.outputNode;
outputString.AddShaderChunk(bodyGenerator.GetShaderString(0), false);

{
var inputValue = subGraphOutputNode.GetSlotValue(slot.id, GenerationMode.SurfaceShader);
var inputValue = subGraphOutputNode.GetSlotValue(slot.id, GenerationMode.ForReals);
outputString.AddShaderChunk(
GetVariableNameForSlot(slot.id)

if (subGraph == null)
return;
subGraph.GeneratePropertyBlock(visitor, GenerationMode.SurfaceShader);
subGraph.GeneratePropertyBlock(visitor, GenerationMode.ForReals);
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

if (subGraph == null)
return;
subGraph.GeneratePropertyUsages(visitor, GenerationMode.SurfaceShader);
subGraph.GeneratePropertyUsages(visitor, GenerationMode.ForReals);
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)

if (subGraph == null)
return;
subGraph.GenerateNodeFunction(visitor, GenerationMode.SurfaceShader);
subGraph.GenerateNodeFunction(visitor, GenerationMode.ForReals);
}
public void GenerateVertexShaderBlock(ShaderGenerator visitor, GenerationMode generationMode)

subGraph.GenerateVertexShaderBlock(visitor, GenerationMode.SurfaceShader);
subGraph.GenerateVertexShaderBlock(visitor, GenerationMode.ForReals);
}
public void GenerateVertexToFragmentBlock(ShaderGenerator visitor, GenerationMode generationMode)

subGraph.GenerateVertexToFragmentBlock(visitor, GenerationMode.SurfaceShader);
subGraph.GenerateVertexToFragmentBlock(visitor, GenerationMode.ForReals);
}
}
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyGenerator.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

231
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs


private readonly int m_IndentLevel;
private readonly string m_ShaderChunkString;
public int chunkIndentLevel { get { return m_IndentLevel; } }
public string chunkString { get { return m_ShaderChunkString; } }
public int chunkIndentLevel
{
get { return m_IndentLevel; }
}
public string chunkString
{
get { return m_ShaderChunkString; }
}
}
private readonly List<ShaderChunk> m_ShaderChunks = new List<ShaderChunk>();

m_ShaderChunks.Add(new ShaderChunk(m_IndentLevel, s));
}
public void Indent() { m_IndentLevel++; }
public void Deindent() { m_IndentLevel = Math.Max(0, m_IndentLevel - 1); }
public void Indent()
{
m_IndentLevel++;
}
public void Deindent()
{
m_IndentLevel = Math.Max(0, m_IndentLevel - 1);
}
public string GetShaderString(int baseIndentLevel)
{

var line = lines[index];
for (var i = 0; i < shaderChunk.chunkIndentLevel + baseIndentLevel; i++)
sb.Append("\t");
sb.AppendLine(line);
}
}

private static string GetTemplatePath(string templateName)
internal static string GetTemplatePath(string templateName)
{
var path = new List<string>
{

}
private const string kErrorString = @"ERROR!";
public static string AdaptNodeOutput(AbstractMaterialNode node, int outputSlotId, ConcreteSlotValueType convertToType, bool textureSampleUVHack = false)
{
var outputSlot = node.FindOutputSlot<MaterialSlot>(outputSlotId);

switch (convertFromType)
{
case ConcreteSlotValueType.Vector2:
return string.Format("half4({0}.x, {0}.y, 0.0, 0.0)", rawOutput);
return string.Format("half4({0}.x, {0}.y, 0.0, 1.0)", rawOutput);
return string.Format("half4({0}.x, {0}.y, {0}.z, 0.0)", rawOutput);
return string.Format("half4({0}.x, {0}.y, {0}.z, 1.0)", rawOutput);
default:
return kErrorString;
}

}
public int numberOfChunks
{
get { return m_ShaderChunks.Count; }
}
public static string GeneratePreviewShader(AbstractMaterialNode node, out PreviewMode generatedShaderMode)

// figure out what kind of preview we want!
var activeNodeList = ListPool<INode>.Get();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, node);
var generationMode = GenerationMode.Preview2D;
{
generationMode = GenerationMode.Preview3D;
}
string templateLocation = GetTemplatePath(generationMode == GenerationMode.Preview2D ? "2DPreview.template" : "3DPreview.template");
string templateLocation = GetTemplatePath("2DPreview.template");
if (!File.Exists(templateLocation))
return null;

var shaderInputVisitor = new ShaderGenerator();
var shaderName = "Hidden/PreviewShader/" + node.GetVariableNameForSlot(node.GetOutputSlots<MaterialSlot>().First().id);
var shaderInputVisitor = new ShaderGenerator();
var shaderName = "Hidden/PreviewShader/" + node.GetVariableNameForSlot(node.GetOutputSlots<MaterialSlot>().First().id);
// always add color because why not.
shaderInputVisitor.AddShaderChunk("float4 color : COLOR;", true);
vertexShaderBlock.AddShaderChunk("float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;", true);
vertexShaderBlock.AddShaderChunk("float3 viewDir = UnityWorldSpaceViewDir(worldPos);", true);
vertexShaderBlock.AddShaderChunk("float4 screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));", true);
vertexShaderBlock.AddShaderChunk("float3 worldNormal = UnityObjectToWorldNormal(v.normal);", true);
if (activeNodeList.Any(x => x is IRequiresWorldPosition))
{
shaderInputVisitor.AddShaderChunk("float3 worldPos : TEXCOORD2;", true);
vertexShaderBlock.AddShaderChunk("o.worldPos = worldPos;", true);
}
if (activeNodeList.Any(x => x is IRequiresNormal))
{
shaderInputVisitor.AddShaderChunk("float3 worldNormal : TEXCOORD3;", true);
vertexShaderBlock.AddShaderChunk("o.worldNormal = worldNormal;", true);
}
if (activeNodeList.Any(x => x is IRequiresMeshUV))
{
shaderInputVisitor.AddShaderChunk("half4 meshUV0 : TEXCOORD0;", true);
vertexShaderBlock.AddShaderChunk("o.meshUV0 = v.texcoord;", true);
}
if (activeNodeList.Any(x => x is IRequiresViewDirection))
{
shaderBodyVisitor.AddShaderChunk("fixed3 worldViewDir = normalize(UnityWorldSpaceViewDir(IN.worldPos));", true);
}
if (activeNodeList.Any(x => x is IRequiresScreenPosition))
{
shaderInputVisitor.AddShaderChunk("float4 screenPos : TEXCOORD3;", true);
vertexShaderBlock.AddShaderChunk("o.screenPos = screenPos;", true);
}
var generationMode = GenerationMode.Preview;
if (activeNode is IGeneratesVertexToFragmentBlock)
(activeNode as IGeneratesVertexToFragmentBlock).GenerateVertexToFragmentBlock(shaderInputVisitor, generationMode);
if (activeNode is IGeneratesVertexShaderBlock)
(activeNode as IGeneratesVertexShaderBlock).GenerateVertexShaderBlock(vertexShaderBlock, generationMode);
shaderBodyVisitor.AddShaderChunk("return " + AdaptNodeOutputForPreview(node, node.GetOutputSlots<MaterialSlot>().First().id, ConcreteSlotValueType.Vector4) + ";", true);
if (shaderInputVisitor.numberOfChunks == 0)
{
shaderInputVisitor.AddShaderChunk("float4 color : COLOR;", true);
}
if (generationMode == GenerationMode.Preview2D)
shaderBodyVisitor.AddShaderChunk("return " + AdaptNodeOutputForPreview(node, node.GetOutputSlots<MaterialSlot>().First().id, ConcreteSlotValueType.Vector4) + ";", true);
else
shaderBodyVisitor.AddShaderChunk("o.Emission = " + AdaptNodeOutputForPreview(node, node.GetOutputSlots<MaterialSlot>().First().id, ConcreteSlotValueType.Vector3) + ";", true);
ListPool<INode>.Release(activeNodeList);
template = template.Replace("${ShaderName}", shaderName);
template = template.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
template = template.Replace("${ShaderPropertyUsages}", shaderPropertyUsagesVisitor.GetShaderString(3));

}
return Regex.Replace(template, @"\r\n|\n\r|\n|\r", Environment.NewLine);
}
private static void GenerateSurfaceShaderInternal(
PixelShaderNode pixelNode,
ShaderGenerator shaderBody,
ShaderGenerator inputStruct,
ShaderGenerator lightFunction,
ShaderGenerator surfaceOutput,
ShaderGenerator nodeFunction,
PropertyGenerator shaderProperties,
ShaderGenerator propertyUsages,
ShaderGenerator vertexShader,
bool isPreview)
{
pixelNode.GenerateLightFunction(lightFunction);
pixelNode.GenerateSurfaceOutput(surfaceOutput);
var genMode = isPreview ? GenerationMode.Preview3D : GenerationMode.SurfaceShader;
var activeNodes = new List<INode>();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodes, pixelNode);
var activeMaterialNodes = activeNodes.OfType<AbstractMaterialNode>();
foreach (var node in activeMaterialNodes)
{
if (node is IGeneratesFunction) (node as IGeneratesFunction).GenerateNodeFunction(nodeFunction, genMode);
if (node is IGeneratesVertexToFragmentBlock) (node as IGeneratesVertexToFragmentBlock).GenerateVertexToFragmentBlock(inputStruct, genMode);
if (node is IGeneratesVertexShaderBlock) (node as IGeneratesVertexShaderBlock).GenerateVertexShaderBlock(vertexShader, genMode);
if (node is IGenerateProperties)
{
(node as IGenerateProperties).GeneratePropertyBlock(shaderProperties, genMode);
(node as IGenerateProperties).GeneratePropertyUsages(propertyUsages, genMode);
}
}
pixelNode.GenerateNodeCode(shaderBody, genMode);
}
public static string GenerateSurfaceShader(PixelShaderNode node, MaterialOptions options, string shaderName, bool isPreview, out List<PropertyGenerator.TextureInfo> configuredTextures)
{
var templateLocation = GetTemplatePath("shader.template");
if (!File.Exists(templateLocation))
{
configuredTextures = new List<PropertyGenerator.TextureInfo>();
return string.Empty;
}
var templateText = File.ReadAllText(templateLocation);
var shaderBodyVisitor = new ShaderGenerator();
var shaderInputVisitor = new ShaderGenerator();
var shaderLightFunctionVisitor = new ShaderGenerator();
var shaderOutputSurfaceVisitor = new ShaderGenerator();
var shaderFunctionVisitor = new ShaderGenerator();
var shaderPropertiesVisitor = new PropertyGenerator();
var shaderPropertyUsagesVisitor = new ShaderGenerator();
var vertexShaderBlock = new ShaderGenerator();
GenerateSurfaceShaderInternal(
node,
shaderBodyVisitor,
shaderInputVisitor,
shaderLightFunctionVisitor,
shaderOutputSurfaceVisitor,
shaderFunctionVisitor,
shaderPropertiesVisitor,
shaderPropertyUsagesVisitor,
vertexShaderBlock,
isPreview);
if (shaderInputVisitor.numberOfChunks == 0)
{
shaderInputVisitor.AddShaderChunk("float4 color : COLOR;", true);
}
var tagsVisitor = new ShaderGenerator();
var blendingVisitor = new ShaderGenerator();
var cullingVisitor = new ShaderGenerator();
var zTestVisitor = new ShaderGenerator();
var zWriteVisitor = new ShaderGenerator();
options.GetTags(tagsVisitor);
options.GetBlend(blendingVisitor);
options.GetCull(cullingVisitor);
options.GetDepthTest(zTestVisitor);
options.GetDepthWrite(zWriteVisitor);
var resultShader = templateText.Replace("${ShaderName}", shaderName);
resultShader = resultShader.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${ShaderPropertyUsages}", shaderPropertyUsagesVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${LightingFunctionName}", shaderLightFunctionVisitor.GetPragmaString());
resultShader = resultShader.Replace("${LightingFunction}", shaderLightFunctionVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${SurfaceOutputStructureName}", shaderOutputSurfaceVisitor.GetPragmaString());
resultShader = resultShader.Replace("${ShaderFunctions}", shaderFunctionVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${ShaderInputs}", shaderInputVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${PixelShaderBody}", shaderBodyVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${Tags}", tagsVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${Blending}", blendingVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${Culling}", cullingVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${ZTest}", zTestVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${ZWrite}", zWriteVisitor.GetShaderString(2));
string vertexShaderBody = vertexShaderBlock.GetShaderString(3);
if (vertexShaderBody.Length > 0)
{
resultShader = resultShader.Replace("${VertexShaderDecl}", "vertex:vert");
resultShader = resultShader.Replace("${VertexShaderBody}", vertexShaderBody);
}
else
{
resultShader = resultShader.Replace("${VertexShaderDecl}", "");
resultShader = resultShader.Replace("${VertexShaderBody}", "");
}
configuredTextures = shaderPropertiesVisitor.GetConfiguredTexutres();
return Regex.Replace(resultShader, @"\r\n|\n\r|\n|\r", Environment.NewLine);
}
public int numberOfChunks
{
get { return m_ShaderChunks.Count; }
}
}
}

2
MaterialGraphProject/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 5.5.0a4
m_EditorVersion: 5.5.0b1

120
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodePreviewDrawData.cs


using System;
using System.Collections.Generic;
using UnityEditor.Graphing;
using UnityEditor.Graphing.Drawing;
using RMGUI.GraphView;
namespace UnityEditor.MaterialGraph
namespace UnityEditor.MaterialGraph.Drawing
[CustomNodeUI(typeof(AbstractMaterialNode))]
public class AbstractMaterialNodeUI : ICustomNodeUi
[Serializable]
public class NodePreviewDrawData : GraphElementData
protected NodePreviewDrawData()
{}
private MaterialGraphPreviewGenerator m_PreviewGenerator;
[NonSerialized]

private AbstractMaterialNode m_Node;
[NonSerialized]
private ModificationScope m_modificationScope;
// Null means no modification is currently in progress.
public ModificationScope modificationScope
{
get
{
return m_modificationScope;
}
set
{
// External changes can only set the modification scope higher, to prevent missing out on a previously set shader regeneration.
if (m_modificationScope == ModificationScope.Graph || (m_modificationScope == ModificationScope.Node && value == ModificationScope.Nothing))
return;
m_modificationScope = value;
}
}
[NonSerialized]
private Texture m_texture;
private PreviewMode m_GeneratedShaderMode = PreviewMode.Preview2D;
public Material previewMaterial

}
}
private float m_PreviewWidth;
public virtual float GetNodeUiHeight(float width)
{
if (!m_Node.drawState.expanded)
return 0;
if (m_Node.hasPreview == false)
return 0;
m_PreviewWidth = width - 20;
return m_PreviewWidth;
}
public INode node
{
get { return m_Node; }
set
{
var materialNode = value as AbstractMaterialNode;
if (materialNode != null)
m_Node = materialNode;
}
}
public PreviewMode generatedShaderMode
public void Initialize(AbstractMaterialNode node)
get { return m_GeneratedShaderMode; }
set { m_GeneratedShaderMode = value; }
m_Node = node;
m_modificationScope = ModificationScope.Graph;
public virtual float GetNodeWidth()
public Texture Render(Vector2 dimension)
return 200;
}
public virtual GUIModificationType Render(Rect area)
{
if (m_Node == null || !m_Node.drawState.expanded)
return GUIModificationType.None;
if (m_Node == null)
return null;
return GUIModificationType.None;
return null;
if (m_LastShaderVersion != m_Node.version)
if (m_modificationScope != ModificationScope.Nothing)
if (UpdatePreviewShader())
m_LastShaderVersion = m_Node.version;
bool status = false;
if (m_modificationScope == ModificationScope.Graph)
{
previewGenerator.Reset();
// TODO: Handle shader regeneration error
status = UpdatePreviewShader();
}
m_texture = RenderPreview(dimension);
m_modificationScope = ModificationScope.Nothing;
}
else if (m_texture == null)
{
m_texture = RenderPreview(dimension);
var preview = RenderPreview(area);
GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
GUI.DrawTexture(area, preview, ScaleMode.StretchToFill, false);
GL.sRGBWrite = false;
return GUIModificationType.None;
return m_texture;
// TODO: this is a workaround right now.
if (m_Node is AbstractMasterNode)
{
var localNode = (AbstractMasterNode)m_Node;
if (localNode == null)
return string.Empty;
var shaderName = "Hidden/PreviewShader/" + localNode.GetVariableNameForNode();
List<PropertyGenerator.TextureInfo> defaultTextures;
//TODO: Need to get the real options somehow
var resultShader = ((AbstractMasterNode) m_Node).GetShader(new MaterialOptions(), GenerationMode.Preview, out defaultTextures);
m_GeneratedShaderMode = PreviewMode.Preview3D;
return resultShader;
}
return ShaderGenerator.GeneratePreviewShader(m_Node, out m_GeneratedShaderMode);
}

/// RenderPreview gets called in OnPreviewGUI. Nodes can override
/// RenderPreview and do their own rendering to the render texture
/// </summary>
public Texture RenderPreview(Rect targetSize)
private Texture RenderPreview(Vector2 targetSize)
return previewGenerator.DoRenderPreview(previewMaterial, m_GeneratedShaderMode, targetSize);
return previewGenerator.DoRenderPreview(previewMaterial, m_GeneratedShaderMode, new Rect(0, 0, targetSize.x, targetSize.y));
}
private static void SetPreviewMaterialProperty(PreviewProperty previewProperty, Material mat)

110
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs


using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph
namespace UnityEditor.MaterialGraph.Drawing
{
internal class MaterialGraphPreviewGenerator
{

private static readonly GUIContent[] s_LightIcons = {null, null};
private static readonly GUIContent[] s_TimeIcons = {null, null};
public MaterialGraphPreviewGenerator()
private PreviewRenderUtility utility
if (m_PreviewUtility == null)
get
m_PreviewUtility = new PreviewRenderUtility();
EditorUtility.SetCameraAnimateMaterials(m_PreviewUtility.m_Camera, true);
if (m_PreviewUtility == null)
m_PreviewUtility = new PreviewRenderUtility();
return m_PreviewUtility;
}
public void Reset()
{
if (m_PreviewUtility != null)
m_PreviewUtility.Cleanup();
m_PreviewUtility = null;
}
public MaterialGraphPreviewGenerator()
{
EditorUtility.SetCameraAnimateMaterials(utility.m_Camera, true);
if (s_Meshes[0] == null)
{
var handleGo = (GameObject)EditorGUIUtility.LoadRequired("Previews/PreviewMaterials.fbx");

return DoRenderPreview(mat, mode, size, Time.realtimeSinceStartup);
}
static Mesh s_Quad;
public static Mesh quad
{
get
{
if (s_Quad != null)
return s_Quad;
var vertices = new[]
{
new Vector3(-1f, -1f, 0f),
new Vector3(1f, 1f, 0f),
new Vector3(1f, -1f, 0f),
new Vector3(-1f, 1f, 0f)
};
var uvs = new[]
{
new Vector2(0f, 0f),
new Vector2(1f, 1f),
new Vector2(1f, 0f),
new Vector2(0f, 1f)
};
var indices = new[] { 0, 1, 2, 1, 0, 3 };
s_Quad = new Mesh
{
vertices = vertices,
uv = uvs,
triangles = indices
};
s_Quad.RecalculateNormals();
s_Quad.RecalculateBounds();
return s_Quad;
}
}
m_PreviewUtility.BeginPreview(size, GUIStyle.none);
utility.BeginPreview(size, GUIStyle.none);
m_PreviewUtility.m_Camera.transform.position = -Vector3.forward * 5;
m_PreviewUtility.m_Camera.transform.rotation = Quaternion.identity;
EditorUtility.SetCameraAnimateMaterialsTime(m_PreviewUtility.m_Camera, time);
var amb = new Color(.2f, .2f, .2f, 0);
m_PreviewUtility.m_Light[0].intensity = 1.0f;
m_PreviewUtility.m_Light[0].transform.rotation = Quaternion.Euler(50f, 50f, 0);
m_PreviewUtility.m_Light[1].intensity = 1.0f;
InternalEditorUtility.SetCustomLighting(m_PreviewUtility.m_Light, amb);
m_PreviewUtility.DrawMesh(s_Meshes[0], Vector3.zero, Quaternion.Euler(-20, 0, 0) * Quaternion.Euler(0, 0, 0), mat, 0);
var oldFog = RenderSettings.fog;
Unsupported.SetRenderSettingsUseFogNoDirty(false);
m_PreviewUtility.m_Camera.Render();
Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
InternalEditorUtility.RemoveCustomLighting();
utility.m_Camera.transform.position = -Vector3.forward * 5;
utility.m_Camera.transform.rotation = Quaternion.identity;
EditorUtility.UpdateGlobalShaderProperties(Time.realtimeSinceStartup);
Graphics.Blit(null, mat);
utility.m_Camera.projectionMatrix = Matrix4x4.identity;
return m_PreviewUtility.EndPreview();
EditorUtility.SetCameraAnimateMaterialsTime(utility.m_Camera, time);
utility.m_Light[0].intensity = 1.0f;
utility.m_Light[0].transform.rotation = Quaternion.Euler(50f, 50f, 0);
utility.m_Light[1].intensity = 1.0f;
InternalEditorUtility.SetCustomLighting(utility.m_Light, Color.black);
var oldFog = RenderSettings.fog;
Unsupported.SetRenderSettingsUseFogNoDirty(false);
utility.m_Camera.clearFlags = CameraClearFlags.Depth;
utility.DrawMesh(
mode == PreviewMode.Preview3D ? s_Meshes[0] : quad,
Vector3.zero,
Quaternion.identity,
mat,
0);
utility.m_Camera.Render();
Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
InternalEditorUtility.RemoveCustomLighting();
return utility.EndPreview();
}
}
}

244
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs


using System;
using System.Collections.Generic;
using System.Linq;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.Graphing;
namespace UnityEditor.Graphing.Drawing
{
[Serializable]
public abstract class AbstractGraphDataSource : ScriptableObject, IGraphElementDataSource
{
[SerializeField]
private List<GraphElementData> m_Elements = new List<GraphElementData>();
[SerializeField]
private List<GraphElementData> m_TempElements = new List<GraphElementData>();
private readonly Dictionary<Type, Type> m_DataMapper = new Dictionary<Type, Type>();
public IGraphAsset graphAsset { get; private set; }
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<NodeDrawData>().ToList();
var found = theElements.Where(x => x.node.guid == node.guid).ToList();
foreach (var drawableNodeData in found)
drawableNodeData.OnModified(scope);
}
EditorUtility.SetDirty(graphAsset.GetScriptableObject());
}
private void UpdateData()
{
// Find all nodes currently being drawn which are no longer in the graph (i.e. deleted)
var deletedElements = m_Elements
.OfType<NodeDrawData>()
.Where(nd => !graphAsset.graph.GetNodes<INode>().Contains(nd.node))
.OfType<GraphElementData>()
.ToList();
var deletedEdges = m_Elements.OfType<EdgeDrawData>()
.Where(ed => !graphAsset.graph.edges.Contains(ed.edge));
// Find all edges currently being drawn which are no longer in the graph (i.e. deleted)
foreach (var edgeData in deletedEdges)
{
// Make sure to disconnect the node, otherwise new connections won't be allowed for the used slots
edgeData.output.Disconnect(edgeData);
edgeData.input.Disconnect(edgeData);
var toNodeGuid = edgeData.edge.inputSlot.nodeGuid;
var toNode = m_Elements.OfType<NodeDrawData>().FirstOrDefault(nd => nd.node.guid == toNodeGuid);
if (toNode != null)
{
// Make the input node (i.e. right side of the connection) re-render
OnNodeChanged(toNode.node, ModificationScope.Graph);
}
deletedElements.Add(edgeData);
}
// Remove all nodes and edges marked for deletion
foreach (var deletedElement in deletedElements)
{
m_Elements.Remove(deletedElement);
}
var addedNodes = new List<NodeDrawData>();
// Find all new nodes and mark for addition
foreach (var node in graphAsset.graph.GetNodes<INode>())
{
// Check whether node already exists
if (m_Elements.OfType<NodeDrawData>().Any(e => e.node == node))
continue;
var type = MapType(node.GetType());
var nodeData = (NodeDrawData)CreateInstance(type);
node.onModified += OnNodeChanged;
nodeData.Initialize(node);
addedNodes.Add(nodeData);
}
// Create edge data for nodes marked for addition
var drawableEdges = new List<EdgeDrawData>();
foreach (var addedNode in addedNodes)
{
var baseNode = addedNode.node;
foreach (var slot in baseNode.GetOutputSlots<ISlot>())
{
var sourceAnchors = addedNode.elements.OfType<AnchorDrawData>();
var sourceAnchor = sourceAnchors.FirstOrDefault(x => x.slot == slot);
var edges = baseNode.owner.GetEdges(new SlotReference(baseNode.guid, slot.id));
foreach (var edge in edges)
{
var toNode = baseNode.owner.GetNodeFromGuid(edge.inputSlot.nodeGuid);
var toSlot = toNode.FindInputSlot<ISlot>(edge.inputSlot.slotId);
var targetNode = addedNodes.FirstOrDefault(x => x.node == toNode);
var targetAnchors = targetNode.elements.OfType<AnchorDrawData>();
var targetAnchor = targetAnchors.FirstOrDefault(x => x.slot == toSlot);
var edgeData = CreateInstance<EdgeDrawData>();
edgeData.Initialize(edge);
edgeData.output = sourceAnchor;
edgeData.output.Connect(edgeData);
edgeData.input = targetAnchor;
edgeData.input.Connect(edgeData);
drawableEdges.Add(edgeData);
}
}
}
// Add nodes marked for addition
m_Elements.AddRange(addedNodes.OfType<GraphElementData>());
// Find edges in the graph that are not being drawn and create edge data for them
foreach (var edge in graphAsset.graph.edges)
{
if (!m_Elements.OfType<EdgeDrawData>().Any(ed => ed.edge == edge))
{
var fromNode = graphAsset.graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);
var fromSlot = fromNode.FindOutputSlot<ISlot>(edge.outputSlot.slotId);
var sourceNode = m_Elements.OfType<NodeDrawData>().FirstOrDefault(x => x.node == fromNode);
var sourceAnchors = sourceNode.elements.OfType<AnchorDrawData>();
var sourceAnchor = sourceAnchors.FirstOrDefault(x => x.slot == fromSlot);
var toNode = graphAsset.graph.GetNodeFromGuid(edge.inputSlot.nodeGuid);
var toSlot = toNode.FindInputSlot<ISlot>(edge.inputSlot.slotId);
var targetNode = m_Elements.OfType<NodeDrawData>().FirstOrDefault(x => x.node == toNode);
var targetAnchors = targetNode.elements.OfType<AnchorDrawData>();
var targetAnchor = targetAnchors.FirstOrDefault(x => x.slot == toSlot);
OnNodeChanged(targetNode.node, ModificationScope.Graph);
var edgeData = CreateInstance<EdgeDrawData>();
edgeData.Initialize(edge);
edgeData.output = sourceAnchor;
edgeData.output.Connect(edgeData);
edgeData.input = targetAnchor;
edgeData.input.Connect(edgeData);
drawableEdges.Add(edgeData);
}
}
m_Elements.AddRange(drawableEdges.OfType<GraphElementData>());
}
private Type MapType(Type type)
{
Type found = null;
while (type != null)
{
if (m_DataMapper.TryGetValue(type, out found))
break;
type = type.BaseType;
}
return found ?? typeof(NodeDrawData);
}
protected abstract void AddTypeMappings();
public void AddTypeMapping(Type node, Type drawData)
{
m_DataMapper[node] = drawData;
}
public virtual void Initialize(IGraphAsset graphAsset)
{
m_DataMapper.Clear();
AddTypeMappings();
this.graphAsset = graphAsset;
if (graphAsset == null)
return;
UpdateData();
}
public void AddNode(INode node)
{
graphAsset.graph.AddNode(node);
EditorUtility.SetDirty(graphAsset.GetScriptableObject());
UpdateData();
}
public void RemoveElements(IEnumerable<NodeDrawData> nodes, IEnumerable<EdgeDrawData> edges)
{
graphAsset.graph.RemoveElements(nodes.Select(x => x.node), edges.Select(x => x.edge));
graphAsset.graph.ValidateGraph();
EditorUtility.SetDirty(graphAsset.GetScriptableObject());
UpdateData();
}
public IEnumerable<GraphElementData> elements
{
get { return m_Elements.Union(m_TempElements); }
}
public void AddTempElement(GraphElementData element)
{
m_TempElements.Add(element);
}
public void RemoveTempElement(GraphElementData element)
{
m_TempElements.Remove(element);
}
public void ClearTempElements()
{
m_TempElements.Clear();
}
public void Connect(AnchorDrawData left, AnchorDrawData right)
{
if (left && right)
{
graphAsset.graph.Connect(left.slot.slotReference, right.slot.slotReference);
EditorUtility.SetDirty(graphAsset.GetScriptableObject());
UpdateData();
}
}
public void AddElement(GraphElementData element)
{
throw new ArgumentException("Not supported on Serializable Graph, data comes from data store");
}
public void RemoveElement(GraphElementData element)
{
throw new ArgumentException("Not supported on Serializable Graph, data comes from data store");
}
}
}

315
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs


using System;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.RMGUI;
namespace UnityEditor.Graphing.Drawing
{
public abstract class AbstractGraphEditWindow<T> : EditorWindow, ISerializationCallbackReceiver where T : class, IGraphAsset
{
public RenderTexture rt;
[NonSerialized]
private T m_LastSelection;
[SerializeField]
private ScriptableObject m_LastSelectedGraphSerialized;
private bool shouldRepaint
{
get
{
return m_LastSelection != null && m_LastSelection.shouldRepaint;
}
}
protected GraphView graphView
{
get { return m_GraphView; }
}
private GraphView m_GraphView;
public virtual AbstractGraphDataSource CreateDataSource()
{
return CreateInstance<SerializedGraphDataSource>();
}
public virtual GraphView CreateGraphView()
{
return new SerializableGraphView();
}
void OnEnable()
{
m_GraphView = CreateGraphView();
m_GraphView.name = "Graph View";
var source = CreateDataSource();
source.Initialize(m_LastSelection);
m_GraphView.dataSource = source;
m_GraphView.StretchToParentSize();
windowRoot.AddChild(m_GraphView);
}
void OnDisable()
{
windowRoot.ClearChildren();
}
void Update()
{
if (shouldRepaint)
Repaint();
}
void OnSelectionChange()
{
if (Selection.activeObject == null || !EditorUtility.IsPersistent(Selection.activeObject))
return;
if (Selection.activeObject is ScriptableObject)
{
var selection = Selection.activeObject as T;
if (selection != m_LastSelection)
{
var graph = selection.graph;
graph.OnEnable();
graph.ValidateGraph();
m_LastSelection = selection;
var source = CreateDataSource();
source.Initialize(m_LastSelection);
m_GraphView.dataSource = source;
m_GraphView.StretchToParentSize();
Repaint();
}
}
}
/*
private void ConvertSelectionToSubGraph()
{
if (m_Canvas.dataSource == null)
return;
var dataSource = m_Canvas.dataSource as GraphDataSource;
if (dataSource == null)
return;
var asset = dataSource.graphAsset;
if (asset == null)
return;
var targetGraph = asset.graph;
if (targetGraph == null)
return;
if (!m_Canvas.selection.Any())
return;
var serialzied = CopySelected.SerializeSelectedElements(m_Canvas);
var deserialized = CopySelected.DeserializeSelectedElements(serialzied);
if (deserialized == null)
return;
string path = EditorUtility.SaveFilePanelInProject("Save subgraph", "New SubGraph", "ShaderSubGraph", "");
path = path.Replace(Application.dataPath, "Assets");
if (path.Length == 0)
return;
var graphAsset = CreateInstance<MaterialSubGraphAsset>();
graphAsset.name = Path.GetFileName(path);
graphAsset.PostCreate();
var graph = graphAsset.subGraph;
if (graphAsset.graph == null)
return;
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 inputEdgeNeedsRemap = new List<IEdge>();
var outputEdgeNeedsRemap = 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)
{
inputEdgeNeedsRemap.Add(edge);
}
else if (inputRemapExists)
{
outputEdgeNeedsRemap.Add(edge);
}
}
// we do a grouping here as the same output can
// point to multiple inputs
var uniqueOutputs = outputEdgeNeedsRemap.GroupBy(edge => edge.outputSlot);
var inputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>();
foreach (var group in uniqueOutputs)
{
var inputNode = graph.inputNode;
var slotId = inputNode.AddSlot();
var outputSlotRef = new SlotReference(inputNode.guid, slotId);
foreach (var edge in group)
{
var newEdge = graph.Connect(outputSlotRef, new SlotReference(nodeGuidMap[edge.inputSlot.nodeGuid], edge.inputSlot.slotId));
inputsNeedingConnection.Add(new KeyValuePair<IEdge, IEdge>(edge, newEdge));
}
}
var uniqueInputs = inputEdgeNeedsRemap.GroupBy(edge => edge.inputSlot);
var outputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>();
foreach (var group in uniqueInputs)
{
var outputNode = graph.outputNode;
var slotId = outputNode.AddSlot();
var inputSlotRef = new SlotReference(outputNode.guid, slotId);
foreach (var edge in group)
{
var newEdge = graph.Connect(new SlotReference(nodeGuidMap[edge.outputSlot.nodeGuid], edge.outputSlot.slotId), inputSlotRef);
outputsNeedingConnection.Add(new KeyValuePair<IEdge, IEdge>(edge, newEdge));
}
}
AssetDatabase.CreateAsset(graphAsset, path);
var subGraphNode = new SubGraphNode();
targetGraph.AddNode(subGraphNode);
subGraphNode.subGraphAsset = graphAsset;
foreach (var edgeMap in inputsNeedingConnection)
{
targetGraph.Connect(edgeMap.Key.outputSlot, new SlotReference(subGraphNode.guid, edgeMap.Value.outputSlot.slotId));
}
foreach (var edgeMap in outputsNeedingConnection)
{
targetGraph.Connect(new SlotReference(subGraphNode.guid, edgeMap.Value.inputSlot.slotId), edgeMap.Key.inputSlot);
}
var toDelete = m_Canvas.selection.Where(x => x is DrawableNode).ToList();
dataSource.DeleteElements(toDelete);
targetGraph.ValidateGraph();
m_Canvas.ReloadData();
m_Canvas.Invalidate();
m_Canvas.selection.Clear();
var toSelect = m_Canvas.elements.OfType<DrawableNode>().FirstOrDefault(x => x.m_Node == subGraphNode);
if (toSelect != null)
{
toSelect.selected = true;
m_Canvas.selection.Add(toSelect);
}
m_Canvas.Repaint();
}
private void Rebuild()
{
if (m_Canvas == null || m_LastSelection == null)
return;
m_DataSource.graphAsset = m_LastSelection;
m_Canvas.ReloadData();
}*/
/* void OnGUI()
{
m_HostWindow = this;
if (m_Canvas == null)
{
InitializeCanvas();
}
if (m_LastSelection == null || m_LastSelection.graph == null)
{
GUILayout.Label("No Graph selected");
return;
}
m_Canvas.OnGUI(this, new Rect(0, 0, position.width - 250, position.height));
if (GUI.Button(new Rect(position.width - 250, 0, 250, 50), "Convert to Sub-Graph"))
ConvertSelectionToSubGraph();
if (GUI.Button(new Rect(position.width - 250, 70, 250, 50), "Export"))
Export(false);
if (GUI.Button(new Rect(position.width - 250, 140, 250, 50), "Export - quick"))
Export(true);
EditorGUI.ObjectField(new Rect(position.width - 250, 210, 250, 50), rt, typeof(RenderTexture), false);
}*/
/*public void RenderOptions(MaterialGraph graph)
{
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
EditorGUILayout.BeginVertical();
m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, EditorStyles.textArea, GUILayout.width(250), GUILayout.ExpandHeight(true));
graph.materialOptions.DoGUI();
EditorGUILayout.Separator();
m_NodeExpanded = MaterialGraphStyles.Header("Selected", m_NodeExpanded);
if (m_NodeExpanded)
DrawableMaterialNode.OnGUI(m_Canvas.selection);
GUILayout.EndScrollView();
if (GUILayout.Button("Export"))
m_DataSource.Export(false);
GUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
}*/
public void OnBeforeSerialize()
{
var o = m_LastSelection as ScriptableObject;
if (o != null)
m_LastSelectedGraphSerialized = o;
}
public void OnAfterDeserialize()
{
if (m_LastSelectedGraphSerialized != null)
m_LastSelection = m_LastSelectedGraphSerialized as T;
m_LastSelectedGraphSerialized = null;
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs.meta


fileFormatVersion: 2
guid: 322c21863b8e2024e85c4f0e0dee0b94
timeCreated: 1476711073
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/COPIED.meta


fileFormatVersion: 2
guid: ef89c3094f656ca419096cec59d816af
folderAsset: yes
timeCreated: 1478076357
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData.meta


fileFormatVersion: 2
guid: 4e974459130fa5f4f9899e83b1e752d5
folderAsset: yes
timeCreated: 1476708485
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer.meta


fileFormatVersion: 2
guid: 8aa4176733f149446bd0c55036656e30
folderAsset: yes
timeCreated: 1476708981
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Manipulators.meta


fileFormatVersion: 2
guid: 49d342e281c5c0842a37adc523aca716
folderAsset: yes
timeCreated: 1477989669
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

44
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs


using System.Collections.Generic;
using System.Linq;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.RMGUI;
namespace UnityEditor.Graphing.Drawing
{
[StyleSheet("Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss")]
public class SerializableGraphView : GraphView
{
public SerializableGraphView()
{
// Shortcut handler to delete elements
var dictionary = new Dictionary<Event, ShortcutDelegate>();
dictionary[Event.KeyboardEvent("delete")] = DeleteSelection;
AddManipulator(new ShortcutHandler(dictionary));
AddManipulator(new ContentZoomer());
AddManipulator(new ContentDragger());
AddManipulator(new RectangleSelector());
AddManipulator(new SelectionDragger());
AddManipulator(new ClickSelector());
AddDecorator(new GridBackground());
dataMapper[typeof(NodeDrawData)] = typeof(NodeDrawer);
dataMapper[typeof(HeaderDrawData)] = typeof(HeaderDrawer);
}
private EventPropagation DeleteSelection()
{
var nodalViewData = dataSource as AbstractGraphDataSource;
if (nodalViewData == null)
return EventPropagation.Stop;
nodalViewData.RemoveElements(
selection.OfType<NodeDrawer>().Select(x => x.dataProvider as NodeDrawData),
selection.OfType<Edge>().Select(x => x.dataProvider as EdgeDrawData)
);
return EventPropagation.Stop;
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs.meta


fileFormatVersion: 2
guid: 0f06001291d4e32479f71557abf52944
timeCreated: 1476710182
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

15
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs


using UnityEngine.Graphing;
namespace UnityEditor.Graphing.Drawing
{
public class SerializedGraphDataSource : AbstractGraphDataSource
{
protected SerializedGraphDataSource()
{}
protected override void AddTypeMappings()
{
AddTypeMapping(typeof(SerializableNode), typeof(NodeDrawData));
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs.meta


fileFormatVersion: 2
guid: d7466f2e9546aaa409ea2125e36a0342
timeCreated: 1476711073
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles.meta


fileFormatVersion: 2
guid: 0bfdedf8c1122ce43a248236ef367ab3
folderAsset: yes
timeCreated: 1476713799
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

25
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/UIUtilities.cs


using System.Collections.Generic;
namespace UnityEditor.Graphing.Util
{
public static class UIUtilities
{
public static bool ItemsReferenceEquals<T>(this IList<T> first, IList<T> second)
{
if (first.Count != second.Count)
{
return false;
}
for (int i = 0; i < first.Count; i++)
{
if (!ReferenceEquals(first[i], second[i]))
{
return false;
}
}
return true;
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/UIUtilities.cs.meta


fileFormatVersion: 2
guid: 60ebb16e194464bce8a4975da8fd215a
timeCreated: 1476782702
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/NewUI.meta


fileFormatVersion: 2
guid: 891cd61cb6bbad6438e2bae6bdc5b60c
folderAsset: yes
timeCreated: 1475651642
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer.meta


fileFormatVersion: 2
guid: 7887abd697bcde24596ec729cd7e3c3e
folderAsset: yes
timeCreated: 1476708485
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

164
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
using UnityEngine.RMGUI;
using Edge = RMGUI.GraphView.Edge;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing
{
[StyleSheet("Assets/UnityShaderEditor/Editor/Drawing/Styles/MaterialGraph.uss")]
public class MaterialGraphView : SerializableGraphView
{
public MaterialGraphView()
{
AddManipulator(new ContextualMenu(DoContextMenu));
dataMapper[typeof(MaterialNodeDrawData)] = typeof(MaterialNodeDrawer);
dataMapper[typeof(AnchorDrawData)] = typeof(NodeAnchor);
dataMapper[typeof(EdgeData)] = typeof(Edge);
var dictionary = new Dictionary<Event, ShortcutDelegate>();
dictionary[Event.KeyboardEvent("^F1")] = Export;
AddManipulator(new ShortcutHandler(dictionary));
}
public virtual bool CanAddToNodeMenu(Type type)
{
return true;
}
protected EventPropagation DoContextMenu(Event evt, Object customData)
{
var gm = new GenericMenu();
foreach (Type type in Assembly.GetAssembly(typeof(AbstractMaterialNode)).GetTypes())
{
if (type.IsClass && !type.IsAbstract && (type.IsSubclassOf(typeof(AbstractMaterialNode))))
{
var attrs = type.GetCustomAttributes(typeof(TitleAttribute), false) as TitleAttribute[];
if (attrs != null && attrs.Length > 0 && CanAddToNodeMenu(type))
{
gm.AddItem(new GUIContent(attrs[0].m_Title), false, AddNode, new AddNodeCreationObject(type, evt.mousePosition));
}
}
}
//gm.AddSeparator("");
// gm.AddItem(new GUIContent("Convert To/SubGraph"), true, ConvertSelectionToSubGraph);
gm.ShowAsContext();
return EventPropagation.Stop;
}
private class AddNodeCreationObject : object
{
public Vector2 m_Pos;
public readonly Type m_Type;
public AddNodeCreationObject(Type t, Vector2 p)
{
m_Type = t;
m_Pos = p;
}
};
private void AddNode(object obj)
{
var posObj = obj as AddNodeCreationObject;
if (posObj == null)
return;
INode node;
try
{
node = Activator.CreateInstance(posObj.m_Type) as INode;
}
catch (Exception e)
{
Debug.LogWarningFormat("Could not construct instance of: {0} - {1}", posObj.m_Type, e);
return;
}
if (node == null)
return;
var drawstate = node.drawState;
drawstate.position = new Rect(posObj.m_Pos.x, posObj.m_Pos.y, 0, 0);
node.drawState = drawstate;
var graphDataSource = dataSource as AbstractGraphDataSource;
graphDataSource.AddNode(node);
}
public EventPropagation Export()
{
var path = EditorUtility.SaveFilePanelInProject("Export shader to file...", "shader.shader", "shader", "Enter file name");
var ds = dataSource as AbstractGraphDataSource;
if (ds != null && !string.IsNullOrEmpty(path))
{
ExportShader(ds.graphAsset as MaterialGraphAsset, path);
}
else
EditorUtility.DisplayDialog("Export Shader Error", "Cannot export shader", "Ok");
return EventPropagation.Stop;
}
public static Shader ExportShader(MaterialGraphAsset graphAsset, string path)
{
if (graphAsset == null)
return null;
var materialGraph = graphAsset.graph as PixelGraph;
if (materialGraph == null)
return null;
List<PropertyGenerator.TextureInfo> configuredTextures;
var shaderString = materialGraph.masterNode.GetShader(new MaterialOptions(), GenerationMode.ForReals, out configuredTextures);
File.WriteAllText(path, shaderString);
AssetDatabase.Refresh(); // Investigate if this is optimal
var shader = AssetDatabase.LoadAssetAtPath(path, typeof(Shader)) as Shader;
if (shader == null)
return null;
var shaderImporter = AssetImporter.GetAtPath(path) as ShaderImporter;
if (shaderImporter == null)
return null;
var textureNames = new List<string>();
var textures = new List<Texture>();
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable == TexturePropertyChunk.ModifiableState.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 == TexturePropertyChunk.ModifiableState.NonModifiable))
{
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());
shaderImporter.SaveAndReimport();
return shaderImporter.GetShader();
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs.meta


fileFormatVersion: 2
guid: e0bbd4215e018eb4bbdb28bfaa7eabdd
timeCreated: 1476707367
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles.meta


fileFormatVersion: 2
guid: 55206ee1a8b96e84bb8a8a0bc7c58bd0
folderAsset: yes
timeCreated: 1475748087
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

295
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/New Shader Graph.ShaderGraph


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 562bd27a5e73fc64d80a1d9d936ffbd5, type: 3}
m_Name: New Shader Graph
m_EditorClassIdentifier:
m_MaterialGraph:
m_MaterialOptions:
m_SrcBlend: 0
m_DstBlend: 1
m_CullMode: 0
m_ZTest: 2
m_ZWrite: 0
m_RenderQueue: 1
m_RenderType: 0
m_ShadowPass: 0
m_FullForwardShadows: 0
m_NoAmbient: 0
m_NoVertexLights: 0
m_NoLightmaps: 0
m_NoDirLightmap: 0
m_NoForwardAdd: 0
m_ApproxView: 0
m_HalfAsView: 0
m_Expanded: 0
m_PixelGraph:
m_SerializableNodes:
- typeInfo:
fullName: UnityEngine.MaterialGraph.PixelShaderNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"c835c2eb-0a54-43de-b581-1b283b208eef\",\n
\ \"m_Name\": \"PixelMaster\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": 236.0,\n \"y\": 93.0,\n \"width\":
-236.0,\n \"height\": -93.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\\\": \\\"Albedo\\\",\\n \\\"m_SlotType\\\":
0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 2,\\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\\\":
3,\\n \\\"m_ShaderOutputName\\\": \\\"Albedo\\\"\\n}\"\n },\n
\ {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\":
\\\"Normal\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 2,\\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\\\": 3,\\n \\\"m_ShaderOutputName\\\":
\\\"Normal\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n
\ \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\":
\\\"Emission\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 2,\\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\\\": 3,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Emission\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"Metallic\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Metallic\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"Smoothness\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Smoothness\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\":
\\\"Occlusion\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Occlusion\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 6,\\n \\\"m_DisplayName\\\":
\\\"Alpha\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"Alpha\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n
\ \"m_SerializedLightFunction\": {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.PBRMetalicLightFunction\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{}\"\n }\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.ColorNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"4ea9595c-885f-4073-a7f7-af240cae0405\",\n
\ \"m_Name\": \"ColorNode\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -1020.91259765625,\n \"y\": -118.99871826171875,\n
\ \"width\": 152.0,\n \"height\": 139.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\\\":
\\\"Color\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 1,\\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\\\": 4,\\n \\\"m_ShaderOutputName\\\":
\\\"Color\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n
\ \"m_PropertyName\": \"\",\n \"m_Description\": \"\",\n \"m_Exposed\":
1,\n \"m_Color\": {\n \"r\": 1.0,\n \"g\": 0.0,\n \"b\":
0.0,\n \"a\": 1.0\n }\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.ColorNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"057ee10d-238b-4ad2-ba2f-7ef35a1034a0\",\n
\ \"m_Name\": \"ColorNode\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -1023.91259765625,\n \"y\": 39.00128173828125,\n
\ \"width\": 211.0,\n \"height\": 181.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\\\":
\\\"Color\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 1,\\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\\\": 4,\\n \\\"m_ShaderOutputName\\\":
\\\"Color\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n
\ \"m_PropertyName\": \"\",\n \"m_Description\": \"\",\n \"m_Exposed\":
1,\n \"m_Color\": {\n \"r\": 0.9264705777168274,\n \"g\":
0.19074395298957826,\n \"b\": 0.19074395298957826,\n \"a\":
0.0\n }\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.TextureNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"af0c9ce8-5cb8-4b59-b543-5dcc4f900137\",\n
\ \"m_Name\": \"Texture\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -1034.91259765625,\n \"y\": 192.00128173828126,\n
\ \"width\": 603.0,\n \"height\": -307.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\\\":
\\\"RGBA\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 1,\\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\\\": 4,\\n \\\"m_ShaderOutputName\\\":
\\\"RGBA\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n
\ \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"R\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"R\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"G\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"G\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"B\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"B\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\": \\\"A\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"A\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\":
\\\"UV\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 3,\\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\\\": 2,\\n \\\"m_ShaderOutputName\\\":
\\\"UV\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n \"m_PropertyName\":
\"\",\n \"m_Description\": \"\",\n \"m_Exposed\": 1,\n \"m_SerializedTexture\":
\"{\\n \\\"texture\\\": {\\n \\\"fileID\\\": 10906,\\n \\\"guid\\\":
\\\"0000000000000000f000000000000000\\\",\\n \\\"type\\\": 0\\n }\\n}\",\n
\ \"m_TextureType\": 0\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.SubGraphNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"1b4853a9-f60e-4b74-a56f-faa39bd3c2e3\",\n
\ \"m_Name\": \"SubGraph\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -394.0,\n \"y\": 111.0,\n \"width\":
394.0,\n \"height\": -111.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(4)\\\",\\n
\ \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\":
1,\\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\\\":
4,\\n \\\"m_ShaderOutputName\\\": \\\"Input1\\\"\\n}\"\n },\n
\ {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": -2,\\n \\\"m_DisplayName\\\":
\\\"Input 2(4)\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\": 4,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Input2\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\":
\\\"Output 1(4)\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\": 4,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Output1\\\"\\n}\"\n }\n ],\n
\ \"m_OutputPrecision\": 1,\n \"m_SerializedSubGraph\": \"{\\n \\\"subGraph\\\":
{\\n \\\"fileID\\\": 11400000,\\n \\\"guid\\\": \\\"8c60a30380fb1434597b0c3993758852\\\",\\n
\ \\\"type\\\": 2\\n }\\n}\"\n}"
m_SerializableEdges:
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\":
\"4ea9595c-885f-4073-a7f7-af240cae0405\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": -1,\n \"m_NodeGUIDSerialized\": \"1b4853a9-f60e-4b74-a56f-faa39bd3c2e3\"\n
\ }\n}"
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\":
\"af0c9ce8-5cb8-4b59-b543-5dcc4f900137\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": -2,\n \"m_NodeGUIDSerialized\": \"1b4853a9-f60e-4b74-a56f-faa39bd3c2e3\"\n
\ }\n}"
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\":
\"1b4853a9-f60e-4b74-a56f-faa39bd3c2e3\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": 3,\n \"m_NodeGUIDSerialized\": \"c835c2eb-0a54-43de-b581-1b283b208eef\"\n
\ }\n}"
m_Name:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/New Shader Graph.ShaderGraph.meta


fileFormatVersion: 2
guid: f60ac9e5e8c629d44aa0a9f0f810fbbd
timeCreated: 1475478432
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

300
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/blah.ShaderGraph


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 562bd27a5e73fc64d80a1d9d936ffbd5, type: 3}
m_Name: blah
m_EditorClassIdentifier:
m_MaterialGraph:
m_MaterialOptions:
m_SrcBlend: 0
m_DstBlend: 1
m_CullMode: 0
m_ZTest: 2
m_ZWrite: 0
m_RenderQueue: 1
m_RenderType: 0
m_ShadowPass: 0
m_FullForwardShadows: 0
m_NoAmbient: 0
m_NoVertexLights: 0
m_NoLightmaps: 0
m_NoDirLightmap: 0
m_NoForwardAdd: 0
m_ApproxView: 0
m_HalfAsView: 0
m_Expanded: 0
m_PixelGraph:
m_SerializableNodes:
- typeInfo:
fullName: UnityEngine.MaterialGraph.PixelShaderNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"e5f33fa6-beb3-4bac-bb88-820fc7df4a8f\",\n
\ \"m_Name\": \"PixelMaster\",\n \"m_DrawData\": {\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\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Albedo\\\",\\n \\\"m_SlotType\\\":
0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 2,\\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\\\":
3,\\n \\\"m_ShaderOutputName\\\": \\\"Albedo\\\"\\n}\"\n },\n
\ {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\":
\\\"Normal\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 2,\\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\\\": 3,\\n \\\"m_ShaderOutputName\\\":
\\\"Normal\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n
\ \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\":
\\\"Emission\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 2,\\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\\\": 3,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Emission\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"Metallic\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Metallic\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"Smoothness\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Smoothness\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\":
\\\"Occlusion\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Occlusion\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 6,\\n \\\"m_DisplayName\\\":
\\\"Alpha\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"Alpha\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n
\ \"m_SerializedLightFunction\": {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.PBRMetalicLightFunction\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{}\"\n }\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.TextureNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"8f2995c0-956f-4d3c-a2a1-d326a8b2ca2f\",\n
\ \"m_Name\": \"Texture\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -495.0,\n \"y\": -378.0,\n \"width\":
-196.0,\n \"height\": 455.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\\\": \\\"RGBA\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\":
4,\\n \\\"m_ShaderOutputName\\\": \\\"RGBA\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"R\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"R\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"G\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"G\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"B\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"B\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\": \\\"A\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"A\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\":
\\\"UV\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 3,\\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\\\": 2,\\n \\\"m_ShaderOutputName\\\":
\\\"UV\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n \"m_PropertyName\":
\"\",\n \"m_Description\": \"\",\n \"m_Exposed\": 1,\n \"m_SerializedTexture\":
\"{\\n \\\"texture\\\": {\\n \\\"fileID\\\": 2800000,\\n \\\"guid\\\":
\\\"330f42016073a97418a4aae5517e32c8\\\",\\n \\\"type\\\": 3\\n }\\n}\",\n
\ \"m_TextureType\": 0\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.TextureNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"921f9c09-60c4-49fe-8a1f-e74528b68723\",\n
\ \"m_Name\": \"Texture\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -528.0,\n \"y\": 265.0,\n \"width\":
21.0,\n \"height\": 60.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\\\": \\\"RGBA\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\":
4,\\n \\\"m_ShaderOutputName\\\": \\\"RGBA\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"R\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"R\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"G\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"G\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"B\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"B\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\": \\\"A\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"A\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\":
\\\"UV\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 3,\\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\\\": 2,\\n \\\"m_ShaderOutputName\\\":
\\\"UV\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n \"m_PropertyName\":
\"\",\n \"m_Description\": \"\",\n \"m_Exposed\": 1,\n \"m_SerializedTexture\":
\"{\\n \\\"texture\\\": {\\n \\\"fileID\\\": 2800000,\\n \\\"guid\\\":
\\\"5a5e07ee958edbd468227e1d9ac4726a\\\",\\n \\\"type\\\": 3\\n }\\n}\",\n
\ \"m_TextureType\": 3\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.ColorNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"6ae3a0e2-f1f0-4d9a-a6aa-20078a916e6d\",\n
\ \"m_Name\": \"ColorNode\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -852.0,\n \"y\": 85.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\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Color\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\":
4,\\n \\\"m_ShaderOutputName\\\": \\\"Color\\\"\\n}\"\n }\n ],\n
\ \"m_OutputPrecision\": 1,\n \"m_PropertyName\": \"\",\n \"m_Description\":
\"\",\n \"m_Exposed\": 1,\n \"m_Color\": {\n \"r\": 1.0,\n
\ \"g\": 0.31617647409439089,\n \"b\": 0.31617647409439089,\n
\ \"a\": 0.0\n }\n}"
m_SerializableEdges:
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\":
\"8f2995c0-956f-4d3c-a2a1-d326a8b2ca2f\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"e5f33fa6-beb3-4bac-bb88-820fc7df4a8f\"\n
\ }\n}"
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\":
\"921f9c09-60c4-49fe-8a1f-e74528b68723\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"e5f33fa6-beb3-4bac-bb88-820fc7df4a8f\"\n
\ }\n}"
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\":
\"6ae3a0e2-f1f0-4d9a-a6aa-20078a916e6d\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": 3,\n \"m_NodeGUIDSerialized\": \"e5f33fa6-beb3-4bac-bb88-820fc7df4a8f\"\n
\ }\n}"
m_Name:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/blah.ShaderGraph.meta


fileFormatVersion: 2
guid: 7a113c2246bb1f646974359108cfcaa2
timeCreated: 1470917887
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

271
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/new.ShaderGraph


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 562bd27a5e73fc64d80a1d9d936ffbd5, type: 3}
m_Name: new
m_EditorClassIdentifier:
m_MaterialGraph:
m_MaterialOptions:
m_SrcBlend: 0
m_DstBlend: 1
m_CullMode: 0
m_ZTest: 2
m_ZWrite: 0
m_RenderQueue: 1
m_RenderType: 0
m_ShadowPass: 0
m_FullForwardShadows: 0
m_NoAmbient: 0
m_NoVertexLights: 0
m_NoLightmaps: 0
m_NoDirLightmap: 0
m_NoForwardAdd: 0
m_ApproxView: 0
m_HalfAsView: 0
m_Expanded: 0
m_PixelGraph:
m_SerializableNodes:
- typeInfo:
fullName: UnityEngine.MaterialGraph.PixelShaderNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"8539a9b8-41b7-4729-94ac-6f25b1d5efa3\",\n
\ \"m_Name\": \"PixelMaster\",\n \"m_DrawData\": {\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\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Albedo\\\",\\n \\\"m_SlotType\\\":
0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 2,\\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\\\":
3,\\n \\\"m_ShaderOutputName\\\": \\\"Albedo\\\"\\n}\"\n },\n
\ {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\":
\\\"Normal\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 2,\\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\\\": 3,\\n \\\"m_ShaderOutputName\\\":
\\\"Normal\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n
\ \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\":
\\\"Emission\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 2,\\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\\\": 3,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Emission\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"Metallic\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Metallic\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"Smoothness\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Smoothness\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\":
\\\"Occlusion\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\":
2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n
\ \\\"m_ShaderOutputName\\\": \\\"Occlusion\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 6,\\n \\\"m_DisplayName\\\":
\\\"Alpha\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"Alpha\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n
\ \"m_SerializedLightFunction\": {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.PBRMetalicLightFunction\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{}\"\n }\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.TextureNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"3c5c7d01-2fd6-44a8-b3e7-148190b0ecde\",\n
\ \"m_Name\": \"Texture\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -620.0,\n \"y\": -121.0,\n \"width\":
22.0,\n \"height\": 263.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\\\": \\\"RGBA\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\":
4,\\n \\\"m_ShaderOutputName\\\": \\\"RGBA\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"R\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"R\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"G\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"G\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"B\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"B\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\": \\\"A\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"A\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\":
\\\"UV\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 3,\\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\\\": 2,\\n \\\"m_ShaderOutputName\\\":
\\\"UV\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n \"m_PropertyName\":
\"\",\n \"m_Description\": \"\",\n \"m_Exposed\": 1,\n \"m_SerializedTexture\":
\"{\\n \\\"texture\\\": {\\n \\\"fileID\\\": 2800000,\\n \\\"guid\\\":
\\\"e0ac3a897e9bf5d40ac1eb6a44a7ab21\\\",\\n \\\"type\\\": 3\\n }\\n}\",\n
\ \"m_TextureType\": 0\n}"
- typeInfo:
fullName: UnityEngine.MaterialGraph.TextureNode
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_GuidSerialized\": \"16289dee-283c-42df-8430-70d7e1342db3\",\n
\ \"m_Name\": \"Texture\",\n \"m_DrawData\": {\n \"m_Expanded\":
true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n
\ \"x\": -513.0,\n \"y\": 338.0,\n \"width\":
112.0,\n \"height\": 69.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\\\": \\\"RGBA\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 1,\\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\\\":
4,\\n \\\"m_ShaderOutputName\\\": \\\"RGBA\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\":
\\\"R\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"R\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"G\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"G\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\":
\\\"B\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 4,\\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\\\": 1,\\n \\\"m_ShaderOutputName\\\":
\\\"B\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\":
\"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\":
\"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n
\ \\\"m_Id\\\": 5,\\n \\\"m_DisplayName\\\": \\\"A\\\",\\n \\\"m_SlotType\\\":
1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_ValueType\\\": 4,\\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\\\":
1,\\n \\\"m_ShaderOutputName\\\": \\\"A\\\"\\n}\"\n },\n {\n
\ \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n
\ \"assemblyName\": \"Assembly-CSharp\"\n },\n
\ \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\":
\\\"UV\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n
\ \\\"m_ValueType\\\": 3,\\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\\\": 2,\\n \\\"m_ShaderOutputName\\\":
\\\"UV\\\"\\n}\"\n }\n ],\n \"m_OutputPrecision\": 1,\n \"m_PropertyName\":
\"\",\n \"m_Description\": \"\",\n \"m_Exposed\": 1,\n \"m_SerializedTexture\":
\"{\\n \\\"texture\\\": {\\n \\\"fileID\\\": 2800000,\\n \\\"guid\\\":
\\\"556373d2abe91394795e2c7b920330f0\\\",\\n \\\"type\\\": 3\\n }\\n}\",\n
\ \"m_TextureType\": 3\n}"
m_SerializableEdges:
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\":
\"3c5c7d01-2fd6-44a8-b3e7-148190b0ecde\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"8539a9b8-41b7-4729-94ac-6f25b1d5efa3\"\n
\ }\n}"
- typeInfo:
fullName: UnityEngine.Graphing.Edge
assemblyName: Assembly-CSharp
JSONnodeData: "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\":
\"16289dee-283c-42df-8430-70d7e1342db3\"\n },\n \"m_InputSlot\": {\n
\ \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"8539a9b8-41b7-4729-94ac-6f25b1d5efa3\"\n
\ }\n}"
m_Name:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/new.ShaderGraph.meta


fileFormatVersion: 2
guid: eea9c141cf904494f8038d7148c31f9b
timeCreated: 1470912443
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

36
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/something.ShaderGraph


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 562bd27a5e73fc64d80a1d9d936ffbd5, type: 3}
m_Name: something
m_EditorClassIdentifier:
m_MaterialGraph:
m_MaterialOptions:
m_SrcBlend: 0
m_DstBlend: 1
m_CullMode: 0
m_ZTest: 2
m_ZWrite: 0
m_RenderQueue: 1
m_RenderType: 0
m_ShadowPass: 0
m_FullForwardShadows: 0
m_NoAmbient: 0
m_NoVertexLights: 0
m_NoLightmaps: 0
m_NoDirLightmap: 0
m_NoForwardAdd: 0
m_ApproxView: 0
m_HalfAsView: 0
m_Expanded: 0
m_PixelGraph:
m_SerializableNodes: []
m_SerializableEdges: []
m_Name:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/something.ShaderGraph.meta


fileFormatVersion: 2
guid: 77154e36df4ac4c88b3ede1e4169e2e9
timeCreated: 1477575321
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

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

正在加载...
取消
保存