浏览代码

Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017

/main
Florent Guinier 7 年前
当前提交
6edcd801
共有 164 个文件被更改,包括 1887 次插入145 次删除
  1. 128
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  2. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphInspector.cs
  3. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphPresenter.cs
  4. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/GraphEditWindow.cs
  5. 88
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs
  6. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
  7. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  8. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  9. 67
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraphAsset.cs
  10. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Function3Input.cs
  11. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PreviewProperty.cs
  12. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs
  13. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/TimeNode.cs
  14. 9
      MaterialGraphProject/Assets/Brandon.meta
  15. 9
      MaterialGraphProject/Assets/Matt&Andre.meta
  16. 9
      MaterialGraphProject/Assets/Matt.meta
  17. 1
      MaterialGraphProject/Assets/New Shader Graph.ShaderGraph
  18. 9
      MaterialGraphProject/Assets/New Shader Graph.ShaderGraph.meta
  19. 9
      MaterialGraphProject/Assets/TestAssets.meta
  20. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/CubemapNodePresenter.cs
  21. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/CubemapNodePresenter.cs.meta
  22. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureLODNodePresenter.cs
  23. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureLODNodePresenter.cs.meta
  24. 58
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
  25. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
  26. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers.meta
  27. 56
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/CubemapPropertyChunk.cs
  28. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/CubemapPropertyChunk.cs.meta
  29. 9
      MaterialGraphProject/Assets/Vlad.meta
  30. 13
      MaterialGraphProject/Assets/Brandon/ATan2Node.cs
  31. 12
      MaterialGraphProject/Assets/Brandon/ATan2Node.cs.meta
  32. 13
      MaterialGraphProject/Assets/Brandon/ArcCosNode.cs
  33. 12
      MaterialGraphProject/Assets/Brandon/ArcCosNode.cs.meta
  34. 13
      MaterialGraphProject/Assets/Brandon/ArcSinNode.cs
  35. 12
      MaterialGraphProject/Assets/Brandon/ArcSinNode.cs.meta
  36. 13
      MaterialGraphProject/Assets/Brandon/ArcTanNode.cs
  37. 12
      MaterialGraphProject/Assets/Brandon/ArcTanNode.cs.meta
  38. 65
      MaterialGraphProject/Assets/Brandon/CartesianToPolarNode.cs
  39. 12
      MaterialGraphProject/Assets/Brandon/CartesianToPolarNode.cs.meta
  40. 63
      MaterialGraphProject/Assets/Brandon/CheckerboardNode.cs
  41. 12
      MaterialGraphProject/Assets/Brandon/CheckerboardNode.cs.meta
  42. 13
      MaterialGraphProject/Assets/Brandon/CosNode.cs
  43. 12
      MaterialGraphProject/Assets/Brandon/CosNode.cs.meta
  44. 13
      MaterialGraphProject/Assets/Brandon/CrossNode.cs
  45. 12
      MaterialGraphProject/Assets/Brandon/CrossNode.cs.meta
  46. 13
      MaterialGraphProject/Assets/Brandon/DegreesToRadiansNode.cs
  47. 12
      MaterialGraphProject/Assets/Brandon/DegreesToRadiansNode.cs.meta
  48. 58
      MaterialGraphProject/Assets/Brandon/GradientRampNode.cs
  49. 12
      MaterialGraphProject/Assets/Brandon/GradientRampNode.cs.meta
  50. 58
      MaterialGraphProject/Assets/Brandon/HexNode.cs
  51. 12
      MaterialGraphProject/Assets/Brandon/HexNode.cs.meta
  52. 57
      MaterialGraphProject/Assets/Brandon/ParticleNode.cs
  53. 12
      MaterialGraphProject/Assets/Brandon/ParticleNode.cs.meta
  54. 13
      MaterialGraphProject/Assets/Brandon/RadiansToDegreesNode.cs
  55. 12
      MaterialGraphProject/Assets/Brandon/RadiansToDegreesNode.cs.meta
  56. 29
      MaterialGraphProject/Assets/Brandon/ReciprocalNode.cs
  57. 12
      MaterialGraphProject/Assets/Brandon/ReciprocalNode.cs.meta
  58. 13
      MaterialGraphProject/Assets/Brandon/SinCosNode.cs
  59. 12
      MaterialGraphProject/Assets/Brandon/SinCosNode.cs.meta
  60. 13
      MaterialGraphProject/Assets/Brandon/TanNode.cs
  61. 12
      MaterialGraphProject/Assets/Brandon/TanNode.cs.meta
  62. 56
      MaterialGraphProject/Assets/Brandon/UVTileNode.cs
  63. 12
      MaterialGraphProject/Assets/Brandon/UVTileNode.cs.meta
  64. 183
      MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs
  65. 13
      MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs
  66. 12
      MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs.meta
  67. 14
      MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs
  68. 12
      MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs.meta
  69. 15
      MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs
  70. 12
      MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs.meta
  71. 13
      MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs
  72. 12
      MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs.meta
  73. 13
      MaterialGraphProject/Assets/Matt&Andre/SignNode.cs
  74. 12
      MaterialGraphProject/Assets/Matt&Andre/SignNode.cs.meta
  75. 12
      MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs.meta
  76. 15
      MaterialGraphProject/Assets/Matt&Andre/StepNode.cs
  77. 12
      MaterialGraphProject/Assets/Matt&Andre/StepNode.cs.meta
  78. 15
      MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs
  79. 12
      MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs.meta
  80. 12
      MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs.meta
  81. 17
      MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs
  82. 12
      MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs.meta
  83. 14
      MaterialGraphProject/Assets/Matt&Andre/LogNode.cs
  84. 12
      MaterialGraphProject/Assets/Matt&Andre/LogNode.cs.meta
  85. 17
      MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs
  86. 12
      MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs.meta
  87. 45
      MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs
  88. 12
      MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs.meta
  89. 45
      MaterialGraphProject/Assets/Matt&Andre/HueNode.cs
  90. 12
      MaterialGraphProject/Assets/Matt&Andre/HueNode.cs.meta
  91. 29
      MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs
  92. 12
      MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs.meta
  93. 29
      MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs

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


using System;
using System.IO;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.Graphing;

{
// TODO JOCE Derive from GraphViewEditorWindow
public abstract class AbstractGraphEditWindow<T> : EditorWindow, ISerializationCallbackReceiver where T : class, IGraphAsset
public abstract class AbstractGraphEditWindow : EditorWindow, ISerializationCallbackReceiver
public RenderTexture rt;
[NonSerialized]
private IGraphAsset m_Selected;
[NonSerialized]
private T m_LastSelection;
[NonSerialized]
private IGraphAsset m_InMemoryAsset;
[SerializeField]
private ScriptableObject m_LastSelectedGraphSerialized;
[SerializeField]
private ScriptableObject m_ToLoad;
return m_LastSelection != null && m_LastSelection.shouldRepaint;
return m_InMemoryAsset != null && m_InMemoryAsset.shouldRepaint;
}
}

void OnEnable()
{
var source = CreateDataSource();
source.Initialize(m_LastSelection, this);
source.Initialize(m_InMemoryAsset, this);
m_GraphEditorDrawer = new GraphEditorDrawer(CreateGraphView(), source);
rootVisualContainer.AddChild(m_GraphEditorDrawer);

void Update()
{
if (m_ToLoad)
{
ChangeSelction (m_ToLoad as IGraphAsset);
m_ToLoad = null;
}
if (shouldRepaint)
Repaint();
}

focused = true;
}
void OnSelectionChange()
{
if (Selection.activeObject == null || !EditorUtility.IsPersistent(Selection.activeObject))
return;
public void PingAsset()
{
if (m_Selected != null)
EditorGUIUtility.PingObject(m_Selected.GetScriptableObject());
}
if (Selection.activeObject is ScriptableObject)
{
var selection = Selection.activeObject as T;
if (selection!= null && selection != m_LastSelection)
{
var graph = selection.graph;
graph.OnEnable();
graph.ValidateGraph();
m_LastSelection = selection;
public void UpdateAsset()
{
if (m_Selected != null && m_Selected is IGraphAsset)
{
var path = AssetDatabase.GetAssetPath (m_Selected.GetScriptableObject());
if (!string.IsNullOrEmpty(path) && m_InMemoryAsset != null)
{
File.WriteAllText (path, EditorJsonUtility.ToJson (m_InMemoryAsset.graph as object));
AssetDatabase.ImportAsset (path);
var source = CreateDataSource();
source.Initialize(m_LastSelection, this);
m_GraphEditorDrawer.presenter = source;
//m_GraphView.StretchToParentSize();
Repaint();
focused = false;
m_GraphEditorDrawer.graphView.Schedule(Focus).StartingIn(1).Until(() => focused);
}
}
}
var asset = AssetDatabase.LoadAssetAtPath<ScriptableObject> (path) as IGraphAsset;
if (asset != null) {
m_Selected = null;
ChangeSelction (asset, false);
}
}
}
}
public void ChangeSelction(IGraphAsset newSelection, bool refocus = true)
{
if (!(newSelection is ScriptableObject))
return;
var newGraph = (ScriptableObject)newSelection;
if (!EditorUtility.IsPersistent (newGraph))
return;
if (m_Selected == newSelection)
return;
if (m_Selected != null) {
if (EditorUtility.DisplayDialog ("Save Old Graph?", "Save Old Graph?", "yes!", "no")) {
UpdateAsset ();
}
}
m_Selected = newSelection;
m_InMemoryAsset = UnityEngine.Object.Instantiate (newGraph) as IGraphAsset;
var graph = m_InMemoryAsset.graph;
graph.OnEnable ();
graph.ValidateGraph ();
var source = CreateDataSource ();
source.Initialize (m_InMemoryAsset, this) ;
m_GraphEditorDrawer.presenter = source;
//m_GraphView.StretchToParentSize();
Repaint ();
if (refocus)
{
focused = false;
m_GraphEditorDrawer.graphView.Schedule (Focus).StartingIn (1).Until (() => focused);
}
}
public void OnBeforeSerialize()
{
m_ToLoad = m_Selected as ScriptableObject;
}
public void OnAfterDeserialize()
{}
/*
private void ConvertSelectionToSubGraph()

m_Canvas.Repaint();
}*/
public void OnBeforeSerialize()
{
var o = m_LastSelection as ScriptableObject;
if (o != null)
m_LastSelectedGraphSerialized = o;
}
public void OnAfterDeserialize()
{
if (m_LastSelectedGraphSerialized != null)
m_LastSelection = m_LastSelectedGraphSerialized as T;
m_LastSelectedGraphSerialized = null;
}
}
}

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphInspector.cs


protected IGraphAsset graphAsset
{
get { return target as IGraphAsset; }
get { return target as IGraphAsset; }
}
protected AbstractGraphInspector(IEnumerable<TypeMapping> typeMappings)

8
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphPresenter.cs


public IGraphAsset graphAsset { get; private set; }
[SerializeField]
private TitleBarPresenter m_TitleBar;
private TitleBarPresenter m_TitleBar;
public TitleBarPresenter titleBar
public TitleBarPresenter titleBar
{
get { return m_TitleBar; }
}

m_Elements.AddRange(drawableEdges.OfType<GraphElementPresenter>());
}
public virtual void Initialize(IGraphAsset graphAsset, EditorWindow container)
public virtual void Initialize(IGraphAsset graphAsset, AbstractGraphEditWindow container)
m_TitleBar.Initialize(graphAsset);
m_TitleBar.Initialize(container);
if (graphAsset == null)
return;

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


namespace UnityEditor.Graphing.Drawing
{
public class GraphEditWindow : AbstractGraphEditWindow<IGraphAsset>
public class GraphEditWindow : AbstractGraphEditWindow
{
[MenuItem("Window/Graph Editor")]
public static void OpenMenu()

88
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs


using UnityEngine.Graphing;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using System.IO;
using System.Linq;
public class TitleBarPresenter : ScriptableObject
public class TitleBarPresenter : ScriptableObject
IGraphAsset m_graphAsset;
AbstractGraphEditWindow m_Owner;
public IEnumerable<TitleBarButtonPresenter> leftItems
{

}
protected TitleBarPresenter()
{
}
{}
public void Initialize(IGraphAsset graphAsset)
public void Initialize(AbstractGraphEditWindow graphWindow)
m_graphAsset = graphAsset;
m_Owner = graphWindow;
currentGraphItem.text = graphAsset != null ? graphAsset.GetScriptableObject().name : "";
currentGraphItem.text = "Put name here";
m_leftItems.Add(currentGraphItem);
var updateAsset = CreateInstance<TitleBarButtonPresenter>();

var showInProjectItem = CreateInstance<TitleBarButtonPresenter>();
showInProjectItem.text = "Show in project";
showInProjectItem.onClick += OnShowInProjectClick;
m_leftItems.Add(showInProjectItem);
var showInProjectItem = CreateInstance<TitleBarButtonPresenter>();
showInProjectItem.text = "Show in project";
showInProjectItem.onClick += OnShowInProjectClick;
m_leftItems.Add(showInProjectItem);
var selectGraph = CreateInstance<TitleBarButtonPresenter>();
selectGraph.text = "Select Graph";
selectGraph.onClick += SelectGraph;
m_leftItems.Add(selectGraph);
var optionsItem = CreateInstance<TitleBarButtonPresenter>();
optionsItem.text = "Options";

void OnShowInProjectClick()
{
if (m_graphAsset != null)
EditorGUIUtility.PingObject(m_graphAsset.GetScriptableObject());
}
void OnShowInProjectClick()
{
if (m_Owner != null)
m_Owner.PingAsset ();
}
class CallbackData
{
public MaterialGraphAsset asset;
public AbstractGraphEditWindow owner;
}
public static List<MaterialGraphAsset> FindAssets()
{
var assets = new List<MaterialGraphAsset>();
string[] guids = AssetDatabase.FindAssets(string.Format("t:MaterialGraphAsset", typeof(MaterialGraphAsset)));
for( int i = 0; i < guids.Length; i++ )
{
string assetPath = AssetDatabase.GUIDToAssetPath( guids[i] );
MaterialGraphAsset asset = AssetDatabase.LoadAssetAtPath<MaterialGraphAsset>( assetPath );
if( asset != null )
{
assets.Add(asset);
}
}
return assets;
}
void SelectGraph()
{
var options = FindAssets().Where (x => EditorUtility.IsPersistent (x)).ToList ();
var gm = new GenericMenu ();
foreach (var option in options) {
gm.AddItem (new GUIContent (AssetDatabase.GetAssetPath (option)), false, Callback, new CallbackData(){asset = option, owner = m_Owner});
}
gm.ShowAsContext ();
}
void Callback(object userData)
{
if (!(userData is CallbackData))
return;
var cbData = (CallbackData)userData;
cbData.owner.ChangeSelction (cbData.asset);
}
if (m_graphAsset != null && m_graphAsset is MaterialGraphAsset)
{
var mg = (MaterialGraphAsset)m_graphAsset;
mg.RegenerateInternalShader();
}
//TODO: We need two currently.. fix later
m_Owner.UpdateAsset ();
m_Owner.UpdateAsset ();
}
}
}

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


public override void Action(int instanceId, string pathName, string resourceFile)
{
var graph = CreateInstance<MaterialGraphAsset>();
graph.name = Path.GetFileName(pathName);
AssetDatabase.CreateAsset(graph, pathName);
var graph = new UnityEngine.MaterialGraph.MaterialGraph();
File.WriteAllText(pathName, EditorJsonUtility.ToJson(graph));
AssetDatabase.Refresh ();
}
}
}

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


namespace UnityEditor.MaterialGraph.Drawing
{
public class MaterialGraphEditWindow : AbstractGraphEditWindow<IMaterialGraphAsset>
public class MaterialGraphEditWindow : AbstractGraphEditWindow
{
[MenuItem("Window/Material Editor")]
public static void OpenMenu()

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


typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter);
typeMapper[typeof(ColorNode)] = typeof(ColorNodePresenter);
typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
typeMapper[typeof(TextureLODNode)] = typeof(TextureLODNodePresenter);
typeMapper[typeof(CubemapNode)] = typeof(CubeNodePresenter);
typeMapper[typeof(UVNode)] = typeof(UVNodePresenter);
typeMapper[typeof(Vector1Node)] = typeof(Vector1NodePresenter);
typeMapper[typeof(Vector2Node)] = typeof(Vector2NodePresenter);

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


get { return m_MaterialGraph; }
}
public MaterialGraph materialGraph
{
get { return m_MaterialGraph; }
set { m_MaterialGraph = value; }
}
#if UNITY_EDITOR
public static bool ShaderHasError(Shader shader)
{

}
public bool RegenerateInternalShader()
{
if (m_MaterialGraph.masterNode == null)
return false;
var path = "Assets/GraphTemp.shader";
List<PropertyGenerator.TextureInfo> configuredTextures;
var shaderString = m_MaterialGraph.masterNode.GetFullShader(GenerationMode.ForReals, out configuredTextures);
File.WriteAllText(path, shaderString);
AssetDatabase.ImportAsset(path);
var shader = AssetDatabase.LoadAssetAtPath(path, typeof(Shader)) as Shader;
if (shader == null)
return false;
var shaderImporter = AssetImporter.GetAtPath(path) as ShaderImporter;
if (shaderImporter == null)
return false;
var textureNames = new List<string>();
var textures = new List<Texture>();
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable == TexturePropertyChunk.ModifiableState.Modifiable))
{
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture;
if (texture == null)
continue;
textureNames.Add(textureInfo.name);
textures.Add(texture);
}
shaderImporter.SetDefaultTextures(textureNames.ToArray(), textures.ToArray());
textureNames.Clear();
textures.Clear();
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable == TexturePropertyChunk.ModifiableState.NonModifiable))
{
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture;
if (texture == null)
continue;
textureNames.Add(textureInfo.name);
textures.Add(texture);
}
shaderImporter.SetNonModifiableTextures(textureNames.ToArray(), textures.ToArray());
shaderImporter.SaveAndReimport();
var imported = shaderImporter.GetShader();
if (m_GeneratedShader == null)
{
m_GeneratedShader = Instantiate(imported);
AssetDatabase.AddObjectToAsset(m_GeneratedShader, this);
}
else
{
AssetDatabase.CopyAsset(imported, m_GeneratedShader);
DestroyImmediate(imported, true);
}
AssetDatabase.DeleteAsset(path);
return true;
}
#endif

8
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Function3Input.cs


{
public abstract class Function3Input : AbstractMaterialNode, IGeneratesBodyCode
{
private const string kInputSlot1ShaderName = "Input1";
private const string kInputSlot2ShaderName = "Input2";
private const string kInputSlot3ShaderName = "Input3";
private const string kOutputSlotShaderName = "Output";
protected const string kInputSlot1ShaderName = "Input1";
protected const string kInputSlot2ShaderName = "Input2";
protected const string kInputSlot3ShaderName = "Input3";
protected const string kOutputSlotShaderName = "Output";
public const int InputSlot1Id = 0;
public const int InputSlot2Id = 1;

1
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PreviewProperty.cs


public Color m_Color;
public Texture2D m_Texture;
public Cubemap m_Cubemap;
public Vector4 m_Vector4;
public float m_Float;
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs


{
Color,
Texture2D,
Cubemap,
Float,
Vector2,
Vector3,

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


public class TimeNode : AbstractMaterialNode, IRequiresTime
{
private const string kOutputSlotName = "Time";
private const string kOutputSlotNameX = "Time.x";
private const string kOutputSlotNameY = "Time.y";
private const string kOutputSlotNameZ = "Time.z";
private const string kOutputSlotNameW = "Time.w";
private const string kOutputSlotNameX = "Time/20";
private const string kOutputSlotNameY = "Time";
private const string kOutputSlotNameZ = "Time * 2";
private const string kOutputSlotNameW = "Time * 3";
public const int OutputSlotId = 0;
public const int OutputSlotIdX = 1;

protected int[] validSlots
{
get { return new[] {OutputSlotId, OutputSlotIdX, OutputSlotIdY, OutputSlotIdZ, OutputSlotId}; }
get { return new[] {OutputSlotId, OutputSlotIdX, OutputSlotIdY, OutputSlotIdZ, OutputSlotIdW}; }
}
public override string GetVariableNameForSlot(int slotId)

9
MaterialGraphProject/Assets/Brandon.meta


fileFormatVersion: 2
guid: fa558cffd4da3284094239ece7c77127
folderAsset: yes
timeCreated: 1495479460
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Matt&Andre.meta


fileFormatVersion: 2
guid: 07096cbe059c94e42b244abc3e875ccf
folderAsset: yes
timeCreated: 1495475979
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Matt.meta


fileFormatVersion: 2
guid: d44a270dca2589e4bb89c277d87ac0d9
folderAsset: yes
timeCreated: 1495475979
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

1
MaterialGraphProject/Assets/New Shader Graph.ShaderGraph


{"m_SerializableNodes":[],"m_SerializableEdges":[],"m_ActiveMasterNodeGUIDSerialized":"49382d1d-b29d-4bfa-ab55-3526be874cd8"}

9
MaterialGraphProject/Assets/New Shader Graph.ShaderGraph.meta


fileFormatVersion: 2
guid: 0e5edf7e3bc2bbc47bdb6b74107cc104
timeCreated: 1495479560
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/TestAssets.meta


fileFormatVersion: 2
guid: f65c08d6acb9e794699bb04e8db778f3
folderAsset: yes
timeCreated: 1490784346
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

52
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/CubemapNodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
class CubeContolPresenter : 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();
var tNode = node as UnityEngine.MaterialGraph.CubemapNode;
if (tNode == null)
return;
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
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);
}
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class CubeNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<CubeContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/CubemapNodePresenter.cs.meta


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

52
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureLODNodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
class TextureLODContolPresenter : 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();
var tNode = node as UnityEngine.MaterialGraph.TextureLODNode;
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(Texture2D), null) as Texture2D;
tNode.textureType = (TextureType)EditorGUILayout.Popup((int)tNode.textureType, textureTypeNames, EditorStyles.popup);
}
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class TextureLODNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<TextureLODContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureLODNodePresenter.cs.meta


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

58
MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader


Shader "Unlit/NewUnlitShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta


fileFormatVersion: 2
guid: 9ab5e16c2083a4fe689209a8c1ae425e
timeCreated: 1495436993
licenseType: Pro
ShaderImporter:
defaultTextures: []
nonModifiableTextures:
- Texture_2ad4e61d_d44e_4e70_b3d0_540eae630bdf_Uniform: {fileID: 2800000, guid: 76c3d794167d8524481195736f067518,
type: 3}
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers.meta


fileFormatVersion: 2
guid: a1485bce8acd0428fae1525629b9ed8b
folderAsset: yes
timeCreated: 1495357309
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

56
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/CubemapPropertyChunk.cs


using System;
using System.Text;
namespace UnityEngine.MaterialGraph
{
public class CubemapPropertyChunk : PropertyChunk
{
public enum ModifiableState
{
Modifiable,
NonModifiable
}
private readonly Cubemap m_DefaultCube;
private readonly ModifiableState m_Modifiable;
public CubemapPropertyChunk(string propertyName, string propertyDescription, Cubemap defaultTexture, HideState hidden, ModifiableState modifiableState)
: base(propertyName, propertyDescription, hidden)
{
m_DefaultCube = defaultTexture;
m_Modifiable = modifiableState;
}
public override string GetPropertyString()
{
var result = new StringBuilder();
if (hideState == HideState.Hidden)
result.Append("[HideInInspector] ");
if (m_Modifiable == ModifiableState.NonModifiable)
result.Append("[NonModifiableTextureData] ");
result.Append(propertyName);
result.Append("(\"");
result.Append(propertyDescription);
result.Append("\", Cube) = \"");
result.Append("");
result.Append("\" {}");
return result.ToString();
}
public Texture defaultCube
{
get
{
return m_DefaultCube;
}
}
public ModifiableState modifiableState
{
get
{
return m_Modifiable;
}
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/CubemapPropertyChunk.cs.meta


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

9
MaterialGraphProject/Assets/Vlad.meta


fileFormatVersion: 2
guid: ea5b5394ff8b04146abae74a39fd167a
folderAsset: yes
timeCreated: 1495479460
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

13
MaterialGraphProject/Assets/Brandon/ATan2Node.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/ArcTan2 Node")]
public class ATan2Node : Function2Input
{
public ATan2Node()
{
name = "ATan2Node";
}
protected override string GetFunctionName() { return "atan2"; }
}
}

12
MaterialGraphProject/Assets/Brandon/ATan2Node.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/ArcCosNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/ArcCos Node")]
public class ACosNode : Function1Input
{
public ACosNode()
{
name = "ACosNode";
}
protected override string GetFunctionName() { return "acos"; }
}
}

12
MaterialGraphProject/Assets/Brandon/ArcCosNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/ArcSinNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/ArcSin Node")]
public class ASinNode : Function1Input
{
public ASinNode()
{
name = "ASinNode";
}
protected override string GetFunctionName() { return "asin"; }
}
}

12
MaterialGraphProject/Assets/Brandon/ArcSinNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/ArcTanNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/ArcTan Node")]
public class ATanNode : Function1Input
{
public ATanNode()
{
name = "ATanNode";
}
protected override string GetFunctionName() { return "atan"; }
}
}

12
MaterialGraphProject/Assets/Brandon/ArcTanNode.cs.meta


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

65
MaterialGraphProject/Assets/Brandon/CartesianToPolarNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Cartesian To Polar Node")]
public class CartesianToPolarNode : Function3Input, IGeneratesFunction
{
public CartesianToPolarNode()
{
name = "CartesianToPolarNode";
}
protected override string GetFunctionName()
{
return "unity_cartesiantopolar_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override string GetInputSlot2Name()
{
return "HorizontalTileScale";
}
protected override string GetInputSlot3Name()
{
return "VerticalTileScale";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetInputSlot3()
{
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector2, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "horizontalTileScale", "verticalTileScale"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float radius = length(uv);", false);
outputString.AddShaderChunk("float angle = atan2(uv.x, uv.y);", false);
outputString.AddShaderChunk("return float2(radius, angle);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/CartesianToPolarNode.cs.meta


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

63
MaterialGraphProject/Assets/Brandon/CheckerboardNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Checkerboard Node")]
public class CheckerboardNode : Function3Input, IGeneratesFunction
{
public CheckerboardNode()
{
name = "CheckerboardNode";
}
protected override string GetFunctionName()
{
return "unity_checkerboard_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override string GetInputSlot2Name()
{
return "HorizontalTileScale";
}
protected override string GetInputSlot3Name()
{
return "VerticalTileScale";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetInputSlot3()
{
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "horizontalTileScale", "verticalTileScale"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return floor(fmod(floor(uv.x * horizontalTileScale) + floor(uv.y * verticalTileScale), 2.0)) * float4(1.0, 1.0, 1.0, 1.0);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/CheckerboardNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/CosNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/Cos Node")]
public class CosNode : Function1Input
{
public CosNode()
{
name = "CosNode";
}
protected override string GetFunctionName() { return "cos"; }
}
}

12
MaterialGraphProject/Assets/Brandon/CosNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/CrossNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/Cross Node")]
public class CrossNode : Function2Input
{
public CrossNode()
{
name = "CrossNode";
}
protected override string GetFunctionName() { return "cross"; }
}
}

12
MaterialGraphProject/Assets/Brandon/CrossNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/DegreesToRadiansNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/Degrees To Radians Node")]
public class DegreesToRadiansNode : Function1Input
{
public DegreesToRadiansNode()
{
name = "DegreesToRadians";
}
protected override string GetFunctionName() { return "radians"; }
}
}

12
MaterialGraphProject/Assets/Brandon/DegreesToRadiansNode.cs.meta


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

58
MaterialGraphProject/Assets/Brandon/GradientRampNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Gradient Ramp Node")]
public class GradientRampNode : Function2Input, IGeneratesFunction
{
public GradientRampNode()
{
name = "GradientRampNode";
}
protected override string GetFunctionName()
{
return "unitygGradientramp_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override string GetInputSlot2Name()
{
return "Stripe Count";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector4.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "stripeCount"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float widthOfEachStripe = 1.0 / stripeCount;", false);
outputString.AddShaderChunk("float t = fmod(floor(uv.x / widthOfEachStripe), stripeCount);", false);
outputString.AddShaderChunk("return lerp(0.0, 1.0, t / (stripeCount - 1.0));", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/GradientRampNode.cs.meta


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

58
MaterialGraphProject/Assets/Brandon/HexNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Hex Node")]
public class HexNode : Function2Input, IGeneratesFunction
{
public HexNode()
{
name = "HexNode";
}
protected override string GetFunctionName()
{
return "unity_hex_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
protected override string GetInputSlot2Name()
{
return "Thickness";
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "thickness"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("uv.y += fmod(floor(uv.x), 2.0) * 0.5;", false);
outputString.AddShaderChunk("uv = abs(frac(uv) - 0.5);", false);
outputString.AddShaderChunk("return step(thickness, abs(max(uv.x * 1.5 + uv.y, uv.y * 2.0) - 1.0));", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/HexNode.cs.meta


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

57
MaterialGraphProject/Assets/Brandon/ParticleNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Particle Node")]
public class ParticleNode : Function2Input, IGeneratesFunction
{
public ParticleNode()
{
name = "ParticleNode";
}
protected override string GetFunctionName()
{
return "unity_particle_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override string GetInputSlot2Name()
{
return "ScaleFactor";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector2.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "scaleFactor"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("uv = uv * 2.0 - 1.0;", false);
outputString.AddShaderChunk("return abs(1.0/length(uv * scaleFactor));", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/ParticleNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/RadiansToDegreesNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/Radians To Degrees Node")]
public class RadiansToDegreesNode : Function1Input
{
public RadiansToDegreesNode()
{
name = "RadiansToDegrees";
}
protected override string GetFunctionName() { return "degrees"; }
}
}

12
MaterialGraphProject/Assets/Brandon/RadiansToDegreesNode.cs.meta


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

29
MaterialGraphProject/Assets/Brandon/ReciprocalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Advanced/Reciprocal Node")]
public class ReciprocalNode : Function1Input, IGeneratesFunction
{
public ReciprocalNode()
{
name = "ReciprocalNode";
}
protected override string GetFunctionName()
{
return "unity_reciprocal_" + precision;
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("arg1"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return 1.0/arg1;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/ReciprocalNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/SinCosNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/SinCos Node")]
public class SinCosNode : Function1Input
{
public SinCosNode()
{
name = "SinCosNode";
}
protected override string GetFunctionName() { return "cos"; }
}
}

12
MaterialGraphProject/Assets/Brandon/SinCosNode.cs.meta


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

13
MaterialGraphProject/Assets/Brandon/TanNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/Tan Node")]
public class TanNode : Function1Input
{
public TanNode()
{
name = "TanNode";
}
protected override string GetFunctionName() { return "tan"; }
}
}

12
MaterialGraphProject/Assets/Brandon/TanNode.cs.meta


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

56
MaterialGraphProject/Assets/Brandon/UVTileNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Tile Node")]
public class UVTileNode : Function2Input, IGeneratesFunction
{
public UVTileNode()
{
name = "UVTileNode";
}
protected override string GetFunctionName()
{
return "unity_uvtile_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override string GetInputSlot2Name()
{
return "Tile Factor (X,Y)";
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector2, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "tileFactor"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return uv * tileFactor;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Brandon/UVTileNode.cs.meta


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

183
MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Range/Remap")]
public class RemapNode : Function2Input, IGeneratesFunction
{
/*protected const string kInputSlot1ShaderName = "Input1";
protected const string kInputSlot2ShaderName = "Input2";
protected const string kOutputSlotShaderName = "Output";
public const int InputSlot1Id = 0;
public const int InputSlot2Id = 1;
public const int OutputSlotId = 2;
[SerializeField]
private Vector4 m_Value;
*/
public RemapNode ()
{
name = "RemapNode";
//UpdateNodeAfterDeserialization ();
}
protected override string GetFunctionName ()
{
return "unity_remap_" + precision;
}
//need to override the type of slot two somehow///////////////////////////////////////////////////
/*override MaterialSlot GetInputSlot2 ()
{
return new MaterialSlot (InputSlot2Id, GetInputSlot2Name (), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector4, Vector4.zero);
}*/
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1", "arg2"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return ((arg1 * (arg2.y - arg2.x)) * (arg2.w - arg2.z))+arg2.z;", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
/*
public sealed override void UpdateNodeAfterDeserialization ()
{
AddSlot (GetInputSlot1 ());
AddSlot (GetInputSlot2 ());
AddSlot (GetOutputSlot ());
RemoveSlotsNameNotMatching (validSlots);
}
protected int[] validSlots {
get { return new[] { InputSlot1Id, InputSlot2Id, OutputSlotId }; }
}
protected virtual MaterialSlot GetInputSlot1 ()
{
return new MaterialSlot (InputSlot1Id, GetInputSlot1Name (), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual MaterialSlot GetInputSlot2 ()
{
return new MaterialSlot (InputSlot2Id, GetInputSlot2Name (), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector4, Vector4.zero);
}
protected virtual MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual string GetInputSlot1Name ()
{
return "Input1";
}
protected virtual string GetInputSlot2Name ()
{
return "RemapVector";
}
protected virtual string GetOutputSlotName ()
{
return "Output";
}
//protected abstract string GetFunctionName ();
/*protected virtual string GetFunctionPrototype (string arg1Name, string arg2Name)
{
return "inline " + precision + outputDimension + " " + GetFunctionName () + " ("
+ precision + input1Dimension + " " + arg1Name + ", "
+ precision + input2Dimension + " " + arg2Name + ")";
}
public void GenerateNodeCode (ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration (this, new[] { InputSlot1Id, InputSlot2Id }, new[] { OutputSlotId });
string input1Value = GetSlotValue (InputSlot1Id, generationMode);
string input2Value = GetSlotValue (InputSlot2Id, generationMode);
visitor.AddShaderChunk (precision + outputDimension + " " + GetVariableNameForSlot (OutputSlotId) + " = " + GetFunctionCallBody (input1Value, input2Value) + ";", true);
}
protected virtual string GetFunctionCallBody (string input1Value, string input2Value)
{
return GetFunctionName () + " (" + input1Value + ", " + input2Value + ")";
}*/
/*public string outputDimension {
get { return ConvertConcreteSlotValueTypeToString (FindOutputSlot<MaterialSlot> (OutputSlotId).concreteValueType); }
}
private string input1Dimension {
get { return ConvertConcreteSlotValueTypeToString (FindInputSlot<MaterialSlot> (InputSlot1Id).concreteValueType); }
}
private string input2Dimension {
get { return ConvertConcreteSlotValueTypeToString (FindInputSlot<MaterialSlot> (InputSlot2Id).concreteValueType); }
}*/
/// <summary>
/// Gets the type of the property.*/
/// </summary>
/// <value>The type of the property.</value>
/*public override PropertyType propertyType {
get { return PropertyType.Vector4; }
}
public Vector4 value {
get { return m_Value; }
set {
if (m_Value == value)
return;
m_Value = value;
if (onModified != null)
onModified (this, ModificationScope.Node);
}
}*/
/*public override void GeneratePropertyBlock (PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty (new VectorPropertyChunk (propertyName, description, m_Value, PropertyChunk.HideState.Visible));
}
public override void GeneratePropertyUsages (ShaderGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed || generationMode.IsPreview ())
visitor.AddShaderChunk (precision + "3 " + propertyName + ";", false);
}*/
/*public void GenerateNodeCode (ShaderGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed || generationMode.IsPreview ())
return;
var input1Value = GetSlotValue (InputSlot1Id, generationMode);
var input2Value = GetSlotValue (InputSlot2Id, generationMode);
visitor.AddShaderChunk (precision + "4 " + propertyName + " = " + input1Value + " * ((" + input2Value + ".w - " + input2Value + ".z) + " + input2Value + ".z);", false);
}
public override bool hasPreview {
get { return true; }
}
public override PreviewProperty GetPreviewProperty ()
{
return new PreviewProperty {
m_Name = propertyName,
m_PropType = PropertyType.Vector4,
m_Vector4 = m_Value
};
}*/
}
}

13
MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Ceil")]
public class CeilNode : Function1Input
{
public CeilNode()
{
name = "Ceil";
}
protected override string GetFunctionName() { return "ceil"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs.meta


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

14
MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Floor")]
public class FloorNode : Function1Input
{
public FloorNode()
{
name = "Floor";
}
protected override string GetFunctionName() { return "floor"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs.meta


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

15
MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Range/Fraction")]
public class FractionNode : Function1Input
{
public FractionNode()
{
name = "Fraction";
}
protected override string GetFunctionName() { return "frac"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs.meta


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

13
MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Round")]
public class RoundNode : Function1Input
{
public RoundNode()
{
name = "Round";
}
protected override string GetFunctionName() { return "round"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs.meta


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

13
MaterialGraphProject/Assets/Matt&Andre/SignNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Sign")]
public class SignNode : Function1Input
{
public SignNode()
{
name = "Sign";
}
protected override string GetFunctionName() { return "sign"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/SignNode.cs.meta


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

12
MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs.meta


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

15
MaterialGraphProject/Assets/Matt&Andre/StepNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Step")]
public class StepNode : Function2Input
{
public StepNode()
{
name = "Step";
}
protected override string GetFunctionName() { return "step"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/StepNode.cs.meta


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

15
MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Truncate")]
public class TruncateNode : Function1Input
{
public TruncateNode()
{
name = "Truncate";
}
protected override string GetFunctionName() { return "truncate"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs.meta


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

12
MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs.meta


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

17
MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Advanced/Fmod")]
public class FmodNode : Function2Input
{
public FmodNode ()
{
name = "Fmod";
}
protected override string GetFunctionName ()
{
return "fmod";
}
}
}

12
MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs.meta


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

14
MaterialGraphProject/Assets/Matt&Andre/LogNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Advanced/Log")]
public class LogNode : Function1Input
{
public LogNode()
{
name = "Log";
}
protected override string GetFunctionName() { return "log"; }
}
}

12
MaterialGraphProject/Assets/Matt&Andre/LogNode.cs.meta


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

17
MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Basic/Exponential")]
public class ExponentialNode : Function1Input
{
public ExponentialNode ()
{
name = "Exponential";
}
protected override string GetFunctionName ()
{
return "exp";
}
}
}

12
MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs.meta


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

45
MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/HSVtoRGB")]
public class HSVtoRGBNode : Function1Input, IGeneratesFunction
{
public HSVtoRGBNode ()
{
name = "HSVtoRGB";
}
protected override string GetFunctionName ()
{
return "unity_hsvtorgb_" + precision;
}
protected override MaterialSlot GetInputSlot ()
{
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
//TODO:Externalize
//Reference code from:https://github.com/Unity-Technologies/PostProcessing/blob/master/PostProcessing/Resources/Shaders/ColorGrading.cginc#L175
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk (precision + "4 K = " + precision + "4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);", false);
outputString.AddShaderChunk (precision + "3 P = abs(frac(arg1.xxx + K.xyz) * 6.0 - K.www);", false);
outputString.AddShaderChunk ("return arg1.z * lerp(K.xxx, saturate(P - K.xxx), arg1.y);", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs.meta


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

45
MaterialGraphProject/Assets/Matt&Andre/HueNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Color/Hue")]
public class HueNode : Function1Input, IGeneratesFunction
{
public HueNode()
{
name = "Hue";
}
protected override string GetFunctionName()
{
return "unity_hue_" + precision;
}
protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
//TODO:Externalize
//Reference code from:https://github.com/Unity-Technologies/PostProcessing/blob/master/PostProcessing/Resources/Shaders/ColorGrading.cginc#L175
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("arg1"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk(precision + "4 K = " + precision + "4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);", false);
outputString.AddShaderChunk(precision + "3 P = abs(frac(arg1.xxx + K.xyz) * 6.0 - K.www);", false);
outputString.AddShaderChunk("return 1 * lerp(K.xxx, saturate(P - K.xxx), 1);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt&Andre/HueNode.cs.meta


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

29
MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Interpolation/InverseLerp")]
public class InverseLerpNode : Function3Input, IGeneratesFunction
{
public InverseLerpNode ()
{
name = "InverseLerp";
}
protected override string GetFunctionName ()
{
return "unity_inverselerp_" + precision;
}
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1", "arg2", "arg3"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return (arg3 - arg1)/(arg2 - arg1);", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs.meta


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

29
MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Range/OneMinus")]
public class OneMinusNode : Function1Input, IGeneratesFunction
{
public OneMinusNode ()
{
name = "OneMinus";
}
protected override string GetFunctionName ()
{
return "unity_oneminus_" + precision;
}
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return arg1 * -1 + 1;", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

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

正在加载...
取消
保存