浏览代码

Run `hg format` on repository

/main
Peter Bay Bastian 7 年前
当前提交
7e160ce8
共有 204 个文件被更改,包括 1455 次插入1439 次删除
  1. 40
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/IntegrationTests/SerializationTests.cs
  2. 1
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Assets/IGraphAsset.cs
  3. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs
  4. 10
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs
  5. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/GraphDrawingData.cs
  6. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Util/PooledObject.cs
  7. 16
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Util/SerializationHelper.cs
  8. 68
      MaterialGraphProject/Assets/NewNodes/ChannelBlendNode.cs
  9. 16
      MaterialGraphProject/Assets/NewNodes/CommonMatrixType.cs
  10. 4
      MaterialGraphProject/Assets/NewNodes/ConstantType.cs
  11. 12
      MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs
  12. 3
      MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs
  13. 18
      MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs
  14. 11
      MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs
  15. 3
      MaterialGraphProject/Assets/NewNodes/FractalNode.cs
  16. 108
      MaterialGraphProject/Assets/NewNodes/FunctionNAddNode.cs
  17. 306
      MaterialGraphProject/Assets/NewNodes/FunctionNInNOut.cs
  18. 3
      MaterialGraphProject/Assets/NewNodes/Keep/BlendModeNode.cs
  19. 2
      MaterialGraphProject/Assets/NewNodes/Keep/BlendModesEnum.cs
  20. 2
      MaterialGraphProject/Assets/NewNodes/Keep/ColorBalanceNode.cs
  21. 3
      MaterialGraphProject/Assets/NewNodes/Keep/ConstantsNode.cs
  22. 6
      MaterialGraphProject/Assets/NewNodes/Keep/GradientField.cs
  23. 11
      MaterialGraphProject/Assets/NewNodes/Keep/GradientNode.cs
  24. 97
      MaterialGraphProject/Assets/NewNodes/Keep/GradientWrapper.cs
  25. 2
      MaterialGraphProject/Assets/NewNodes/Keep/HeightToNormalNode.cs
  26. 54
      MaterialGraphProject/Assets/NewNodes/Keep/LightProbeNode.cs
  27. 11
      MaterialGraphProject/Assets/NewNodes/Keep/ParallaxNode.cs
  28. 3
      MaterialGraphProject/Assets/NewNodes/Keep/RadialShearNode.cs
  29. 2
      MaterialGraphProject/Assets/NewNodes/Keep/RandomRangeNode.cs
  30. 4
      MaterialGraphProject/Assets/NewNodes/Keep/ReciprocalSqrtNode.cs
  31. 56
      MaterialGraphProject/Assets/NewNodes/Keep/ReflectionProbeNode.cs
  32. 3
      MaterialGraphProject/Assets/NewNodes/Keep/SamplerStateNode.cs
  33. 3
      MaterialGraphProject/Assets/NewNodes/Keep/ScaleOffsetNode.cs
  34. 9
      MaterialGraphProject/Assets/NewNodes/Keep/Texture2DNode.cs
  35. 22
      MaterialGraphProject/Assets/NewNodes/Keep/TextureSamplerNode.cs
  36. 363
      MaterialGraphProject/Assets/NewNodes/Keep/TransformNode.cs
  37. 377
      MaterialGraphProject/Assets/NewNodes/Keep/UVTriPlanar.cs
  38. 3
      MaterialGraphProject/Assets/NewNodes/Kill/AACheckerBoard3dNode.cs
  39. 2
      MaterialGraphProject/Assets/NewNodes/Kill/AACheckerBoardNode.cs
  40. 9
      MaterialGraphProject/Assets/NewNodes/Kill/MultiLayerParallaxNode.cs
  41. 3
      MaterialGraphProject/Assets/NewNodes/Kill/POMNode.cs
  42. 262
      MaterialGraphProject/Assets/NewNodes/Kill/ScatterNode.cs
  43. 2
      MaterialGraphProject/Assets/NewNodes/Kill/SphereWarpNode.cs
  44. 2
      MaterialGraphProject/Assets/NewNodes/Kill/SphericalIndentationNode.cs
  45. 22
      MaterialGraphProject/Assets/NewNodes/Kill/ToggleNode.cs
  46. 2
      MaterialGraphProject/Assets/NewNodes/Kill/VertexNormalNode.cs
  47. 6
      MaterialGraphProject/Assets/NewNodes/Kill/VertexPositionNode.cs
  48. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateRemapGraph.cs
  49. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
  50. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  51. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Clicker.cs
  52. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs
  53. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/AbstractNodeInspector.cs
  54. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/PropertyNodeInspector.cs
  55. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs
  56. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphInspectorPresenter.cs
  57. 48
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  58. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs
  59. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ColorNodePresenter.cs
  60. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CubemapNodePresenter.cs
  61. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CustomCodeNodePresenter.cs
  62. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/GradientNodePresenter.cs
  63. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/IfNodePresenter.cs
  64. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MasterNodePresenter.cs
  65. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MatrixCommonNodePresenter.cs
  66. 60
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/RemapInputNodePresenter.cs
  67. 64
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/RemapMasterNodePresenter.cs
  68. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerAssetNodePresenter.cs
  69. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerStateNodePresenter.cs
  70. 58
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ScatterNodePresenter.cs
  71. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs
  72. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureAssetNodePresenter.cs
  73. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureLODNodePresenter.cs
  74. 74
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureNodePresenter.cs
  75. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureSamplerNodePresenter.cs
  76. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/UVNodePresenter.cs
  77. 84
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector1NodePresenter.cs
  78. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TitleBarPresenter.cs
  79. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  80. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphInspectorView.cs
  81. 29
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
  82. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/TitleBarButtonView.cs
  83. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/TitleBarView.cs
  84. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
  85. 24
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs
  86. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporterEditor.cs
  87. 50
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/Checkerboard.shader
  88. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs
  89. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs
  90. 33
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs
  91. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyChunkTests.cs
  92. 132
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs
  93. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/CopyPasteGraph.cs
  94. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/ScriptableObjectFactory.cs
  95. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/TypeMapper.cs
  96. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/TypeMapping.cs
  97. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraphAsset.cs
  98. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/IMaterialGraphAsset.cs
  99. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
  100. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraphAsset.cs

40
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/IntegrationTests/SerializationTests.cs


get
{
return new SimpleSerializeClass
{
stringValue = "ABCD",
intValue = 5,
floatValue = 7.7f,
arrayValue = new[] {1, 2, 3, 4}
};
{
stringValue = "ABCD",
intValue = 5,
floatValue = 7.7f,
arrayValue = new[] {1, 2, 3, 4}
};
}
}

get
{
return new ChildClassA
{
stringValue = "qwee",
intValue = 5,
floatValue = 6f,
arrayValue = new[] {5, 6, 7, 8},
childString = "CHILD"
};
{
stringValue = "qwee",
intValue = 5,
floatValue = 6f,
arrayValue = new[] {5, 6, 7, 8},
childString = "CHILD"
};
}
}

get
{
return new ChildClassB
{
stringValue = "qwee",
intValue = 5,
floatValue = 6f,
arrayValue = new[] {5, 6, 7, 8},
childInt = 666
};
{
stringValue = "qwee",
intValue = 5,
floatValue = 6f,
arrayValue = new[] {5, 6, 7, 8},
childInt = 666
};
}
}

1
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Assets/IGraphAsset.cs


namespace UnityEngine.Graphing
{
}

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs


Exclude
}
public static void DepthFirstCollectNodesFromNode(List<INode> nodeList, INode node, IncludeSelf includeSelf = IncludeSelf.Include, List<int>slotIds = null)
public static void DepthFirstCollectNodesFromNode(List<INode> nodeList, INode node, IncludeSelf includeSelf = IncludeSelf.Include, List<int> slotIds = null)
{
// no where to start
if (node == null)

var ids = node.GetInputSlots<ISlot>().Select(x => x.id);
if (slotIds != null)
ids = node.GetInputSlots<ISlot>().Where(x => slotIds.Contains(x.id)).Select(x => x.id);
foreach (var slot in ids)
{
foreach (var edge in node.owner.GetEdges(node.GetSlotReference(slot)))

10
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs


public virtual void OnAfterDeserialize()
{
m_Nodes = SerializationHelper.Deserialize<INode>(m_SerializableNodes, GetLegacyTypeRemapping());
foreach (var node in m_Nodes)
{
node.owner = this;
node.UpdateNodeAfterDeserialization ();
}
foreach (var node in m_Nodes)
{
node.owner = this;
node.UpdateNodeAfterDeserialization();
}
m_SerializableNodes = null;

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


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

selection = m_SerializableSelection.Select(x => new Guid(x));
}
}
}
}

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Util/PooledObject.cs


using System;
using System;
namespace UnityEngine.Graphing
{

ReleaseUnmanagedResources();
}
}
}
}

16
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Util/SerializationHelper.cs


public static TypeSerializationInfo GetTypeSerializableAsString(Type type)
{
return new TypeSerializationInfo
{
fullName = type.FullName,
assemblyName = type.Assembly.GetName().Name
};
{
fullName = type.FullName,
assemblyName = type.Assembly.GetName().Name
};
}
private static Type GetTypeFromSerializedString(TypeSerializationInfo typeInfo)

;
return new JSONSerializedElement
{
typeInfo = typeInfo,
JSONnodeData = data
};
{
typeInfo = typeInfo,
JSONnodeData = data
};
}
private static TypeSerializationInfo DoTypeRemap(TypeSerializationInfo info, Dictionary<TypeSerializationInfo, TypeSerializationInfo> remapper)

68
MaterialGraphProject/Assets/NewNodes/ChannelBlendNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
/* [Title("Art/ChannelBlend")]
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction
{
/* [Title("Art/ChannelBlend")]
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction
{
public ChannelBlend()
{
name = "ChannelBlend";
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
public ChannelBlend()
{
name = "ChannelBlend";
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
protected override string GetFunctionName()
{
return "unity_ChannelBlend";
}
protected override string GetFunctionName()
{
return "unity_ChannelBlend";
}
public override bool hasPreview
{
get { return true; }
}
public override bool hasPreview
{
get { return true; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.AddShaderChunk("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false);
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false);
outputString.AddShaderChunk("}", false);
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.AddShaderChunk("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false);
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false);
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}*/
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}*/
}

16
MaterialGraphProject/Assets/NewNodes/CommonMatrixType.cs


namespace UnityEngine.MaterialGraph
namespace UnityEngine.MaterialGraph
{
public enum CommonMatrixType
{

WorldToObject
};
public enum SimpleMatrixType
{
World,
Local,
Tangent,
View
};
public enum SimpleMatrixType
{
World,
Local,
Tangent,
View
};
}

4
MaterialGraphProject/Assets/NewNodes/ConstantType.cs


namespace UnityEngine.MaterialGraph
namespace UnityEngine.MaterialGraph
{
public enum ConstantType
{

E,
SQRT2
};
}
}

12
MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine.MaterialGraph;

cNode.blendMode = (BlendModesEnum)EditorGUILayout.EnumPopup("", cNode.blendMode);
}
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*/
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*/
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.standardVerticalSpacing;

3
MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using UnityEditor.Experimental.UIElements.GraphView;

[Serializable]
class ConstantsContolPresenter : GraphControlPresenter
{
private string[] m_ConstantTypeNames;
private string[] constantTypeNames
{

18
MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

{
base.OnGUIHandler();
var cNode = node as ToggleNode;
var cNode = node as ToggleNode;
cNode.value = EditorGUILayout.Toggle(cNode.value);
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState);
cNode.value = EditorGUILayout.Toggle(cNode.value);
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState);
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*/
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*/
public override float GetHeight()
{
return 2 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;

11
MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs


{
class TransformControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();

return;
//EditorGUILayout.BeginHorizontal ();
tNode.spaceFrom = (SimpleMatrixType)EditorGUILayout.EnumPopup ("From", tNode.spaceFrom);
tNode.spaceTo = (SimpleMatrixType)EditorGUILayout.EnumPopup ("To", tNode.spaceTo);
//EditorGUILayout.BeginHorizontal ();
//EditorGUILayout.BeginHorizontal ();
tNode.spaceFrom = (SimpleMatrixType)EditorGUILayout.EnumPopup("From", tNode.spaceFrom);
tNode.spaceTo = (SimpleMatrixType)EditorGUILayout.EnumPopup("To", tNode.spaceTo);
//EditorGUILayout.BeginHorizontal ();
return (EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
return (EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}

3
MaterialGraphProject/Assets/NewNodes/FractalNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

public FractalNode()
{
name = "Fractal";

108
MaterialGraphProject/Assets/NewNodes/FunctionNAddNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
/* [Title("Math/Advanced/Adder")]
public class AddManyNode : FunctionNInNOut, IGeneratesFunction
{
int m_nodeInputCount = 2;
/* [Title("Math/Advanced/Adder")]
public class AddManyNode : FunctionNInNOut, IGeneratesFunction
{
int m_nodeInputCount = 2;
public void AddInputSlot()
{
string inputName = "Input" + GetInputSlots<MaterialSlot>().Count().ToString();
AddSlot(inputName, inputName, Graphing.SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
public void AddInputSlot()
{
string inputName = "Input" + GetInputSlots<MaterialSlot>().Count().ToString();
AddSlot(inputName, inputName, Graphing.SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
public AddManyNode()
{
name = "Adder";
for(int i = 0; i < m_nodeInputCount; ++i)
{
AddInputSlot();
}
public AddManyNode()
{
name = "Adder";
for(int i = 0; i < m_nodeInputCount; ++i)
{
AddInputSlot();
}
AddSlot("Sum", "finalSum", Graphing.SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
UpdateNodeAfterDeserialization();
}
AddSlot("Sum", "finalSum", Graphing.SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
UpdateNodeAfterDeserialization();
}
public void OnModified()
{
if (onModified != null)
onModified(this, ModificationScope.Node);
}
public void OnModified()
{
if (onModified != null)
onModified(this, ModificationScope.Node);
}
protected override string GetFunctionName()
{
return "unity_Adder";
}
protected override string GetFunctionName()
{
return "unity_Adder";
}
string GetSumOfAllInputs()
{
string sumString = "";
int inputsLeft = GetInputSlots<ISlot>().Count();
string GetSumOfAllInputs()
{
string sumString = "";
int inputsLeft = GetInputSlots<ISlot>().Count();
foreach (ISlot slot in GetInputSlots<ISlot>())
{
sumString += GetShaderOutputName(slot.id);
if (inputsLeft > 1)
sumString += " + ";
--inputsLeft;
}
foreach (ISlot slot in GetInputSlots<ISlot>())
{
sumString += GetShaderOutputName(slot.id);
if (inputsLeft > 1)
sumString += " + ";
--inputsLeft;
}
return sumString;
}
return sumString;
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("finalSum = " + GetSumOfAllInputs() + ";", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("finalSum = " + GetSumOfAllInputs() + ";", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}*/
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}*/
}

306
MaterialGraphProject/Assets/NewNodes/FunctionNInNOut.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
using System.Linq;
using System.Collections;
using System;

/* public abstract class FunctionNInNOut : AbstractMaterialNode, IGeneratesBodyCode
{
/* public abstract class FunctionNInNOut : AbstractMaterialNode, IGeneratesBodyCode
{
public FunctionNInNOut()
{
name = "FunctionNInNOut";
UpdateNodeAfterDeserialization();
}
public FunctionNInNOut()
{
name = "FunctionNInNOut";
UpdateNodeAfterDeserialization();
}
public override void UpdateNodeAfterDeserialization()
{
base.UpdateNodeAfterDeserialization();
foreach (var slot in GetSlots<MaterialSlot>())
{
slot.showValue = true;
}
}
public override void UpdateNodeAfterDeserialization()
{
base.UpdateNodeAfterDeserialization();
foreach (var slot in GetSlots<MaterialSlot>())
{
slot.showValue = true;
}
}
public int AddSlot(string displayName, string nameInShader, SlotType slotType, SlotValueType valueType, Vector4 defaultValue)
{
int nextSlotId;
if (slotType == SlotType.Output)
nextSlotId = -( GetOutputSlots<MaterialSlot>().Count() + 1 );
else
nextSlotId = GetInputSlots<MaterialSlot>().Count() + 1;
public int AddSlot(string displayName, string nameInShader, SlotType slotType, SlotValueType valueType, Vector4 defaultValue)
{
int nextSlotId;
if (slotType == SlotType.Output)
nextSlotId = -( GetOutputSlots<MaterialSlot>().Count() + 1 );
else
nextSlotId = GetInputSlots<MaterialSlot>().Count() + 1;
bool useDefaultValue = (valueType != SlotValueType.Texture2D && valueType != SlotValueType.Sampler2D);
AddSlot(new MaterialSlot(nextSlotId, displayName, nameInShader, slotType, valueType, defaultValue, useDefaultValue));
return nextSlotId;
}
bool useDefaultValue = (valueType != SlotValueType.Texture2D && valueType != SlotValueType.Sampler2D);
AddSlot(new MaterialSlot(nextSlotId, displayName, nameInShader, slotType, valueType, defaultValue, useDefaultValue));
return nextSlotId;
}
public void RemoveOutputSlot()
{
var lastSlotId = -GetOutputSlots<ISlot>().Count();
RemoveSlotById(lastSlotId);
}
public void RemoveOutputSlot()
{
var lastSlotId = -GetOutputSlots<ISlot>().Count();
RemoveSlotById(lastSlotId);
}
public void RemoveInputSlot()
{
var lastSlotId = GetInputSlots<ISlot>().Count();
RemoveSlotById(lastSlotId);
}
public void RemoveInputSlot()
{
var lastSlotId = GetInputSlots<ISlot>().Count();
RemoveSlotById(lastSlotId);
}
private void RemoveSlotById(int slotID)
{
if (slotID == 0)
return;
RemoveSlot(slotID);
}
private void RemoveSlotById(int slotID)
{
if (slotID == 0)
return;
RemoveSlot(slotID);
}
public string GetSlotTypeName(int slotId)
{
return ConvertConcreteSlotValueTypeToString(FindSlot<MaterialSlot>(slotId).concreteValueType);
}
public string GetSlotTypeName(int slotId)
{
return ConvertConcreteSlotValueTypeToString(FindSlot<MaterialSlot>(slotId).concreteValueType);
}
public ConcreteSlotValueType GetSlotValueType(int slotId)
{
return FindSlot<MaterialSlot>(slotId).concreteValueType;
}
public ConcreteSlotValueType GetSlotValueType(int slotId)
{
return FindSlot<MaterialSlot>(slotId).concreteValueType;
}
protected string GetShaderOutputName(int slotId)
{
return FindSlot<MaterialSlot>(slotId).shaderOutputName;
}
protected string GetShaderOutputName(int slotId)
{
return FindSlot<MaterialSlot>(slotId).shaderOutputName;
}
// Must override this
protected abstract string GetFunctionName();
// Must override this
protected abstract string GetFunctionName();
private string GetFunctionParameters()
{
string param = "";
int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
if (inSlot.isOutputSlot)
param += "out ";
private string GetFunctionParameters()
{
string param = "";
int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
if (inSlot.isOutputSlot)
param += "out ";
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.Texture2D
&& FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.SamplerState
&& FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.Sampler2D
)
param += precision;
param += GetSlotTypeName(inSlot.id) + " ";
param += GetShaderOutputName(inSlot.id);
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.Texture2D
&& FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.SamplerState
&& FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.Sampler2D
)
param += precision;
param += GetSlotTypeName(inSlot.id) + " ";
param += GetShaderOutputName(inSlot.id);
if (remainingParams > 1)
param += ", ";
--remainingParams;
}
if (remainingParams > 1)
param += ", ";
--remainingParams;
}
return param;
}
return param;
}
private string GetFunctionCallParameters(GenerationMode generationMode)
{
string param = "";
int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
private string GetFunctionCallParameters(GenerationMode generationMode)
{
string param = "";
int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType == ConcreteSlotValueType.SamplerState)
param += GetSamplerInput(inSlot.id);
else
param += GetSlotValue(inSlot.id, generationMode);
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType == ConcreteSlotValueType.SamplerState)
param += GetSamplerInput(inSlot.id);
else
param += GetSlotValue(inSlot.id, generationMode);
if (remainingParams > 1)
param += ", ";
--remainingParams;
}
if (remainingParams > 1)
param += ", ";
--remainingParams;
}
return param;
}
return param;
}
protected string GetFunctionPrototype()
{
return "inline " + "void" + " " + GetFunctionName() +
" (" +
GetFunctionParameters() +
")";
}
protected string GetFunctionPrototype()
{
return "inline " + "void" + " " + GetFunctionName() +
" (" +
GetFunctionParameters() +
")";
}
protected virtual string GetFunctionCall(GenerationMode generationMode)
{
string prefix = "";
string sufix = "";
foreach (ISlot slot in GetInputSlots<MaterialSlot>())
{
if (GetSlotValueType(slot.id) == ConcreteSlotValueType.Texture2D || GetSlotValueType(slot.id) == ConcreteSlotValueType.SamplerState)
{
prefix = "#ifdef UNITY_COMPILER_HLSL \n";
sufix = "\n #endif";
}
}
return prefix + GetFunctionName() +
" (" +
GetFunctionCallParameters(generationMode) +
");" + sufix;
}
protected virtual string GetFunctionCall(GenerationMode generationMode)
{
string prefix = "";
string sufix = "";
foreach (ISlot slot in GetInputSlots<MaterialSlot>())
{
if (GetSlotValueType(slot.id) == ConcreteSlotValueType.Texture2D || GetSlotValueType(slot.id) == ConcreteSlotValueType.SamplerState)
{
prefix = "#ifdef UNITY_COMPILER_HLSL \n";
sufix = "\n #endif";
}
}
return prefix + GetFunctionName() +
" (" +
GetFunctionCallParameters(generationMode) +
");" + sufix;
}
private string GetOutputDeclaration()
{
string outDeclaration = "";
foreach (MaterialSlot outSlot in GetOutputSlots<MaterialSlot>())
{
outDeclaration += "\n " + precision + GetSlotTypeName(outSlot.id) + " " + GetVariableNameForSlot(outSlot.id) + ";\n";
}
private string GetOutputDeclaration()
{
string outDeclaration = "";
foreach (MaterialSlot outSlot in GetOutputSlots<MaterialSlot>())
{
outDeclaration += "\n " + precision + GetSlotTypeName(outSlot.id) + " " + GetVariableNameForSlot(outSlot.id) + ";\n";
}
return outDeclaration;
}
return outDeclaration;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetOutputDeclaration(), false);
outputString.AddShaderChunk(GetFunctionCall(generationMode), false);
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetOutputDeclaration(), false);
outputString.AddShaderChunk(GetFunctionCall(generationMode), false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
public string GetSamplerInput(int slotID)
{
//default sampler if no input is provided
var samplerName = "my_linear_repeat_sampler";
public string GetSamplerInput(int slotID)
{
//default sampler if no input is provided
var samplerName = "my_linear_repeat_sampler";
//Sampler input slot
var samplerSlot = FindInputSlot<MaterialSlot>(slotID);
//Sampler input slot
var samplerSlot = FindInputSlot<MaterialSlot>(slotID);
if (samplerSlot != null)
{
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList();
if (samplerSlot != null)
{
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList();
if (edgesSampler.Count > 0)
{
var edge = edgesSampler[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true);
}
}
if (edgesSampler.Count > 0)
{
var edge = edgesSampler[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true);
}
}
return samplerName;
}
}*/
return samplerName;
}
}*/
}

3
MaterialGraphProject/Assets/NewNodes/Keep/BlendModeNode.cs


using System.Reflection;
using System.Reflection;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

}
}
}

2
MaterialGraphProject/Assets/NewNodes/Keep/BlendModesEnum.cs


namespace UnityEngine.MaterialGraph
namespace UnityEngine.MaterialGraph
{
public enum BlendModesEnum
{

2
MaterialGraphProject/Assets/NewNodes/Keep/ColorBalanceNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

3
MaterialGraphProject/Assets/NewNodes/Keep/ConstantsNode.cs


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

public class ConstantsNode : PropertyNode, IGeneratesBodyCode
{
static Dictionary<ConstantType, float> m_constantList = new Dictionary<ConstantType, float>
{
{ConstantType.PI, 3.1415926f },

6
MaterialGraphProject/Assets/NewNodes/Keep/GradientField.cs


using UnityEngine;
using UnityEngine;
using UnityEditor;
using System.Reflection;

public static class GUIGradientField
{
#region Initial Setup
private static MethodInfo s_miGradientField1;

return gradient;
}
}
}

11
MaterialGraphProject/Assets/NewNodes/Keep/GradientNode.cs


using System.Reflection;
using System.Reflection;
using System.Text;
using UnityEngine.Graphing;

onModified(this, ModificationScope.Graph);
}
// Debug.Log("UPDATED GRAPH");
// Debug.Log("UPDATED GRAPH");
}
public GradientNode()

{
return GetType().GetMethod("Unity_Gradient", BindingFlags.NonPublic | BindingFlags.Instance);
}
string Unity_Gradient(
[Slot(0, Binding.None)] Vector1 value,

for (int i = 0; i < colorkeys.Length - 1; i++)
{
int j = i + 1;
outputString.AppendLine(string.Format("\t{{precision}} colorLerpPosition{0}=smoothstep(colorp{0},colorp{1},value);",i,j));
outputString.AppendLine(string.Format("\tgradcolor = lerp(gradcolor,color{0},colorLerpPosition{1});",j, i));
outputString.AppendLine(string.Format("\t{{precision}} colorLerpPosition{0}=smoothstep(colorp{0},colorp{1},value);", i, j));
outputString.AppendLine(string.Format("\tgradcolor = lerp(gradcolor,color{0},colorLerpPosition{1});", j, i));
}
//Alpha

{
int j = i + 1;
outputString.AppendLine(string.Format("\t{{precision}} alphaLerpPosition{0}=smoothstep(alphap{0},alphap{1},value);", i, j));
outputString.AppendLine(string.Format("\tgradalpha = lerp(gradalpha,alpha{0},alphaLerpPosition{1});",j, i));
outputString.AppendLine(string.Format("\tgradalpha = lerp(gradalpha,alpha{0},alphaLerpPosition{1});", j, i));
}
//Result

97
MaterialGraphProject/Assets/NewNodes/Keep/GradientWrapper.cs


using UnityEngine;
using UnityEngine;
using UnityEditor;
using System.Reflection;

[System.Serializable]
public class GradientWrapper
{
/// <summary>
/// Wrapper for <c>GradientColorKey</c>.
/// </summary>

public static Type s_tyGradient;
#if (UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
private static MethodInfo s_miEvaluate;
private static PropertyInfo s_piColorKeys;
private static PropertyInfo s_piAlphaKeys;
private static Type s_tyGradientColorKey;
private static Type s_tyGradientAlphaKey;
private static MethodInfo s_miEvaluate;
private static PropertyInfo s_piColorKeys;
private static PropertyInfo s_piAlphaKeys;
private static Type s_tyGradientColorKey;
private static Type s_tyGradientAlphaKey;
#endif
/// <summary>

{
#if (UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
Assembly editorAssembly = typeof(Editor).Assembly;
s_tyGradientColorKey = editorAssembly.GetType("UnityEditor.GradientColorKey");
s_tyGradientAlphaKey = editorAssembly.GetType("UnityEditor.GradientAlphaKey");
// Note that `Gradient` is defined in the editor namespace in Unity 3.5.7!
s_tyGradient = editorAssembly.GetType("UnityEditor.Gradient");
s_miEvaluate = s_tyGradient.GetMethod("CalcColor", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(float) }, null);
s_piColorKeys = s_tyGradient.GetProperty("colorKeys", BindingFlags.Public | BindingFlags.Instance);
s_piAlphaKeys = s_tyGradient.GetProperty("alphaKeys", BindingFlags.Public | BindingFlags.Instance);
Assembly editorAssembly = typeof(Editor).Assembly;
s_tyGradientColorKey = editorAssembly.GetType("UnityEditor.GradientColorKey");
s_tyGradientAlphaKey = editorAssembly.GetType("UnityEditor.GradientAlphaKey");
// Note that `Gradient` is defined in the editor namespace in Unity 3.5.7!
s_tyGradient = editorAssembly.GetType("UnityEditor.Gradient");
s_miEvaluate = s_tyGradient.GetMethod("CalcColor", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(float) }, null);
s_piColorKeys = s_tyGradient.GetProperty("colorKeys", BindingFlags.Public | BindingFlags.Instance);
s_piAlphaKeys = s_tyGradient.GetProperty("alphaKeys", BindingFlags.Public | BindingFlags.Instance);
#else
// In Unity 4 this is easy :)
s_tyGradient = typeof(Gradient);

#if (UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
#region Unity 3.5.7 Implementation
private object _gradient = Activator.CreateInstance(s_tyGradient);
public object GradientData {
get { return _gradient; }
set { _gradient = value; }
}
public Color Evaluate(float time) {
return (Color)s_miEvaluate.Invoke(_gradient, new object[] { time });
}
public void SetKeys(ColorKey[] colorKeys, AlphaKey[] alphaKeys) {
if (colorKeys != null) {
Array colorKeyParam = (Array)Activator.CreateInstance(s_tyGradientColorKey.MakeArrayType(), new object[] { colorKeys.Length });
for (int i = 0; i < colorKeys.Length; ++i)
colorKeyParam.SetValue(Activator.CreateInstance(s_tyGradientColorKey, colorKeys[i].color, colorKeys[i].time), i);
s_piColorKeys.SetValue(_gradient, colorKeyParam, null);
}
if (alphaKeys != null) {
Array alphaKeyParam = (Array)Activator.CreateInstance(s_tyGradientAlphaKey.MakeArrayType(), new object[] { alphaKeys.Length });
for (int i = 0; i < alphaKeys.Length; ++i)
alphaKeyParam.SetValue(Activator.CreateInstance(s_tyGradientAlphaKey, alphaKeys[i].alpha, alphaKeys[i].time), i);
s_piAlphaKeys.SetValue(_gradient, alphaKeyParam, null);
}
}
private object _gradient = Activator.CreateInstance(s_tyGradient);
public object GradientData
{
get { return _gradient; }
set { _gradient = value; }
}
public Color Evaluate(float time)
{
return (Color)s_miEvaluate.Invoke(_gradient, new object[] { time });
}
public void SetKeys(ColorKey[] colorKeys, AlphaKey[] alphaKeys)
{
if (colorKeys != null)
{
Array colorKeyParam = (Array)Activator.CreateInstance(s_tyGradientColorKey.MakeArrayType(), new object[] { colorKeys.Length });
for (int i = 0; i < colorKeys.Length; ++i)
colorKeyParam.SetValue(Activator.CreateInstance(s_tyGradientColorKey, colorKeys[i].color, colorKeys[i].time), i);
s_piColorKeys.SetValue(_gradient, colorKeyParam, null);
}
if (alphaKeys != null)
{
Array alphaKeyParam = (Array)Activator.CreateInstance(s_tyGradientAlphaKey.MakeArrayType(), new object[] { alphaKeys.Length });
for (int i = 0; i < alphaKeys.Length; ++i)
alphaKeyParam.SetValue(Activator.CreateInstance(s_tyGradientAlphaKey, alphaKeys[i].alpha, alphaKeys[i].time), i);
s_piAlphaKeys.SetValue(_gradient, alphaKeyParam, null);
}
}
#endregion
#else
#region Unity 4.x Implementation

#endregion
#endif
}
}

2
MaterialGraphProject/Assets/NewNodes/Keep/HeightToNormalNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

54
MaterialGraphProject/Assets/NewNodes/Keep/LightProbeNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Scene Data/Light Probe")]
public class LightProbeNode : CodeFunctionNode
{
public override bool hasPreview { get { return false; } }
[Title("Input/Scene Data/Light Probe")]
public class LightProbeNode : CodeFunctionNode
{
public override bool hasPreview { get { return false; } }
public LightProbeNode()
{
name = "LightProbe";
}
public LightProbeNode()
{
name = "LightProbe";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_LightProbe", BindingFlags.Static | BindingFlags.NonPublic);
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_LightProbe", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_LightProbe(
[Slot(0, Binding.Normal)] Vector3 worldSpaceNormal,
[Slot(1, Binding.None)] out Vector4 color)
{
color = Vector4.one;
return
@"
static string Unity_LightProbe(
[Slot(0, Binding.Normal)] Vector3 worldSpaceNormal,
[Slot(1, Binding.None)] out Vector4 color)
{
color = Vector4.one;
return
@"
}
}
public override PreviewMode previewMode {
get {
return PreviewMode.Preview3D;
}
}
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
}
}

11
MaterialGraphProject/Assets/NewNodes/Keep/ParallaxNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector4.zero);
}
precision + " " + arg1Name + ", " +
precision + " " + arg1Name + ", " +
precision + "2 " + arg2Name + ", " +
precision + "3 " + arg3Name + ")";
}

protected virtual string GetFunctionCallBody(string inputValue1)
{
var channel = UVChannel.uv0;
return GetFunctionName() + " (" +
inputValue1 + ", " +
channel.GetUVName() + ", " +

{
return channel == UVChannel.uv0;
}
public bool RequiresViewDirectionTangentSpace()
{
return true;

3
MaterialGraphProject/Assets/NewNodes/Keep/RadialShearNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

";
}
}
}

2
MaterialGraphProject/Assets/NewNodes/Keep/RandomRangeNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

4
MaterialGraphProject/Assets/NewNodes/Keep/ReciprocalSqrtNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

}
}
}

56
MaterialGraphProject/Assets/NewNodes/Keep/ReflectionProbeNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Scene Data/Reflection Probe")]
public class ReflectionProbeNode : CodeFunctionNode
{
public ReflectionProbeNode()
{
name = "ReflectionProbe";
}
[Title("Input/Scene Data/Reflection Probe")]
public class ReflectionProbeNode : CodeFunctionNode
{
public ReflectionProbeNode()
{
name = "ReflectionProbe";
}
public override PreviewMode previewMode {
get {
return PreviewMode.Preview3D;
}
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_ReflectionProbe", BindingFlags.Static | BindingFlags.NonPublic);
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_ReflectionProbe", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_ReflectionProbe(
[Slot(0, Binding.ViewDirection)] Vector3 viewDirection,
[Slot(1, Binding.Normal)] Vector3 worldSpaceNormal,
[Slot(2, Binding.None)] Vector1 lod,
[Slot(3, Binding.None)] out Vector4 color)
{
color = Vector4.one;
return
@"
static string Unity_ReflectionProbe(
[Slot(0, Binding.ViewDirection)] Vector3 viewDirection,
[Slot(1, Binding.Normal)] Vector3 worldSpaceNormal,
[Slot(2, Binding.None)] Vector1 lod,
[Slot(3, Binding.None)] out Vector4 color)
{
color = Vector4.one;
return
@"
}
}
}
}
}

3
MaterialGraphProject/Assets/NewNodes/Keep/SamplerStateNode.cs


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

public class SamplerStateNode : AbstractMaterialNode
{
public enum FilterMode
{
Linear,

3
MaterialGraphProject/Assets/NewNodes/Keep/ScaleOffsetNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

}
";
}
}
}

9
MaterialGraphProject/Assets/NewNodes/Keep/Texture2DNode.cs


using System;
using System;
using System.Collections.Generic;
using System.Linq;
#if UNITY_EDITOR

defaultTexture, m_TextureType,
PropertyChunk.HideState.Visible,
exposedState == ExposedState.Exposed ?
TexturePropertyChunk.ModifiableState.Modifiable
: TexturePropertyChunk.ModifiableState.NonModifiable));
TexturePropertyChunk.ModifiableState.Modifiable
: TexturePropertyChunk.ModifiableState.NonModifiable));
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
var slotTexture2D = FindOutputSlot<MaterialSlot>(0);

}
}
public override PreviewProperty GetPreviewProperty()
{

}
public override PropertyType propertyType { get { return PropertyType.Texture; } }
}
}

22
MaterialGraphProject/Assets/NewNodes/Keep/TextureSamplerNode.cs


using System.Linq;
using System.Linq;
public const int OutputSlotId = 0;
public const int TextureInputId = 1;
public const int UVInput = 2;

#else
{0}4 {1} = UNITY_SAMPLE_TEX2D({2}, {4});
#endif"
, precision
, GetVariableNameForSlot(OutputSlotId)
, GetSlotValue(TextureInputId, generationMode)
, GetSlotValue(SamplerInput, generationMode)
, uvName);
, precision
, GetVariableNameForSlot(OutputSlotId)
, GetSlotValue(TextureInputId, generationMode)
, GetSlotValue(SamplerInput, generationMode)
, uvName);
, precision
, GetVariableNameForSlot(OutputSlotId)
, GetSlotValue(TextureInputId, generationMode)
, uvName);
, precision
, GetVariableNameForSlot(OutputSlotId)
, GetSlotValue(TextureInputId, generationMode)
, uvName);
}
visitor.AddShaderChunk(result, true);
}

363
MaterialGraphProject/Assets/NewNodes/Keep/TransformNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
[Title ("Math/Vector/Transform")]
public class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal
{
[SerializeField]
private SimpleMatrixType m_spaceListFrom;
[SerializeField]
private SimpleMatrixType m_spaceListTo;
[Title("Math/Vector/Transform")]
public class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal
{
[SerializeField]
private SimpleMatrixType m_spaceListFrom;
[SerializeField]
private SimpleMatrixType m_spaceListTo;
private const int InputSlotId = 0;
private const int OutputSlotId = 1;
private const string kInputSlotName = "Input";
private const string kOutputSlotName = "Output";
private const int InputSlotId = 0;
private const int OutputSlotId = 1;
private const string kInputSlotName = "Input";
private const string kOutputSlotName = "Output";
public SimpleMatrixType spaceFrom
{
get { return m_spaceListFrom; }
set
{
if (m_spaceListFrom == value)
return;
public SimpleMatrixType spaceFrom
{
get { return m_spaceListFrom; }
set
{
if (m_spaceListFrom == value)
return;
m_spaceListFrom = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
m_spaceListFrom = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public override bool hasPreview
{
get { return false; }
}
public override bool hasPreview
{
get { return false; }
}
public SimpleMatrixType spaceTo
{
get { return m_spaceListTo; }
set
{
if (m_spaceListTo == value)
return;
public SimpleMatrixType spaceTo
{
get { return m_spaceListTo; }
set
{
if (m_spaceListTo == value)
return;
m_spaceListTo = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
m_spaceListTo = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public TransformNode ()
{
name = "Transform";
UpdateNodeAfterDeserialization ();
}
public TransformNode()
{
name = "Transform";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputSlot());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputSlot());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] {InputSlotId, OutputSlotId}; }
}
protected int[] validSlots
{
get { return new[] {InputSlotId, OutputSlotId}; }
}
protected virtual MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero);
}
protected virtual MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero);
}
protected virtual MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
protected virtual MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
protected virtual string GetInputSlotName()
{
return "Input";
}
protected virtual string GetInputSlotName()
{
return "Input";
}
protected virtual string GetOutputSlotName()
{
return "Output";
}
protected virtual string GetOutputSlotName()
{
return "Output";
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId });
string inputValue = GetSlotValue(InputSlotId, generationMode);
string transformString = "";
bool requiresTangentTransform = false;
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId });
string inputValue = GetSlotValue(InputSlotId, generationMode);
string transformString = "";
bool requiresTangentTransform = false;
if(spaceFrom == SimpleMatrixType.World){
if (spaceTo == SimpleMatrixType.World) {
transformString = inputValue;
} else if (spaceTo == SimpleMatrixType.Local) {
transformString = "mul(unity_WorldToObject, float4(" + inputValue + ", 0)).xyz";
} else if (spaceTo == SimpleMatrixType.Tangent) {
requiresTangentTransform = true;
transformString = "mul(tangentTransform, " + inputValue + ").xyz";
} else if (spaceTo == SimpleMatrixType.View) {
transformString = "mul( UNITY_MATRIX_V, float4(" + inputValue + ", 0)).xyz";
}
}else if(spaceFrom == SimpleMatrixType.Local){
if (spaceTo == SimpleMatrixType.World) {
transformString = "mul(unity_ObjectToWorld, float4(" + inputValue + ", 0)).xyz";
} else if (spaceTo == SimpleMatrixType.Local) {
transformString = inputValue;
} else if (spaceTo == SimpleMatrixType.Tangent) {
requiresTangentTransform = true;
transformString = "mul( tangentTransform, mul( unity_ObjectToWorld, float4(" + inputValue + ", 0) ).xyz).xyz";
} else if (spaceTo == SimpleMatrixType.View) {
transformString = "mul( UNITY_MATRIX_MV, float4(" + inputValue + ", 0)).xyz";
}
}else if(spaceFrom == SimpleMatrixType.Tangent){
requiresTangentTransform = true;
if (spaceTo == SimpleMatrixType.World) {
transformString = "mul( " + inputValue + ", tangentTransform ).xyz";
} else if (spaceTo == SimpleMatrixType.Local) {
transformString = "mul( unity_WorldToObject, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz";
} else if (spaceTo == SimpleMatrixType.Tangent) {
transformString = inputValue;
} else if (spaceTo == SimpleMatrixType.View) {
transformString = "mul( UNITY_MATRIX_V, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz";
}
}else if(spaceFrom == SimpleMatrixType.View){
if (spaceTo == SimpleMatrixType.World) {
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz";
} else if (spaceTo == SimpleMatrixType.Local) {
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_MV ).xyz";
} else if (spaceTo == SimpleMatrixType.Tangent) {
requiresTangentTransform = true;
transformString = "mul( tangentTransform, mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz ).xyz";
} else if (spaceTo == SimpleMatrixType.View) {
transformString = inputValue;
}
}
if (spaceFrom == SimpleMatrixType.World)
{
if (spaceTo == SimpleMatrixType.World)
{
transformString = inputValue;
}
else if (spaceTo == SimpleMatrixType.Local)
{
transformString = "mul(unity_WorldToObject, float4(" + inputValue + ", 0)).xyz";
}
else if (spaceTo == SimpleMatrixType.Tangent)
{
requiresTangentTransform = true;
transformString = "mul(tangentTransform, " + inputValue + ").xyz";
}
else if (spaceTo == SimpleMatrixType.View)
{
transformString = "mul( UNITY_MATRIX_V, float4(" + inputValue + ", 0)).xyz";
}
}
else if (spaceFrom == SimpleMatrixType.Local)
{
if (spaceTo == SimpleMatrixType.World)
{
transformString = "mul(unity_ObjectToWorld, float4(" + inputValue + ", 0)).xyz";
}
else if (spaceTo == SimpleMatrixType.Local)
{
transformString = inputValue;
}
else if (spaceTo == SimpleMatrixType.Tangent)
{
requiresTangentTransform = true;
transformString = "mul( tangentTransform, mul( unity_ObjectToWorld, float4(" + inputValue + ", 0) ).xyz).xyz";
}
else if (spaceTo == SimpleMatrixType.View)
{
transformString = "mul( UNITY_MATRIX_MV, float4(" + inputValue + ", 0)).xyz";
}
}
else if (spaceFrom == SimpleMatrixType.Tangent)
{
requiresTangentTransform = true;
if (spaceTo == SimpleMatrixType.World)
{
transformString = "mul( " + inputValue + ", tangentTransform ).xyz";
}
else if (spaceTo == SimpleMatrixType.Local)
{
transformString = "mul( unity_WorldToObject, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz";
}
else if (spaceTo == SimpleMatrixType.Tangent)
{
transformString = inputValue;
}
else if (spaceTo == SimpleMatrixType.View)
{
transformString = "mul( UNITY_MATRIX_V, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz";
}
}
else if (spaceFrom == SimpleMatrixType.View)
{
if (spaceTo == SimpleMatrixType.World)
{
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz";
}
else if (spaceTo == SimpleMatrixType.Local)
{
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_MV ).xyz";
}
else if (spaceTo == SimpleMatrixType.Tangent)
{
requiresTangentTransform = true;
transformString = "mul( tangentTransform, mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz ).xyz";
}
else if (spaceTo == SimpleMatrixType.View)
{
transformString = inputValue;
}
}
if(requiresTangentTransform)
visitor.AddShaderChunk ("float3x3 tangentTransform = float3x3( worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);", false);
if (requiresTangentTransform)
visitor.AddShaderChunk("float3x3 tangentTransform = float3x3( worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);", false);
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + transformString + ";", true);
}
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + transformString + ";", true);
}
//float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);------
//float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);------
//mul(unity_WorldToObject, float4(i.posWorld.rgb,0) ).xyz - world to local---------
//mul( tangentTransform, i.posWorld.rgb ).xyz - world to tangent-----------------
//mul( UNITY_MATRIX_V, float4(i.posWorld.rgb,0) ).xyz - world to view-------------
//mul(unity_WorldToObject, float4(i.posWorld.rgb,0) ).xyz - world to local---------
//mul( tangentTransform, i.posWorld.rgb ).xyz - world to tangent-----------------
//mul( UNITY_MATRIX_V, float4(i.posWorld.rgb,0) ).xyz - world to view-------------
//mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to world--------
//mul( tangentTransform, mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to tangent------------
//mul( UNITY_MATRIX_MV, float4(i.posWorld.rgb,0) ).xyz - local to view--------------
//mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to world--------
//mul( tangentTransform, mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to tangent------------
//mul( UNITY_MATRIX_MV, float4(i.posWorld.rgb,0) ).xyz - local to view--------------
//mul( i.posWorld.rgb, tangentTransform ).xyz - tangent to world---------
//mul( unity_WorldToObject, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to local-----
//mul( UNITY_MATRIX_V, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to view-------
//mul( i.posWorld.rgb, tangentTransform ).xyz - tangent to world---------
//mul( unity_WorldToObject, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to local-----
//mul( UNITY_MATRIX_V, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to view-------
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz - view to world
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz - view to world
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
private string inputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); }
}
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
private string inputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); }
}
public bool RequiresTangent()
{
return true;
}
public bool RequiresTangent()
{
return true;
}
public bool RequiresBitangent()
{
return true;
}
public bool RequiresBitangent()
{
return true;
}
public bool RequiresNormal(){
return true;
}
}
public bool RequiresNormal()
{
return true;
}
}

377
MaterialGraphProject/Assets/NewNodes/Keep/UVTriPlanar.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
/* [Title("UV/Tri-Planar Mapping")]
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
{
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0;
/* [Title("UV/Tri-Planar Mapping")]
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
{
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0;
private string slot0Name = "texRef";
private string slot1Name = "tileFactor";
private string slot2Name = "blendFactor";
private string slot4Name = "normalRef";
private string slot5Name = "posRef";
private string slot6Name = "outputRef";
private string slot0Name = "texRef";
private string slot1Name = "tileFactor";
private string slot2Name = "blendFactor";
private string slot4Name = "normalRef";
private string slot5Name = "posRef";
private string slot6Name = "outputRef";
protected override string GetFunctionName()
{
return "unity_triplanar_" + precision;
}
protected override string GetFunctionName()
{
return "unity_triplanar_" + precision;
}
public UVTriPlanar()
{
name = "UVTriPlanar";
public UVTriPlanar()
{
name = "UVTriPlanar";
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Sampler2D, Vector4.zero);
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Sampler2D, Vector4.zero);
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
UpdateNodeAfterDeserialization();
}
public override bool hasPreview
{
get { return true; }
}
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.Indent();
outputString.AddShaderChunk("{", false);
// create UVs from position
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false);
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.Indent();
outputString.AddShaderChunk("{", false);
// create UVs from position
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false);
// use absolute value of normal as texture weights
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false);
// use absolute value of normal as texture weights
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false);
// make sure the weights sum up to 1 (divide by sum of x+y+z)
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false);
// make sure the weights sum up to 1 (divide by sum of x+y+z)
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false);
// read the three texture projections, for x,y,z axes
outputString.AddShaderChunk("float4 cx = " + "tex2D(" + slot0Name + ", uvs.yz);", false);
outputString.AddShaderChunk("float4 cy = " + "tex2D(" + slot0Name + ", uvs.xz);", false);
outputString.AddShaderChunk("float4 cz = " + "tex2D(" + slot0Name + ", uvs.xy);", false);
// read the three texture projections, for x,y,z axes
outputString.AddShaderChunk("float4 cx = " + "tex2D(" + slot0Name + ", uvs.yz);", false);
outputString.AddShaderChunk("float4 cy = " + "tex2D(" + slot0Name + ", uvs.xz);", false);
outputString.AddShaderChunk("float4 cz = " + "tex2D(" + slot0Name + ", uvs.xy);", false);
// blend the textures based on weights
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false);
// blend the textures based on weights
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
//prevent validation errors when a sampler2D input is missing
//use on any input requiring a Texture2DNode
public override void ValidateNode()
{
base.ValidateNode();
var slot = FindInputSlot<MaterialSlot>(0);
if (slot == null)
return;
//prevent validation errors when a sampler2D input is missing
//use on any input requiring a Texture2DNode
public override void ValidateNode()
{
base.ValidateNode();
var slot = FindInputSlot<MaterialSlot>(0);
if (slot == null)
return;
var edges = owner.GetEdges(slot.slotReference).ToList();
hasError |= edges.Count == 0;
}
var edges = owner.GetEdges(slot.slotReference).ToList();
hasError |= edges.Count == 0;
}
public bool RequiresNormal()
{
return true;
}
public bool RequiresNormal()
{
return true;
}
public bool RequiresWorldPosition()
{
return true;
}
}
}
public bool RequiresWorldPosition()
{
return true;
}
}
}
///////////////// TEXTURE2D version below. Works fine, but the master nodes don't jive with it //////////////////////////
///////////////// TEXTURE2D version below. Works fine, but the master nodes don't jive with it //////////////////////////
/*
/*
namespace UnityEngine.MaterialGraph
{
[Title("UV/Tri-Planar Mapping")]
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
{
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0;
namespace UnityEngine.MaterialGraph
{
[Title("UV/Tri-Planar Mapping")]
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
{
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0;
private string slot0Name = "texRef";
private string slot1Name = "tileFactor";
private string slot2Name = "blendFactor";
private string slot3Name = "samplerRef";
private string slot4Name = "normalRef";
private string slot5Name = "posRef";
private string slot6Name = "outputRef";
private string slot0Name = "texRef";
private string slot1Name = "tileFactor";
private string slot2Name = "blendFactor";
private string slot3Name = "samplerRef";
private string slot4Name = "normalRef";
private string slot5Name = "posRef";
private string slot6Name = "outputRef";
protected override string GetFunctionName()
{
return "unity_triplanar_" + precision;
}
protected override string GetFunctionName()
{
return "unity_triplanar_" + precision;
}
public UVTriPlanar()
{
name = "UVTriPlanar";
public UVTriPlanar()
{
name = "UVTriPlanar";
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot3 = AddSlot("Sampler", slot3Name, Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero);
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot3 = AddSlot("Sampler", slot3Name, Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero);
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
UpdateNodeAfterDeserialization();
}
public override bool hasPreview
{
get { return true; }
}
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
//Sampler input
var samplerName = GetSamplerInput(3);
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
//Sampler input
var samplerName = GetSamplerInput(3);
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.Indent();
outputString.AddShaderChunk("{", false);
// create UVs from position
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false);
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.Indent();
outputString.AddShaderChunk("{", false);
// create UVs from position
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false);
// use absolute value of normal as texture weights
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false);
// use absolute value of normal as texture weights
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false);
// make sure the weights sum up to 1 (divide by sum of x+y+z)
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false);
// make sure the weights sum up to 1 (divide by sum of x+y+z)
outputString.AddShaderChunk("blend /= dot(blend, 1.0);", false);
// read the three texture projections, for x,y,z axes
outputString.AddShaderChunk("float4 cx = " + slot0Name + ".Sample(" + slot3Name + ", uvs.yz);", false);
outputString.AddShaderChunk("float4 cy = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xz);", false);
outputString.AddShaderChunk("float4 cz = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xy);", false);
// read the three texture projections, for x,y,z axes
outputString.AddShaderChunk("float4 cx = " + slot0Name + ".Sample(" + slot3Name + ", uvs.yz);", false);
outputString.AddShaderChunk("float4 cy = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xz);", false);
outputString.AddShaderChunk("float4 cz = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xy);", false);
// blend the textures based on weights
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false);
// blend the textures based on weights
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false);
//outputString.AddShaderChunk("return " + "c;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("#endif", true);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
//outputString.AddShaderChunk("return " + "c;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("#endif", true);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
//Sampler input slot
//Sampler input slot
base.GeneratePropertyUsages(visitor, generationMode);
var samplerSlot = FindInputSlot<MaterialSlot>(slot3);
base.GeneratePropertyUsages(visitor, generationMode);
var samplerSlot = FindInputSlot<MaterialSlot>(slot3);
if (samplerSlot != null)
{
var samplerName = GetSamplerInput(slot3);
if (samplerSlot != null)
{
var samplerName = GetSamplerInput(slot3);
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true);
visitor.AddShaderChunk("#endif", false);
}
}
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true);
visitor.AddShaderChunk("#endif", false);
}
}
//prevent validation errors when a sampler2D input is missing
//use on any input requiring a Texture2DNode
public override void ValidateNode()
{
base.ValidateNode();
var slot = FindInputSlot<MaterialSlot>(0);
if (slot == null)
return;
//prevent validation errors when a sampler2D input is missing
//use on any input requiring a Texture2DNode
public override void ValidateNode()
{
base.ValidateNode();
var slot = FindInputSlot<MaterialSlot>(0);
if (slot == null)
return;
var edges = owner.GetEdges(slot.slotReference).ToList();
hasError |= edges.Count == 0;
}
var edges = owner.GetEdges(slot.slotReference).ToList();
hasError |= edges.Count == 0;
}
public bool RequiresNormal()
{
return true;
}
public bool RequiresNormal()
{
return true;
}
public bool RequiresWorldPosition()
{
return true;
}
}*/
public bool RequiresWorldPosition()
{
return true;
}
}*/

3
MaterialGraphProject/Assets/NewNodes/Kill/AACheckerBoard3dNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

}
}
}

2
MaterialGraphProject/Assets/NewNodes/Kill/AACheckerBoardNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

9
MaterialGraphProject/Assets/NewNodes/Kill/MultiLayerParallaxNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual string GetInputSlot2Name()
{
return kInputFadeRateShaderName;

{
return kTextureSlotShaderName;
}
protected virtual string GetOutputSlotName()
{
return kOutputSlotShaderName;

visitor.AddShaderChunk(
precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) +
" = " + GetFunctionCallBody(depthValue, fadeRateValue, layerCountValue, textureValue) + ";", true);
" = " + GetFunctionCallBody(depthValue, fadeRateValue, layerCountValue, textureValue) + ";", true);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)

{
return channel == UVChannel.uv0;
}
public bool RequiresViewDirectionTangentSpace()
{
return true;

3
MaterialGraphProject/Assets/NewNodes/Kill/POMNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

}
}
}

262
MaterialGraphProject/Assets/NewNodes/Kill/ScatterNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
/* [Title("Procedural/Scatter")]
public class ScatterNode : FunctionNInNOut, IGeneratesFunction
{
/* [Title("Procedural/Scatter")]
public class ScatterNode : FunctionNInNOut, IGeneratesFunction
{
[SerializeField]
private int m_num = 1 ;
[SerializeField]
private int m_num = 1 ;
public int num
{
get { return m_num; }
set
{
public int num
{
get { return m_num; }
set
{
if (m_num == value)
{
return;
}
if (m_num == value)
{
return;
}
m_num = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
m_num = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public ScatterNode()
{
name = "Scatter";
AddSlot("TextureAsset", "inputTex", Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
AddSlot("SamplerState", "inputSampler", Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero);
AddSlot("UV", "inputUV", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one);
AddSlot("Seed", "seed", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one);
AddSlot("PositionRange", "p_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("RotationRange", "r_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("ScaleRange", "s_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
public ScatterNode()
{
name = "Scatter";
AddSlot("TextureAsset", "inputTex", Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
AddSlot("SamplerState", "inputSampler", Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero);
AddSlot("UV", "inputUV", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one);
AddSlot("Seed", "seed", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one);
AddSlot("PositionRange", "p_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("RotationRange", "r_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("ScaleRange", "s_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
protected override string GetFunctionName()
{
return "unity_scatter_" + precision;
}
protected override string GetFunctionName()
{
return "unity_scatter_" + precision;
}
public override bool hasPreview
{
get { return true; }
}
public override bool hasPreview
{
get { return true; }
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
//Sampler input slot
//Sampler input slot
base.GeneratePropertyUsages(visitor, generationMode);
var samplerSlot = FindInputSlot<MaterialSlot>(2);
base.GeneratePropertyUsages(visitor, generationMode);
var samplerSlot = FindInputSlot<MaterialSlot>(2);
if (samplerSlot != null)
{
var samplerName = GetSamplerInput(2);
if (samplerSlot != null)
{
var samplerName = GetSamplerInput(2);
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true);
visitor.AddShaderChunk("#endif", false);
}
}
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true);
visitor.AddShaderChunk("#endif", false);
}
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
//RotateUVFunction ===================================================================
outputString.AddShaderChunk("inline float2 rotateUV( float2 arg1, float arg2 )", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
//center texture's pivot
outputString.AddShaderChunk("arg1.xy -= 0.5;", false);
//rotation matrix
outputString.AddShaderChunk(precision + " s = sin(arg2);", false);
outputString.AddShaderChunk(precision + " c = cos(arg2);", false);
outputString.AddShaderChunk(precision + "2x2 rMatrix = float2x2(c, -s, s, c);", false);
//center rotation matrix
outputString.AddShaderChunk("rMatrix *= 0.5;", false);
outputString.AddShaderChunk("rMatrix += 0.5;", false);
outputString.AddShaderChunk("rMatrix = rMatrix*2 - 1;", false);
//multiply the UVs by the rotation matrix
outputString.AddShaderChunk("arg1.xy = mul(arg1.xy, rMatrix);", false);
outputString.AddShaderChunk("arg1.xy += 0.5;", false);
outputString.AddShaderChunk("return " + "arg1;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
//RotateUVFunction ===================================================================
outputString.AddShaderChunk("inline float2 rotateUV( float2 arg1, float arg2 )", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
//center texture's pivot
outputString.AddShaderChunk("arg1.xy -= 0.5;", false);
//rotation matrix
outputString.AddShaderChunk(precision + " s = sin(arg2);", false);
outputString.AddShaderChunk(precision + " c = cos(arg2);", false);
outputString.AddShaderChunk(precision + "2x2 rMatrix = float2x2(c, -s, s, c);", false);
//center rotation matrix
outputString.AddShaderChunk("rMatrix *= 0.5;", false);
outputString.AddShaderChunk("rMatrix += 0.5;", false);
outputString.AddShaderChunk("rMatrix = rMatrix*2 - 1;", false);
//multiply the UVs by the rotation matrix
outputString.AddShaderChunk("arg1.xy = mul(arg1.xy, rMatrix);", false);
outputString.AddShaderChunk("arg1.xy += 0.5;", false);
outputString.AddShaderChunk("return " + "arg1;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
//RamdomFunction ===================================================================
outputString.AddShaderChunk("inline float randomrange(float2 randomseed, float min, float max)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float randomno = frac(sin(dot(randomseed, float2(12.9898, 78.233)))*43758.5453);", false);
outputString.AddShaderChunk("return lerp(min,max,abs(frac(randomno)));", false);
//outputString.AddShaderChunk("return floor(randomno * (max - min + 1)) + min;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
//RamdomFunction ===================================================================
outputString.AddShaderChunk("inline float randomrange(float2 randomseed, float min, float max)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float randomno = frac(sin(dot(randomseed, float2(12.9898, 78.233)))*43758.5453);", false);
outputString.AddShaderChunk("return lerp(min,max,abs(frac(randomno)));", false);
//outputString.AddShaderChunk("return floor(randomno * (max - min + 1)) + min;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
//ScatterFunction ===================================================================
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
//ScatterFunction ===================================================================
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("finalColor = float4(0,0,0,0);", false);
outputString.AddShaderChunk("float2 newuv;", false);
outputString.AddShaderChunk("float4 tex = finalColor;", false);
outputString.AddShaderChunk("finalColor = float4(0,0,0,0);", false);
outputString.AddShaderChunk("float2 newuv;", false);
outputString.AddShaderChunk("float4 tex = finalColor;", false);
outputString.AddShaderChunk("float scale;", false);
outputString.AddShaderChunk("float rotation;", false);
outputString.AddShaderChunk("float2 position;", false);
outputString.AddShaderChunk("float j;", false);
outputString.AddShaderChunk("float scale;", false);
outputString.AddShaderChunk("float rotation;", false);
outputString.AddShaderChunk("float2 position;", false);
outputString.AddShaderChunk("float j;", false);
for (int i=0; i<m_num; i++)
{
//random UV
for (int i=0; i<m_num; i++)
{
//random UV
outputString.AddShaderChunk("newuv = inputUV;", false);
outputString.AddShaderChunk("j = "+i+"+0.001f;", false);
outputString.AddShaderChunk("newuv = inputUV;", false);
outputString.AddShaderChunk("j = "+i+"+0.001f;", false);
outputString.AddShaderChunk("scale = randomrange(seed+j,s_range.x,s_range.y);", false); //Random Scale
outputString.AddShaderChunk("newuv *= scale;", false); //Scale
outputString.AddShaderChunk("newuv -= (scale-1)*0.5f;", false); //Move to Center After Scale
outputString.AddShaderChunk("scale = randomrange(seed+j,s_range.x,s_range.y);", false); //Random Scale
outputString.AddShaderChunk("newuv *= scale;", false); //Scale
outputString.AddShaderChunk("newuv -= (scale-1)*0.5f;", false); //Move to Center After Scale
outputString.AddShaderChunk("rotation = randomrange(seed+j,r_range.x,r_range.y);", false); //Random rotation
outputString.AddShaderChunk("newuv = rotateUV(newuv,rotation);", false); //Rotate
outputString.AddShaderChunk("rotation = randomrange(seed+j,r_range.x,r_range.y);", false); //Random rotation
outputString.AddShaderChunk("newuv = rotateUV(newuv,rotation);", false); //Rotate
outputString.AddShaderChunk("position.x = randomrange(seed.x+j,p_range.x,p_range.y);", false); //Random position
outputString.AddShaderChunk("position.y = randomrange(seed.y+j,p_range.x,p_range.y);", false); //Random position
outputString.AddShaderChunk("newuv += position*scale;", false); //Position
outputString.AddShaderChunk("position.x = randomrange(seed.x+j,p_range.x,p_range.y);", false); //Random position
outputString.AddShaderChunk("position.y = randomrange(seed.y+j,p_range.x,p_range.y);", false); //Random position
outputString.AddShaderChunk("newuv += position*scale;", false); //Position
//sample
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false);
outputString.AddShaderChunk("#endif",false);
//sample
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false);
outputString.AddShaderChunk("#endif",false);
//blend together
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false);
//blend together
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false);
//seamless
outputString.AddShaderChunk("newuv = 1-newuv;", false);
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false);
outputString.AddShaderChunk("#endif", false);
//blend seamless
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false);
//seamless
outputString.AddShaderChunk("newuv = 1-newuv;", false);
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
outputString.AddShaderChunk("tex = inputTex.Sample(inputSampler, newuv);", false);
outputString.AddShaderChunk("#endif", false);
//blend seamless
outputString.AddShaderChunk("finalColor = lerp(finalColor,tex, tex.a);", false);
}
}
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}*/
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}*/
}

2
MaterialGraphProject/Assets/NewNodes/Kill/SphereWarpNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph
{

2
MaterialGraphProject/Assets/NewNodes/Kill/SphericalIndentationNode.cs


using System.Reflection;
using System.Reflection;
namespace UnityEngine.MaterialGraph

22
MaterialGraphProject/Assets/NewNodes/Kill/ToggleNode.cs


{
[SerializeField]
//private float m_Float;
private bool m_ToggleState;
private bool m_ToggleState;
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Ouput";

public override PropertyType propertyType
{
get { return PropertyType.Float; }
get { return PropertyType.Float; }
}
public bool value

{
if (m_ToggleState == value)
if (m_ToggleState == value)
m_ToggleState = value;
m_ToggleState = value;
if (onModified != null)
{
onModified(this, ModificationScope.Node);

public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, 0f, FloatPropertyChunk.FloatType.Toggle, PropertyChunk.HideState.Visible));
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, 0f, FloatPropertyChunk.FloatType.Toggle, PropertyChunk.HideState.Visible));
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
return;
visitor.AddShaderChunk(value.ToString (), true);
visitor.AddShaderChunk(value.ToString(), true);
{
m_Name = propertyName,
m_PropType = PropertyType.Float,
m_Float = value ? 1f : 0f
};
{
m_Name = propertyName,
m_PropType = PropertyType.Float,
m_Float = value ? 1f : 0f
};
}
}
}

2
MaterialGraphProject/Assets/NewNodes/Kill/VertexNormalNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

6
MaterialGraphProject/Assets/NewNodes/Kill/VertexPositionNode.cs


using UnityEngine.Graphing;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

AddSlot(new MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
get { return new[] { OutputSlotId, OutputSlotIdXYZ ,OutputSlotIdX, OutputSlotIdY, OutputSlotIdZ, OutputSlotIdW }; }
get { return new[] { OutputSlotId, OutputSlotIdXYZ , OutputSlotIdX, OutputSlotIdY, OutputSlotIdZ, OutputSlotIdW }; }
}
public override string GetVariableNameForSlot(int slotId)

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateRemapGraph.cs


public override void Action(int instanceId, string pathName, string resourceFile)
{
/* var graph = CreateInstance<MaterialRemapAsset>();
graph.name = Path.GetFileName(pathName);
AssetDatabase.CreateAsset(graph, pathName);*/
/* var graph = CreateInstance<MaterialRemapAsset>();
graph.name = Path.GetFileName(pathName);
AssetDatabase.CreateAsset(graph, pathName);*/
}
}
}

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


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

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


}
public class MaterialGraphEditWindow : AbstractMaterialGraphEditWindow<UnityEngine.MaterialGraph.MaterialGraph>
{ }
{}
{ }
{}
public abstract class AbstractMaterialGraphEditWindow<TGraphType> : EditorWindow, IMaterialGraphEditWindow where TGraphType : AbstractMaterialGraph
{

var e = Event.current;
if (e.type == EventType.ValidateCommand && (
e.commandName == "Copy" && presenter.canCopy
|| e.commandName == "Paste" && presenter.canPaste
|| e.commandName == "Duplicate" && presenter.canDuplicate
|| e.commandName == "Cut" && presenter.canCut
|| (e.commandName == "Delete" || e.commandName == "SoftDelete") && presenter.canDelete))
e.commandName == "Copy" && presenter.canCopy
|| e.commandName == "Paste" && presenter.canPaste
|| e.commandName == "Duplicate" && presenter.canDuplicate
|| e.commandName == "Cut" && presenter.canCut
|| (e.commandName == "Delete" || e.commandName == "SoftDelete") && presenter.canDelete))
{
e.Use();
}

var textureNames = new List<string>();
var textures = new List<Texture>();
foreach (var textureInfo in configuredTextures.Where(
x => x.modifiable == TexturePropertyChunk.ModifiableState.Modifiable))
x => x.modifiable == TexturePropertyChunk.ModifiableState.Modifiable))
{
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture;
if (texture == null)

textureNames.Clear();
textures.Clear();
foreach (var textureInfo in configuredTextures.Where(
x => x.modifiable == TexturePropertyChunk.ModifiableState.NonModifiable))
x => x.modifiable == TexturePropertyChunk.ModifiableState.NonModifiable))
{
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture;
if (texture == null)

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Clicker.cs


Active
}
// TODO JOCE: This is to mimic the behavior of a button. Remove and replace with actual button in TitleBar.
// TODO JOCE: This is to mimic the behavior of a button. Remove and replace with actual button in TitleBar.
public class Clicker : MouseManipulator
{
public delegate void StateChangeCallback(ClickerState newState);

VisualElement initialTarget;
ClickerState state;
public Clicker()
{
activators.Add(new ManipulatorActivationFilter {button = MouseButton.LeftMouse});
}
public Clicker()
{
activators.Add(new ManipulatorActivationFilter {button = MouseButton.LeftMouse});
}
protected override void RegisterCallbacksOnTarget()
{

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


public void Dispose() {
}
}*/
/*internal class SavedRenderTargetState

m_Camera.targetTexture = m_RenderTexture;
}
if (mode == PreviewMode.Preview3D)
{
m_Camera.transform.position = -Vector3.forward * 5;

m_RenderTexture = null;
}
if (Light0 == null)
if (Light0 == null)
if (Light1 == null)
if (Light1 == null)
if (m_Camera == null)
if (m_Camera == null)
if (m_CheckerboardMaterial == null)
if (m_CheckerboardMaterial == null)
{
UnityEngine.Object.DestroyImmediate(m_CheckerboardMaterial);
m_CheckerboardMaterial = null;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/AbstractNodeInspector.cs


using System;
using System;
using UnityEngine;
using UnityEngine.Graphing;

34
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/PropertyNodeInspector.cs


using UnityEngine;
using UnityEngine;
public class PropertyNodeInspector : BasicNodeInspector
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
public class PropertyNodeInspector : BasicNodeInspector
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var propertyNode = node as PropertyNode;
if (propertyNode == null)
return;
var propertyNode = node as PropertyNode;
if (propertyNode == null)
return;
GUILayout.Label("Settings", EditorStyles.boldLabel);
GUILayout.Label("Settings", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
EditorGUI.BeginChangeCheck();
//propertyNode.name = EditorGUILayout.TextField ("Name", propertyNode.name);
propertyNode.description = EditorGUILayout.TextField ("Description", propertyNode.description);
//propertyNode.name = EditorGUILayout.TextField ("Name", propertyNode.name);
propertyNode.description = EditorGUILayout.TextField("Description", propertyNode.description);
if (EditorGUI.EndChangeCheck())
node.onModified(node, ModificationScope.Node);
}
}
if (EditorGUI.EndChangeCheck())
node.onModified(node, ModificationScope.Node);
}
}
}

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs


var options = surfaceNode.options;
EditorGUI.BeginChangeCheck();
options.srcBlend = (SurfaceMaterialOptions.BlendMode) EditorGUILayout.EnumPopup("Src Blend", options.srcBlend);
options.dstBlend = (SurfaceMaterialOptions.BlendMode) EditorGUILayout.EnumPopup("Dst Blend", options.dstBlend);
options.cullMode = (SurfaceMaterialOptions.CullMode) EditorGUILayout.EnumPopup("Cull Mode", options.cullMode);
options.zTest = (SurfaceMaterialOptions.ZTest) EditorGUILayout.EnumPopup("Z Test", options.zTest);
options.zWrite = (SurfaceMaterialOptions.ZWrite) EditorGUILayout.EnumPopup("Z Write", options.zWrite);
options.renderQueue = (SurfaceMaterialOptions.RenderQueue) EditorGUILayout.EnumPopup("Render Queue", options.renderQueue);
options.renderType = (SurfaceMaterialOptions.RenderType) EditorGUILayout.EnumPopup("Render Type", options.renderType);
options.srcBlend = (SurfaceMaterialOptions.BlendMode)EditorGUILayout.EnumPopup("Src Blend", options.srcBlend);
options.dstBlend = (SurfaceMaterialOptions.BlendMode)EditorGUILayout.EnumPopup("Dst Blend", options.dstBlend);
options.cullMode = (SurfaceMaterialOptions.CullMode)EditorGUILayout.EnumPopup("Cull Mode", options.cullMode);
options.zTest = (SurfaceMaterialOptions.ZTest)EditorGUILayout.EnumPopup("Z Test", options.zTest);
options.zWrite = (SurfaceMaterialOptions.ZWrite)EditorGUILayout.EnumPopup("Z Write", options.zWrite);
options.renderQueue = (SurfaceMaterialOptions.RenderQueue)EditorGUILayout.EnumPopup("Render Queue", options.renderQueue);
options.renderType = (SurfaceMaterialOptions.RenderType)EditorGUILayout.EnumPopup("Render Type", options.renderType);
if (EditorGUI.EndChangeCheck())
node.onModified(node, ModificationScope.Node);

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphInspectorPresenter.cs


using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Graphing.Util;
using UnityEngine;

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


typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter);
typeMapper[typeof(ColorNode)] = typeof(ColorNodePresenter);
typeMapper[typeof(GradientNode)] = typeof(GradientNodePresenter);
// typeMapper[typeof(ScatterNode)] = typeof(ScatterNodePresenter);
// typeMapper[typeof(ScatterNode)] = typeof(ScatterNodePresenter);
//typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
//typeMapper[typeof(SamplerAssetNode)] = typeof(SamplerAssetNodePresenter);
//typeMapper[typeof(TextureSamplerNode)] = typeof(TextureSamplerNodePresenter);

typeMapper[typeof(CubemapNode)] = typeof(CubeNodePresenter);
typeMapper[typeof(ToggleNode)] = typeof(ToggleNodePresenter);
typeMapper[typeof(ToggleNode)] = typeof(ToggleNodePresenter);
/* typeMapper[typeof(ScaleOffsetNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(RadialShearNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphereWarpNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphericalIndentationNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboardNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboard3dNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter*/
/* typeMapper[typeof(ScaleOffsetNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(RadialShearNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphereWarpNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphericalIndentationNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboardNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboard3dNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter*/
// typeMapper[typeof(RemapMasterNode)] = typeof(RemapMasterNodePresenter);
// typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter);
// typeMapper[typeof(RemapMasterNode)] = typeof(RemapMasterNodePresenter);
// typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter);
typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodePresenter);
// typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodePresenter);
// typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
typeMapper[typeof(IfNode)] = typeof(IfNodePresenter);
//typeMapper[typeof(CustomCodeNode)] = typeof(CustomCodePresenter);
typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodePresenter);

typeMapper[typeof(TransformNode)] = typeof(TransformNodePresenter);
typeMapper[typeof(TransformNode)] = typeof(TransformNodePresenter);
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)
return allChildren.OfType<NodeAnchorPresenter>()
.Where(nap => nap.IsConnectable() &&
nap.orientation == startAnchor.orientation &&
nap.direction != startAnchor.direction &&
nodeAdapter.GetAdapter(nap.source, startAnchor.source) != null &&
(startAnchor is GraphAnchorPresenter && ((GraphAnchorPresenter)nap).slot is MaterialSlot &&
((MaterialSlot)((GraphAnchorPresenter)startAnchor).slot).IsCompatibleWithInputSlotType(((MaterialSlot)((GraphAnchorPresenter)nap).slot).valueType)))
.ToList();
return allChildren.OfType<NodeAnchorPresenter>()
.Where(nap => nap.IsConnectable() &&
nap.orientation == startAnchor.orientation &&
nap.direction != startAnchor.direction &&
nodeAdapter.GetAdapter(nap.source, startAnchor.source) != null &&
(startAnchor is GraphAnchorPresenter && ((GraphAnchorPresenter)nap).slot is MaterialSlot &&
((MaterialSlot)((GraphAnchorPresenter)startAnchor).slot).IsCompatibleWithInputSlotType(((MaterialSlot)((GraphAnchorPresenter)nap).slot).valueType)))
.ToList();
}
void OnNodeChanged(INode inNode, ModificationScope scope)

foreach (var slot in presenter.node.GetOutputSlots<ISlot>())
{
foreach (var edge in graph.GetEdges(slot.slotReference))
{
{
// We look at each node we feed into.
var inputNodeGuid = edge.inputSlot.nodeGuid;

m_Container = container;
m_TitleBar = CreateInstance<TitleBarPresenter>();
m_TitleBar.Initialize(container);
m_TitleBar.Initialize(container);
m_GraphInspectorPresenter = CreateInstance<GraphInspectorPresenter>();
m_GraphInspectorPresenter.Initialize();

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs


return string.Empty;
List<PropertyGenerator.TextureInfo> defaultTextures;
var resultShader = ((IMasterNode) m_Node).GetFullShader(GenerationMode.Preview, m_Node.guid + "_preview", out defaultTextures);
var resultShader = ((IMasterNode)m_Node).GetFullShader(GenerationMode.Preview, m_Node.guid + "_preview", out defaultTextures);
if (((IMasterNode)m_Node).has3DPreview())
{

var resultShader = GetPreviewShaderString();
Debug.Log("RecreateShaderAndMaterial : " + m_Node.GetVariableNameForNode() + Environment.NewLine + resultShader);
string shaderOuputString = resultShader.Replace("UnityEngine.MaterialGraph", "Generated");
System.IO.File.WriteAllText(Application.dataPath+"/GeneratedShader.shader", shaderOuputString);
System.IO.File.WriteAllText(Application.dataPath + "/GeneratedShader.shader", shaderOuputString);
if (string.IsNullOrEmpty(resultShader))
return false;

case PropertyType.Texture:
mat.SetTexture(previewProperty.m_Name, previewProperty.m_Texture);
break;
case PropertyType.Cubemap:
mat.SetTexture(previewProperty.m_Name, previewProperty.m_Cubemap);
break;
case PropertyType.Cubemap:
mat.SetTexture(previewProperty.m_Name, previewProperty.m_Cubemap);
break;
case PropertyType.Color:
mat.SetColor(previewProperty.m_Name, previewProperty.m_Color);
break;

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ColorNodePresenter.cs


if (cNode == null)
return;
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState);
cNode.color = EditorGUILayout.ColorField(new GUIContent ("Color"), cNode.color, true, true, cNode.HDR, new ColorPickerHDRConfig(0f, 8f, 0.125f, 3f));
cNode.HDR = EditorGUILayout.Toggle("HDR", cNode.HDR);
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState);
cNode.color = EditorGUILayout.ColorField(new GUIContent("Color"), cNode.color, true, true, cNode.HDR, new ColorPickerHDRConfig(0f, 8f, 0.125f, 3f));
cNode.HDR = EditorGUILayout.Toggle("HDR", cNode.HDR);
return EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
return EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
}
}

20
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CubemapNodePresenter.cs


{
//private string[] m_TextureTypeNames;
//private string[] textureTypeNames
/* {
get
{
if (m_TextureTypeNames == null)
m_TextureTypeNames = Enum.GetNames(typeof(TextureType));
return m_TextureTypeNames;
}
}*/
/* {
get
{
if (m_TextureTypeNames == null)
m_TextureTypeNames = Enum.GetNames(typeof(TextureType));
return m_TextureTypeNames;
}
}*/
var tNode = node as UnityEngine.MaterialGraph.CubemapNode;
var tNode = node as UnityEngine.MaterialGraph.CubemapNode;
tNode.defaultCube = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Cubemap"), tNode.defaultCube, typeof(Cubemap), null) as Cubemap;
tNode.defaultCube = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Cubemap"), tNode.defaultCube, typeof(Cubemap), null) as Cubemap;
//tNode.textureType = (TextureType)EditorGUILayout.Popup((int)tNode.textureType, textureTypeNames, EditorStyles.popup);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CustomCodeNodePresenter.cs


using System;
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/GradientNodePresenter.cs


if (cNode == null)
return;
if(gradientobj == null || prevnode != cNode)
if (gradientobj == null || prevnode != cNode)
{
prevnode = cNode;
gradientobj = new GradientObject();

{
return EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/IfNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MasterNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine.MaterialGraph;

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MatrixCommonNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using UnityEditor.Experimental.UIElements.GraphView;

[Serializable]
class MatrixCommonContolPresenter : GraphControlPresenter
{
private string[] m_MatrixTypeNames;
private string[] matrixTypeNames
{

60
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/RemapInputNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

{
/* [Serializable]
class RemapInputControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
/* [Serializable]
class RemapInputControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var remapNode = node as MasterRemapInputNode;
if (remapNode == null)
return;
var remapNode = node as MasterRemapInputNode;
if (remapNode == null)
return;
if (GUILayout.Button("Add Slot"))
remapNode.AddSlot();
if (GUILayout.Button("Remove Slot"))
remapNode.RemoveSlot();
}
if (GUILayout.Button("Add Slot"))
remapNode.AddSlot();
if (GUILayout.Button("Remove Slot"))
remapNode.RemoveSlot();
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class RemapInputNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<RemapInputControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}*/
[Serializable]
public class RemapInputNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<RemapInputControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}*/
}

64
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/RemapMasterNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

{
/* [Serializable]
class RemapMasterControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
/* [Serializable]
class RemapMasterControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var remapNode = node as RemapMasterNode;
if (remapNode == null)
return;
var remapNode = node as RemapMasterNode;
if (remapNode == null)
return;
remapNode.remapAsset = (MaterialRemapAsset)EditorGUILayout.MiniThumbnailObjectField(
new GUIContent("Remap Asset"),
remapNode.remapAsset,
typeof(MaterialRemapAsset), null);
}
remapNode.remapAsset = (MaterialRemapAsset)EditorGUILayout.MiniThumbnailObjectField(
new GUIContent("Remap Asset"),
remapNode.remapAsset,
typeof(MaterialRemapAsset), null);
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class RemapMasterNodePresenter : MasterNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<RemapMasterControlPresenter>();
instance.Initialize(node);
var controls = new List<GraphControlPresenter>(base.GetControlData());
controls.Add(instance);
return controls;
}
}*/
[Serializable]
public class RemapMasterNodePresenter : MasterNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<RemapMasterControlPresenter>();
instance.Initialize(node);
var controls = new List<GraphControlPresenter>(base.GetControlData());
controls.Add(instance);
return controls;
}
}*/
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerAssetNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerStateNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using UnityEditor.Experimental.UIElements.GraphView;

[Serializable]
class SamplerStateControlPresenter : GraphControlPresenter
{
private string[] samplerFilterMode;
private string[] samplerWrapMode;

58
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ScatterNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;

/* [Serializable]
class ScatterContolPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
/* [Serializable]
class ScatterContolPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as UnityEngine.MaterialGraph.ScatterNode;
if (cNode == null)
return;
var cNode = node as UnityEngine.MaterialGraph.ScatterNode;
if (cNode == null)
return;
cNode.num = EditorGUILayout.IntField(cNode.num, "Number", null);
cNode.num = Math.Min(cNode.num, 50); //prevent infinite => hang!
}
cNode.num = EditorGUILayout.IntField(cNode.num, "Number", null);
cNode.num = Math.Min(cNode.num, 50); //prevent infinite => hang!
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
[Serializable]
public class ScatterNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<ScatterContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
[Serializable]
public class ScatterNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<ScatterContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
*/
*/
}

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


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

{
[Serializable]
class SubgraphIONodeControlPresenter : GraphControlPresenter
class SubgraphIONodeControlPresenter : GraphControlPresenter
var ioNode = node as AbstractSubGraphIONode;
if (ioNode == null)
var ioNode = node as AbstractSubGraphIONode;
if (ioNode == null)
ioNode.AddSlot();
ioNode.AddSlot();
ioNode.RemoveSlot();
ioNode.RemoveSlot();
}
public override float GetHeight()

}
[Serializable]
public class SubgraphIONodePresenter : MaterialNodePresenter
public class SubgraphIONodePresenter : MaterialNodePresenter
var instance = CreateInstance<SubgraphIONodeControlPresenter>();
var instance = CreateInstance<SubgraphIONodeControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureAssetNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureLODNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

74
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureNodePresenter.cs


namespace UnityEditor.MaterialGraph.Drawing
{
/* class TextureContolPresenter : GraphControlPresenter
{
private string[] m_TextureTypeNames;
private string[] textureTypeNames
{
get
{
if (m_TextureTypeNames == null)
m_TextureTypeNames = Enum.GetNames(typeof(TextureType));
return m_TextureTypeNames;
}
}
/* class TextureContolPresenter : GraphControlPresenter
{
private string[] m_TextureTypeNames;
private string[] textureTypeNames
{
get
{
if (m_TextureTypeNames == null)
m_TextureTypeNames = Enum.GetNames(typeof(TextureType));
return m_TextureTypeNames;
}
}
public override void OnGUIHandler()
{
base.OnGUIHandler();
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as UnityEngine.MaterialGraph.TextureNode;
if (tNode == null)
return;
var tNode = node as UnityEngine.MaterialGraph.TextureNode;
if (tNode == null)
return;
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture), null) as Texture;
tNode.textureType = (TextureType)EditorGUILayout.Popup((int)tNode.textureType, textureTypeNames, EditorStyles.popup);
}
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture), null) as Texture;
tNode.textureType = (TextureType)EditorGUILayout.Popup((int)tNode.textureType, textureTypeNames, EditorStyles.popup);
}
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class TextureNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<TextureContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}*/
[Serializable]
public class TextureNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<TextureContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}*/
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureSamplerNodePresenter.cs


using System;
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/UVNodePresenter.cs


if (cNode == null)
return;
cNode.uvChannel = (UVChannel) EditorGUILayout.EnumPopup("Channel", cNode.uvChannel);
cNode.uvChannel = (UVChannel)EditorGUILayout.EnumPopup("Channel", cNode.uvChannel);
}
public override float GetHeight()

84
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector1NodePresenter.cs


{
class Vector1ControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();

return;
tNode.floatType = (FloatPropertyChunk.FloatType)EditorGUILayout.EnumPopup ("Float", tNode.floatType);
Vector3 ranges = tNode.rangeValues;
switch(tNode.floatType){
case FloatPropertyChunk.FloatType.Float:
tNode.floatType = FloatPropertyChunk.FloatType.Float;
tNode.value = EditorGUILayout.FloatField ("Value:", tNode.value);
break;
case FloatPropertyChunk.FloatType.Range:
tNode.floatType = FloatPropertyChunk.FloatType.Range;
tNode.value = EditorGUILayout.Slider (tNode.value, tNode.rangeValues.x, tNode.rangeValues.y);
EditorGUILayout.BeginHorizontal ();
ranges.x = EditorGUILayout.FloatField (ranges.x);
//very dirty...
for (int i = 0; i < 15; i++) {
EditorGUILayout.Space ();
}
ranges.y = EditorGUILayout.FloatField (ranges.y);
EditorGUILayout.EndHorizontal ();
tNode.rangeValues = ranges;
break;
case FloatPropertyChunk.FloatType.PowerSlider:
tNode.floatType = FloatPropertyChunk.FloatType.PowerSlider;
tNode.value = EditorGUILayout.Slider (tNode.value, tNode.rangeValues.x, tNode.rangeValues.y);
EditorGUILayout.BeginHorizontal ();
ranges.x = EditorGUILayout.FloatField (ranges.x);
ranges.y = EditorGUILayout.FloatField (ranges.y);
//power needs to be name
ranges.z = EditorGUILayout.FloatField (ranges.z);
EditorGUILayout.EndHorizontal ();
tNode.rangeValues = ranges;
break;
case FloatPropertyChunk.FloatType.Toggle:
bool toggleState = tNode.value == 0f ? false : true;
tNode.floatType = FloatPropertyChunk.FloatType.Toggle;
toggleState = EditorGUILayout.Toggle (toggleState);
tNode.value = toggleState == true ? 1f : 0f;
break;
}
tNode.floatType = (FloatPropertyChunk.FloatType)EditorGUILayout.EnumPopup("Float", tNode.floatType);
Vector3 ranges = tNode.rangeValues;
switch (tNode.floatType)
{
case FloatPropertyChunk.FloatType.Float:
tNode.floatType = FloatPropertyChunk.FloatType.Float;
tNode.value = EditorGUILayout.FloatField("Value:", tNode.value);
break;
case FloatPropertyChunk.FloatType.Range:
tNode.floatType = FloatPropertyChunk.FloatType.Range;
tNode.value = EditorGUILayout.Slider(tNode.value, tNode.rangeValues.x, tNode.rangeValues.y);
EditorGUILayout.BeginHorizontal();
ranges.x = EditorGUILayout.FloatField(ranges.x);
//very dirty...
for (int i = 0; i < 15; i++)
{
EditorGUILayout.Space();
}
ranges.y = EditorGUILayout.FloatField(ranges.y);
EditorGUILayout.EndHorizontal();
tNode.rangeValues = ranges;
break;
case FloatPropertyChunk.FloatType.PowerSlider:
tNode.floatType = FloatPropertyChunk.FloatType.PowerSlider;
tNode.value = EditorGUILayout.Slider(tNode.value, tNode.rangeValues.x, tNode.rangeValues.y);
EditorGUILayout.BeginHorizontal();
ranges.x = EditorGUILayout.FloatField(ranges.x);
ranges.y = EditorGUILayout.FloatField(ranges.y);
//power needs to be name
ranges.z = EditorGUILayout.FloatField(ranges.z);
EditorGUILayout.EndHorizontal();
tNode.rangeValues = ranges;
break;
case FloatPropertyChunk.FloatType.Toggle:
bool toggleState = tNode.value == 0f ? false : true;
tNode.floatType = FloatPropertyChunk.FloatType.Toggle;
toggleState = EditorGUILayout.Toggle(toggleState);
tNode.value = toggleState == true ? 1f : 0f;
break;
}
return (EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
return (EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TitleBarPresenter.cs


{
List<TitleBarButtonPresenter> m_leftItems;
List<TitleBarButtonPresenter> m_rightItems;
IMaterialGraphEditWindow m_Owner;
IMaterialGraphEditWindow m_Owner;
public IEnumerable<TitleBarButtonPresenter> leftItems
{

protected TitleBarPresenter()
{}
public void Initialize(IMaterialGraphEditWindow graphWindow)
public void Initialize(IMaterialGraphEditWindow graphWindow)
m_Owner = graphWindow;
m_Owner = graphWindow;
currentGraphItem.text = "Put name here";
currentGraphItem.text = "Put name here";
m_leftItems.Add(currentGraphItem);
var updateAsset = CreateInstance<TitleBarButtonPresenter>();

m_leftItems.Add(toSubGraph);
var showInProjectItem = CreateInstance<TitleBarButtonPresenter>();
showInProjectItem.text = "Show in project";
showInProjectItem.onClick += OnShowInProjectClick;
m_leftItems.Add(showInProjectItem);
showInProjectItem.text = "Show in project";
showInProjectItem.onClick += OnShowInProjectClick;
m_leftItems.Add(showInProjectItem);
optionsItem.text = "Time";
optionsItem.onClick += ToggleTime;
optionsItem.text = "Time";
optionsItem.onClick += ToggleTime;
void OnShowInProjectClick()
{
if (m_Owner != null)
m_Owner.PingAsset ();
}
void OnShowInProjectClick()
{
if (m_Owner != null)
m_Owner.PingAsset();
}
m_Owner.UpdateAsset ();
m_Owner.UpdateAsset();
}
void ToSubGraph()

void ToggleTime()
{
m_Owner.ToggleRequiresTime();
}
void ToggleTime()
{
m_Owner.ToggleRequiresTime();
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


protected override Object[] toWatch
{
get { return new Object[]{m_Presenter}; }
get { return new Object[] {m_Presenter}; }
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphInspectorView.cs


using System;
using System;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
using UnityEngine.Experimental.UIElements;

29
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


{
public sealed class MaterialGraphView : GraphView
{
[SerializeField]
private GraphDrawingData m_DrawingData = new GraphDrawingData();

public MaterialGraphView(EditorWindow editorWindow)
{
var shortcutHandler = new ShortcutHandler(
new Dictionary<Event, ShortcutDelegate>
{
{Event.KeyboardEvent("a"), FrameAll},
{Event.KeyboardEvent("f"), FrameSelection},
{Event.KeyboardEvent("o"), FrameOrigin},
{Event.KeyboardEvent("#tab"), FramePrev},
{Event.KeyboardEvent("tab"), FrameNext}
});
new Dictionary<Event, ShortcutDelegate>
{
{Event.KeyboardEvent("a"), FrameAll},
{Event.KeyboardEvent("f"), FrameSelection},
{Event.KeyboardEvent("o"), FrameOrigin},
{Event.KeyboardEvent("#tab"), FramePrev},
{Event.KeyboardEvent("tab"), FrameNext}
});
onEnter += () => editorWindow.rootVisualContainer.parent.AddManipulator(shortcutHandler);
onLeave += () => editorWindow.rootVisualContainer.parent.RemoveManipulator(shortcutHandler);

}
}
}
gm.ShowAsContext();
}
evt.StopPropagation();

var graphDataSource = GetPresenter<MaterialGraphPresenter>();
if (graphDataSource == null)
return;
if (drawingData.selection.SequenceEqual(selection.OfType<MaterialNodeView>().Select(d => ((MaterialNodePresenter) d.presenter).node.guid))) return;
if (drawingData.selection.SequenceEqual(selection.OfType<MaterialNodeView>().Select(d => ((MaterialNodePresenter)d.presenter).node.guid))) return;
.OfType<MaterialNodeView>()
.FirstOrDefault(drawer => ((MaterialNodePresenter) drawer.presenter).node.guid == guid))
.OfType<MaterialNodeView>()
.FirstOrDefault(drawer => ((MaterialNodePresenter)drawer.presenter).node.guid == guid))
.ToList();
ClearSelection();

if (graphDataSource == null)
return;
var selectedNodes = selection.OfType<MaterialNodeView>().Select(x => (MaterialNodePresenter) x.presenter);
var selectedNodes = selection.OfType<MaterialNodeView>().Select(x => (MaterialNodePresenter)x.presenter);
graphDataSource.UpdateSelection(selectedNodes);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/TitleBarButtonView.cs


protected override Object[] toWatch
{
get { return new Object[]{dataProvider}; }
get { return new Object[] {dataProvider}; }
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/TitleBarView.cs


protected override Object[] toWatch
{
get { return new Object[]{dataProvider}; }
get { return new Object[] {dataProvider}; }
}
}
}

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


using UnityEngine.MaterialGraph;
using UnityEngine.MaterialGraph;
using UnityEngine;
using System;
using System.Collections.Generic;

}
return false;
}
public void OpenAsset(string path)
{

24
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs


using UnityEditor.Experimental.AssetImporters;
using UnityEditor.Experimental.AssetImporters;
using UnityEngine.MaterialGraph;
using UnityEngine;
using System.IO;

public class ShaderSubGraphImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
var textGraph = File.ReadAllText(ctx.assetPath, Encoding.UTF8);
var graph = JsonUtility.FromJson<SubGraph>(textGraph);
public override void OnImportAsset(AssetImportContext ctx)
{
var textGraph = File.ReadAllText(ctx.assetPath, Encoding.UTF8);
var graph = JsonUtility.FromJson<SubGraph>(textGraph);
if (graph == null)
return;
if (graph == null)
return;
var graphAsset = ScriptableObject.CreateInstance<MaterialSubGraphAsset> ();
graphAsset.subGraph = graph;
ctx.SetMainAsset("MainAsset", graphAsset);
}
}
var graphAsset = ScriptableObject.CreateInstance<MaterialSubGraphAsset>();
graphAsset.subGraph = graph;
ctx.SetMainAsset("MainAsset", graphAsset);
}
}

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


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

Debug.Assert(importer != null, "importer != null");
ShowGraphEditWindow(importer.assetPath);
}
private static void ShowGraphEditWindow(string path)
{
var asset = AssetDatabase.LoadAssetAtPath<Object>(path);

}
}
}

50
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/Checkerboard.shader


Shader "Hidden/Checkerboard"
Shader "Hidden/Checkerboard"
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityCG.cginc"
uniform float _X;
uniform float _Y;
static const float4 col1 = float4(0.25, 0.25, 0.25, 1.0);
static const float4 col2 = float4(0.75, 0.75, 0.75, 1.0);
uniform float _X;
uniform float _Y;
static const float4 col1 = float4(0.25, 0.25, 0.25, 1.0);
static const float4 col2 = float4(0.75, 0.75, 0.75, 1.0);
float4 frag(v2f_img i) : COLOR
{
float total = floor(i.uv.x * _X) + floor(i.uv.y * _Y);
bool isEven = total % 2.0 == 0.0;
return isEven ? col1 : col2;
}
ENDCG
}
}
float4 frag(v2f_img i) : COLOR
{
float total = floor(i.uv.x * _X) + floor(i.uv.y * _Y);
bool isEven = total % 2.0 == 0.0;
return isEven ? col1 : col2;
}
ENDCG
}
}
}

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


{
var rendered =
generator.DoRenderPreview(m_PreviewMaterial, PreviewMode.Preview3D, new Rect(0, 0, res, res), 10) as
RenderTexture;
RenderTexture;
Assert.IsNotNull(rendered, "Render failed");

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


var graph = new UnityEngine.MaterialGraph.MaterialGraph();
Assert.IsNotNull(graph);
Assert.AreEqual(0, graph.GetNodes<AbstractMaterialNode>().Count());
}
}

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


m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.NormalSlotId));
// m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_Abs.GetSlotReference(Function1Input.InputSlotId));
// m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_Abs.GetSlotReference(Function1Input.InputSlotId));
/* [Test]
public void TestNodeGeneratesCorrectNodeCode()
{
string expected = string.Format("half {0} = 0.2;" + Environment.NewLine
+ "half {1} = abs ({0});" + Environment.NewLine
+ "o.Albedo = {1};" + Environment.NewLine
+ "o.Normal = {0};" + Environment.NewLine
, m_InputOne.GetVariableNameForSlot(Vector1Node.OutputSlotId)
, m_Abs.GetVariableNameForSlot(Function1Input.OutputSlotId));
/* [Test]
public void TestNodeGeneratesCorrectNodeCode()
{
string expected = string.Format("half {0} = 0.2;" + Environment.NewLine
+ "half {1} = abs ({0});" + Environment.NewLine
+ "o.Albedo = {1};" + Environment.NewLine
+ "o.Normal = {0};" + Environment.NewLine
, m_InputOne.GetVariableNameForSlot(Vector1Node.OutputSlotId)
, m_Abs.GetVariableNameForSlot(Function1Input.OutputSlotId));
var generator = new ShaderGenerator();
m_PixelNode.GenerateNodeCode(generator, GenerationMode.ForReals);
var generator = new ShaderGenerator();
m_PixelNode.GenerateNodeCode(generator, GenerationMode.ForReals);
Console.WriteLine(generator.GetShaderString(0));
Console.WriteLine(generator.GetShaderString(0));
Assert.AreEqual(expected, generator.GetShaderString(0));
Assert.AreEqual(string.Empty, generator.GetPragmaString());
}*/
Assert.AreEqual(expected, generator.GetShaderString(0));
Assert.AreEqual(string.Empty, generator.GetPragmaString());
}*/
}
}

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


public void TestColorChunkReturnsValidValues()
{
var expectedPropertyString = "ThePropertyName(\"ThePropertyDescription\", Color) = (1,0,0,1)";
var chunk = new ColorPropertyChunk(kPropertyName, kPropertyDescription, Color.red, ColorPropertyChunk.ColorType.Default, PropertyChunk.HideState.Visible);
var chunk = new ColorPropertyChunk(kPropertyName, kPropertyDescription, Color.red, ColorPropertyChunk.ColorType.Default, PropertyChunk.HideState.Visible);
Assert.AreEqual(kPropertyName, chunk.propertyName);
Assert.AreEqual(kPropertyDescription, chunk.propertyDescription);
Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());

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


public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty()
{
m_Name = TestPropertyName
};
{
m_Name = TestPropertyName
};
}
}

m_Graph.AddNode(m_PropertyNode);
}
/* [Test]
public void TestExposedPropertyReturnsRawName()
{
m_PropertyNode.exposedState = PropertyNode.ExposedState.Exposed;
m_PropertyNode.propertyName = kPropertyName;
Assert.AreEqual(kPropertyName + "_Uniform", m_PropertyNode.propertyName);
}
/* [Test]
public void TestExposedPropertyReturnsRawName()
{
m_PropertyNode.exposedState = PropertyNode.ExposedState.Exposed;
m_PropertyNode.propertyName = kPropertyName;
Assert.AreEqual(kPropertyName + "_Uniform", m_PropertyNode.propertyName);
}
[Test]
public void TestNonExposedPropertyReturnsGeneratedName()
{
var expected = string.Format("{0}_{1}_Uniform", m_PropertyNode.name, m_PropertyNode.guid.ToString().Replace("-", "_"));
m_PropertyNode.exposedState = PropertyNode.ExposedState.NotExposed;
m_PropertyNode.propertyName = kPropertyName;
[Test]
public void TestNonExposedPropertyReturnsGeneratedName()
{
var expected = string.Format("{0}_{1}_Uniform", m_PropertyNode.name, m_PropertyNode.guid.ToString().Replace("-", "_"));
m_PropertyNode.exposedState = PropertyNode.ExposedState.NotExposed;
m_PropertyNode.propertyName = kPropertyName;
Assert.AreEqual(expected, m_PropertyNode.propertyName);
}
Assert.AreEqual(expected, m_PropertyNode.propertyName);
}
[Test]
public void TestPropertyNodeDescriptionWorks()
{
m_PropertyNode.propertyName = kPropertyName;
m_PropertyNode.description = kDescription;
Assert.AreEqual(kDescription, m_PropertyNode.description);
}
[Test]
public void TestPropertyNodeDescriptionWorks()
{
m_PropertyNode.propertyName = kPropertyName;
m_PropertyNode.description = kDescription;
Assert.AreEqual(kDescription, m_PropertyNode.description);
}
[Test]
public void TestPropertyNodeDescriptionReturnsPropertyNameWhenNoDescriptionSet()
{
m_PropertyNode.propertyName = kPropertyName;
m_PropertyNode.description = string.Empty;
Assert.AreEqual(kPropertyName, m_PropertyNode.description);
}
[Test]
public void TestPropertyNodeDescriptionReturnsPropertyNameWhenNoDescriptionSet()
{
m_PropertyNode.propertyName = kPropertyName;
m_PropertyNode.description = string.Empty;
Assert.AreEqual(kPropertyName, m_PropertyNode.description);
}
[Test]
public void TestPropertyNodeReturnsPreviewProperty()
{
var props = new List<PreviewProperty>();
m_PropertyNode.CollectPreviewMaterialProperties(props);
Assert.AreEqual(props.Count, 1);
Assert.AreEqual(TestPropertyNode.TestPropertyName, props[0].m_Name);
}
[Test]
public void TestPropertyNodeReturnsPreviewProperty()
{
var props = new List<PreviewProperty>();
m_PropertyNode.CollectPreviewMaterialProperties(props);
Assert.AreEqual(props.Count, 1);
Assert.AreEqual(TestPropertyNode.TestPropertyName, props[0].m_Name);
}
[Test]
public void TestDuplicatedPropertyNameGeneratesErrorWhenExposed()
{
const string failName = "SameName";
[Test]
public void TestDuplicatedPropertyNameGeneratesErrorWhenExposed()
{
const string failName = "SameName";
m_Vector1Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector1Node.propertyName = failName;
m_Vector2Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector2Node.propertyName = failName;
m_Vector1Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector1Node.propertyName = failName;
m_Vector2Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector2Node.propertyName = failName;
m_Vector1Node.ValidateNode();
m_Vector2Node.ValidateNode();
Assert.IsTrue(m_Vector1Node.hasError);
Assert.IsTrue(m_Vector2Node.hasError);
}
m_Vector1Node.ValidateNode();
m_Vector2Node.ValidateNode();
Assert.IsTrue(m_Vector1Node.hasError);
Assert.IsTrue(m_Vector2Node.hasError);
}
[Test]
public void TestDuplicatedPropertyNameGeneratesNoErrorWhenNotExposed()
{
const string failName = "SameName";
[Test]
public void TestDuplicatedPropertyNameGeneratesNoErrorWhenNotExposed()
{
const string failName = "SameName";
m_Vector1Node.exposedState = PropertyNode.ExposedState.NotExposed;
m_Vector1Node.propertyName = failName;
m_Vector2Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector2Node.propertyName = failName;
m_Vector1Node.exposedState = PropertyNode.ExposedState.NotExposed;
m_Vector1Node.propertyName = failName;
m_Vector2Node.exposedState = PropertyNode.ExposedState.Exposed;
m_Vector2Node.propertyName = failName;
m_Vector1Node.ValidateNode();
m_Vector2Node.ValidateNode();
Assert.IsFalse(m_Vector1Node.hasError);
Assert.IsFalse(m_Vector2Node.hasError);
}*/
m_Vector1Node.ValidateNode();
m_Vector2Node.ValidateNode();
Assert.IsFalse(m_Vector1Node.hasError);
Assert.IsFalse(m_Vector2Node.hasError);
}*/
[Test]
public void TestPropertyExposedOnSubgraphReturnsFalse()

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/CopyPasteGraph.cs


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

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/ScriptableObjectFactory.cs


using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEditor.Graphing.Util

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/TypeMapper.cs


using System;
using System;
public class TypeMapper<TFrom, TTo, TFallback>
public class TypeMapper<TFrom, TTo, TFallback>
where TFallback : TTo
{
private readonly Dictionary<Type, Type> m_Mappings = new Dictionary<Type, Type>();

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/TypeMapping.cs


using System;
using System;
namespace UnityEditor.Graphing.Util
{

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


using System.Linq;
using System.Linq;
}
}

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


namespace UnityEngine.MaterialGraph
{
}

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


m_ActiveMasterNodeGUIDSerialized = m_ActiveMasterNodeGUID.ToString();
}
public override void OnAfterDeserialize()
{
base.OnAfterDeserialize();

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


var result = hasErrorsCall.Invoke(null, new object[] { shader });
return (int)result != 0;
}
}
}

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

正在加载...
取消
保存