浏览代码

Merge branch 'master' into node-settings

# Conflicts:
#	com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs
#	com.unity.shadergraph/Editor/Util/UIUtilities.cs
/main
Martin Thorzen 6 年前
当前提交
731a2018
共有 234 个文件被更改,包括 742 次插入81 次删除
  1. 13
      README.md
  2. 3
      TestbedAssets/Beachball.ShaderGraph.meta
  3. 3
      TestbedAssets/Oilish.ShaderGraph.meta
  4. 3
      TestbedAssets/PartyPreview.ShaderGraph.meta
  5. 3
      TestbedAssets/Vector1PropGraph.ShaderGraph.meta
  6. 3
      Testing/IntegrationTests/Graphs/Add.ShaderGraph.meta
  7. 7
      build.py
  8. 59
      com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs
  9. 7
      com.unity.shadergraph/Editor/Data/Graphs/BitangentMaterialSlot.cs
  10. 2
      com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs
  11. 8
      com.unity.shadergraph/Editor/Data/Graphs/NormalMaterialSlot.cs
  12. 8
      com.unity.shadergraph/Editor/Data/Graphs/PositionMaterialSlot.cs
  13. 39
      com.unity.shadergraph/Editor/Data/Graphs/SerializableCubemap.cs
  14. 39
      com.unity.shadergraph/Editor/Data/Graphs/SerializableMesh.cs
  15. 40
      com.unity.shadergraph/Editor/Data/Graphs/SerializableTexture.cs
  16. 8
      com.unity.shadergraph/Editor/Data/Graphs/TangentMaterialSlot.cs
  17. 7
      com.unity.shadergraph/Editor/Data/Graphs/VertexColorMaterialSlot.cs
  18. 7
      com.unity.shadergraph/Editor/Data/Graphs/ViewDirectionMaterialSlot.cs
  19. 16
      com.unity.shadergraph/Editor/Data/MasterNodes/AlphaMode.cs
  20. 56
      com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs
  21. 44
      com.unity.shadergraph/Editor/Data/MasterNodes/UnlitMasterNode.cs
  22. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/ChannelMixerNode.cs
  23. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/ContrastNode.cs
  24. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/HueNode.cs
  25. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/InvertColorsNode.cs
  26. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/ReplaceColorNode.cs
  27. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/SaturationNode.cs
  28. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/WhiteBalanceNode.cs
  29. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Blend/BlendNode.cs
  30. 6
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs
  31. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs
  32. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Mask/ColorMaskNode.cs
  33. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalBlendNode.cs
  34. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalCreateNode.cs
  35. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalStrengthNode.cs
  36. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalUnpackNode.cs
  37. 5
      com.unity.shadergraph/Editor/Data/Nodes/Artistic/Utility/ColorspaceConversion.cs
  38. 5
      com.unity.shadergraph/Editor/Data/Nodes/Channel/CombineNode.cs
  39. 5
      com.unity.shadergraph/Editor/Data/Nodes/Channel/FlipNode.cs
  40. 5
      com.unity.shadergraph/Editor/Data/Nodes/Channel/SplitNode.cs
  41. 15
      com.unity.shadergraph/Editor/Data/Nodes/Channel/SwizzleNode.cs
  42. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/BooleanNode.cs
  43. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/ColorNode.cs
  44. 8
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/ConstantNode.cs
  45. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/IntegerNode.cs
  46. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/SliderNode.cs
  47. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/TimeNode.cs
  48. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector1Node.cs
  49. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector2Node.cs
  50. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector3Node.cs
  51. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector4Node.cs
  52. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BitangentVectorNode.cs
  53. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/NormalVectorNode.cs
  54. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/PositionNode.cs
  55. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs
  56. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/TangentVectorNode.cs
  57. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/UVNode.cs
  58. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs
  59. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs
  60. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs
  61. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs
  62. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs
  63. 8
      com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/TransformationMatrixNode.cs
  64. 8
      com.unity.shadergraph/Editor/Data/Nodes/Input/PBR/DielectricSpecularNode.cs
  65. 8
      com.unity.shadergraph/Editor/Data/Nodes/Input/PBR/MetalReflectanceNode.cs
  66. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/PropertyNode.cs
  67. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/AmbientNode.cs
  68. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/CameraNode.cs
  69. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/FogNode.cs
  70. 7
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/LightProbeNode.cs
  71. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/ObjectNode.cs
  72. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/ReflectionProbeNode.cs
  73. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/ScreenNode.cs
  74. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/CubemapAssetNode.cs
  75. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleCubemapNode.cs
  76. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleTexture2DNode.cs
  77. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SamplerStateNode.cs
  78. 5
      com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/Texture2DAssetNode.cs
  79. 36
      com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs
  80. 2
      com.unity.shadergraph/Editor/Data/Nodes/Math/Basic/MultiplyNode.cs
  81. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixConstructionNode.cs
  82. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixDeterminantNode.cs
  83. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixSplitNode.cs
  84. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixTransposeNode.cs
  85. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Round/CeilingNode.cs
  86. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Round/FloorNode.cs
  87. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Round/RoundNode.cs
  88. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Round/SignNode.cs
  89. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Round/StepNode.cs
  90. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Round/TruncateNode.cs
  91. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/ArccosineNode.cs
  92. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/ArcsineNode.cs
  93. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/Arctangent2Node.cs
  94. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/ArctangentNode.cs
  95. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/CosineNode.cs
  96. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/DegreesToRadiansNode.cs
  97. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/HyperbolicCosineNode.cs
  98. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSineNode.cs
  99. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/HyperbolicTangentNode.cs
  100. 5
      com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/RadiansToDegreesNode.cs

13
README.md


# Shader Graph
![alt text](https://forum.unity.com/proxy.php?image=https%3A%2F%2Flh5.googleusercontent.com%2FUhB18UehZFk8jMo_2V3GW-hD2wARAcQWu6FGzcUvTByHNc51w_mLZBvB6Re5GcTHJQlPHOtzi14wUPvi_yUgWTAp3-HZU463JmxL9NSjJS5yALBSAj1Bdk8yL8zXkRVe-0crKz5F&hash=49458e7088a5be61b288167af65b6faf "Shader Graph")
![Screenshot of Shader Graph](https://forum.unity.com/proxy.php?image=https%3A%2F%2Flh5.googleusercontent.com%2FUhB18UehZFk8jMo_2V3GW-hD2wARAcQWu6FGzcUvTByHNc51w_mLZBvB6Re5GcTHJQlPHOtzi14wUPvi_yUgWTAp3-HZU463JmxL9NSjJS5yALBSAj1Bdk8yL8zXkRVe-0crKz5F&hash=49458e7088a5be61b288167af65b6faf "Shader Graph")
This repository is under active development. Everything is subject to change.
This repository is under active development. Everything is subject to change. The `master` branch is our current development branch and may not work on the latest publicly available version of Unity. Unless you intend to modify Shader Graph or want to try out the very latest and unsupported features, we recommend that you acquire Shader Graph through the Unity Package Manager.
At the moment we recommend using Shader Graph through the [SRP repository](https://github.com/Unity-Technologies/ScriptableRenderPipeline), which has the Shader Graph submodule setup as a submodule. Otherwise you will not have any Master Node backends available and thus your shaders will be pink. This also ensure that you get a compatible set of render pipeline and Shader Graph versions. Otherwise, carry on with the following instructions.
* Clone branch `master`
* Open contained folder `MaterialGraphProject` as a Unity Project
* Quickstart guide can be found [here](https://forum.unity.com/threads/feedback-wanted-shader-graph.511960/)
* Create a new project (or use an existing)
* Clone branch `2018.1` into the `Assets` folder of your project, such that the repository is contained in a sub-folder of the `Assets` folder
* Quick start guide can be found [here](https://forum.unity.com/threads/feedback-wanted-shader-graph.511960/)

3
TestbedAssets/Beachball.ShaderGraph.meta


fileFormatVersion: 2
guid: b141c720617d37f45a2fd27af59ccf42
ScriptedImporter:
fileIDToRecycleName:
4800000: MainAsset
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
TestbedAssets/Oilish.ShaderGraph.meta


fileFormatVersion: 2
guid: abcabb4945a2d6c4aa605f870d393d02
ScriptedImporter:
fileIDToRecycleName:
4800000: MainAsset
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
TestbedAssets/PartyPreview.ShaderGraph.meta


fileFormatVersion: 2
guid: e67b8be7b087145ab87b7ae0a690c35e
ScriptedImporter:
fileIDToRecycleName:
4800000: MainAsset
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
TestbedAssets/Vector1PropGraph.ShaderGraph.meta


fileFormatVersion: 2
guid: 7d765c30286182d4a9e23edbdaf01865
ScriptedImporter:
fileIDToRecycleName:
4800000: MainAsset
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Testing/IntegrationTests/Graphs/Add.ShaderGraph.meta


fileFormatVersion: 2
guid: 5afb17f32b499314c8744c5ee1859a0d
ScriptedImporter:
fileIDToRecycleName:
4800000: MainAsset
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

7
build.py


def packages_list():
return [
("com.unity.shadergraph", os.path.join("MaterialGraphProject", "Assets", "UnityShaderEditor"))
("com.unity.shadergraph", "com.unity.shadergraph")
unity_package_build.copy_path_to_project(os.path.join("MaterialGraphProject", "Assets", "NewNodes"), repo_path, project_path, logger)
unity_package_build.copy_path_to_project(os.path.join("MaterialGraphProject", "Assets", "TestAssets"), repo_path, project_path, logger)
unity_package_build.copy_path_to_project(os.path.join("MaterialGraphProject", "Assets", "UnityShaderEditor", "Editor", "Testing"), repo_path, project_path, logger)
unity_package_build.copy_path_to_project("TestbedAssets", repo_path, project_path, logger)
unity_package_build.copy_path_to_project("Testing", repo_path, project_path, logger)
if __name__ == "__main__":
import sys

59
com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs


using System.Text.RegularExpressions;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.Graphing.Util;
namespace UnityEditor.ShaderGraph
{

get { return m_RemovedNodes; }
}
[NonSerialized]
List<INode> m_PastedNodes = new List<INode>();
public IEnumerable<INode> pastedNodes
{
get { return m_PastedNodes; }
}
#endregion
#region Edge data

{
m_AddedNodes.Clear();
m_RemovedNodes.Clear();
m_PastedNodes.Clear();
m_AddedEdges.Clear();
m_RemovedEdges.Clear();
m_AddedProperties.Clear();

public INode GetNodeFromTempId(Identifier tempId)
{
if (tempId.index > m_Nodes.Count)
throw new ArgumentException("Trying to retrieve a node using an identifier that does not exist.");
throw new Exception("Index does not contain a node.");
throw new Exception("Trying to retrieve a node using an identifier that does not exist.");
if (node.tempId.version != tempId.version)
throw new Exception("Trying to retrieve a node that was removed from the graph.");
return node;

outputSlot = outputNode.FindOutputSlot<MaterialSlot>(edge.outputSlot.slotId);
inputSlot = inputNode.FindInputSlot<MaterialSlot>(edge.inputSlot.slotId);
}
if (outputNode == null
|| inputNode == null
|| outputSlot == null

foreach (var edge in other.edges)
ConnectNoValidate(edge.outputSlot, edge.inputSlot);
ValidateGraph();
}
internal void PasteGraph(CopyPasteGraph graphToPaste, List<INode> remappedNodes, List<IEdge> remappedEdges)
{
var nodeGuidMap = new Dictionary<Guid, Guid>();
foreach (var node in graphToPaste.GetNodes<INode>())
{
var oldGuid = node.guid;
var newGuid = node.RewriteGuid();
nodeGuidMap[oldGuid] = newGuid;
var drawState = node.drawState;
var position = drawState.position;
position.x += 30;
position.y += 30;
drawState.position = position;
node.drawState = drawState;
remappedNodes.Add(node);
AddNode(node);
// add the node to the pasted node list
m_PastedNodes.Add(node);
}
// only connect edges within pasted elements, discard
// external edges.
foreach (var edge in graphToPaste.edges)
{
var outputSlot = edge.outputSlot;
var inputSlot = edge.inputSlot;
Guid remappedOutputNodeGuid;
Guid remappedInputNodeGuid;
if (nodeGuidMap.TryGetValue(outputSlot.nodeGuid, out remappedOutputNodeGuid)
&& nodeGuidMap.TryGetValue(inputSlot.nodeGuid, out remappedInputNodeGuid))
{
var outputSlotRef = new SlotReference(remappedOutputNodeGuid, outputSlot.slotId);
var inputSlotRef = new SlotReference(remappedInputNodeGuid, inputSlot.slotId);
remappedEdges.Add(Connect(outputSlotRef, inputSlotRef));
}
}
ValidateGraph();
}

7
com.unity.shadergraph/Editor/Data/Graphs/BitangentMaterialSlot.cs


using System;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

2
com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs


using UnityEditor.Graphing;
using UnityEngine.Experimental.UIElements;
[assembly: InternalsVisibleTo("com.unity.shadergraph.EditorTests")]
[assembly: InternalsVisibleTo("Unity.ShaderGraph.EditorTests")]
namespace UnityEditor.ShaderGraph
{

8
com.unity.shadergraph/Editor/Data/Graphs/NormalMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

8
com.unity.shadergraph/Editor/Data/Graphs/PositionMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

39
com.unity.shadergraph/Editor/Data/Graphs/SerializableCubemap.cs


public class SerializableCubemap
{
[SerializeField]
private string m_SerializedCubemap;
string m_SerializedCubemap;
[SerializeField]
string m_Guid;
[NonSerialized]
Cubemap m_Cubemap;
private class CubemapHelper
class CubemapHelper
#pragma warning disable 649
#pragma warning restore 649
}
public Cubemap cubemap

if (string.IsNullOrEmpty(m_SerializedCubemap))
return null;
if (!string.IsNullOrEmpty(m_SerializedCubemap))
{
var textureHelper = new CubemapHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedCubemap, textureHelper);
m_SerializedCubemap = null;
m_Guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(textureHelper.cubemap));
m_Cubemap = textureHelper.cubemap;
}
else if (!string.IsNullOrEmpty(m_Guid) && m_Cubemap == null)
{
m_Cubemap = AssetDatabase.LoadAssetAtPath<Cubemap>(AssetDatabase.GUIDToAssetPath(m_Guid));
}
var cube = new CubemapHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedCubemap, cube);
return cube.cubemap;
return m_Cubemap;
if(cubemap == value)
return;
var cubemapHelper = new CubemapHelper();
cubemapHelper.cubemap = value;
m_SerializedCubemap = EditorJsonUtility.ToJson(cubemapHelper, true);
m_SerializedCubemap = null;
m_Guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
m_Cubemap = value;
}
}
}

39
com.unity.shadergraph/Editor/Data/Graphs/SerializableMesh.cs


public class SerializableMesh
{
[SerializeField]
private string m_SerializedMesh;
string m_SerializedMesh;
[SerializeField]
string m_Guid;
[NonSerialized]
Mesh m_Mesh;
private class MeshHelper
class MeshHelper
#pragma warning disable 649
#pragma warning restore 649
}
public Mesh mesh

if (string.IsNullOrEmpty(m_SerializedMesh))
return null;
if (!string.IsNullOrEmpty(m_SerializedMesh))
{
var textureHelper = new MeshHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedMesh, textureHelper);
m_SerializedMesh = null;
m_Guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(textureHelper.mesh));
m_Mesh = textureHelper.mesh;
}
else if (!string.IsNullOrEmpty(m_Guid) && m_Mesh == null)
{
m_Mesh = AssetDatabase.LoadAssetAtPath<Mesh>(AssetDatabase.GUIDToAssetPath(m_Guid));
}
var meshHelper = new MeshHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedMesh, meshHelper);
return meshHelper.mesh;
return m_Mesh;
if (mesh == value)
return;
var meshHelper = new MeshHelper();
meshHelper.mesh = value;
m_SerializedMesh = EditorJsonUtility.ToJson(meshHelper, true);
m_SerializedMesh = null;
m_Guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
m_Mesh = value;
}
}
}

40
com.unity.shadergraph/Editor/Data/Graphs/SerializableTexture.cs


public class SerializableTexture
{
[SerializeField]
private string m_SerializedTexture;
string m_SerializedTexture;
[SerializeField]
string m_Guid;
[NonSerialized]
Texture m_Texture;
private class TextureHelper
class TextureHelper
#pragma warning disable 649
#pragma warning restore 649
}
public Texture texture

if (string.IsNullOrEmpty(m_SerializedTexture))
return null;
var tex = new TextureHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, tex);
return tex.texture;
if (!string.IsNullOrEmpty(m_SerializedTexture))
{
var textureHelper = new TextureHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, textureHelper);
m_SerializedTexture = null;
m_Guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(textureHelper.texture));
m_Texture = textureHelper.texture;
}
else if (!string.IsNullOrEmpty(m_Guid) && m_Texture == null)
{
m_Texture = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(m_Guid));
}
return m_Texture;
if (texture == value)
return;
var textureHelper = new TextureHelper();
textureHelper.texture = value;
m_SerializedTexture = EditorJsonUtility.ToJson(textureHelper, true);
m_SerializedTexture = null;
m_Guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
m_Texture = value;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/TangentMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

7
com.unity.shadergraph/Editor/Data/Graphs/VertexColorMaterialSlot.cs


using System;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, SlotType.Input, Vector3.zero, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView("Vertex Color");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

7
com.unity.shadergraph/Editor/Data/Graphs/ViewDirectionMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

16
com.unity.shadergraph/Editor/Data/MasterNodes/AlphaMode.cs


using System;
namespace UnityEditor.ShaderGraph {
public enum AlphaMode
namespace UnityEditor.ShaderGraph
{
public enum SurfaceType
AlphaBlend,
AdditiveBlend
Transparent
}
public enum AlphaMode
{
Alpha,
Premultiply,
Additive,
Multiply
}
}

56
com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs


using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing;
using UnityEditor.ShaderGraph.Drawing.Controls;

{
[Serializable]
[Title("Master", "PBR")]
public class PBRMasterNode : MasterNode<IPBRSubShader>, IHasSettings
public class PBRMasterNode : MasterNode<IPBRSubShader>, IMayRequireNormal, IHasSettings
{
public const string AlbedoSlotName = "Albedo";
public const string NormalSlotName = "Normal";

[SerializeField]
private Model m_Model = Model.Metallic;
//[EnumControl("")]
[EnumControl("Workflow")]
public Model model
{
get { return m_Model; }

}
[SerializeField]
private SurfaceType m_SurfaceType;
[EnumControl("Surface")]
public SurfaceType surfaceType
{
get { return m_SurfaceType; }
set
{
if (m_SurfaceType == value)
return;
m_SurfaceType = value;
Dirty(ModificationScope.Graph);
}
}
[SerializeField]
//[EnumControl("")]
[EnumControl("Blend")]
public AlphaMode alphaMode
{
get { return m_AlphaMode; }

}
}
[SerializeField]
private bool m_TwoSided;
[ToggleControl("Two Sided")]
public Toggle twoSided
{
get { return new Toggle(m_TwoSided); }
set
{
if (m_TwoSided == value.isOn)
return;
m_TwoSided = value.isOn;
Dirty(ModificationScope.Graph);
}
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/PBR-Master-Node"; }
}
base.UpdateNodeAfterDeserialization();
AddSlot(new Vector3MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, new Vector3(0, 0, 1), ShaderStage.Fragment));
AddSlot(new NormalMaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, CoordinateSpace.Tangent, ShaderStage.Fragment));
AddSlot(new ColorRGBMaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, Color.black, ShaderStage.Fragment));
if (model == Model.Metallic)
AddSlot(new Vector1MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, 0, ShaderStage.Fragment));

AlphaSlotId,
AlphaThresholdSlotId
}, true);
}
if (!subShaders.Any())
AddSubShader(new LightWeightPBRSubShader());
public NeededCoordinateSpace RequiresNormal()
{
List<ISlot> slots = new List<ISlot>();
GetSlots(slots);
return slots.OfType<IMayRequireNormal>().Aggregate(NeededCoordinateSpace.None, (mask, node) => mask | node.RequiresNormal());
}
public VisualElement CreateSettingsElement()

44
com.unity.shadergraph/Editor/Data/MasterNodes/UnlitMasterNode.cs


[SerializeField]
private SurfaceType m_SurfaceType;
[EnumControl("Surface")]
public SurfaceType surfaceType
{
get { return m_SurfaceType; }
set
{
if (m_SurfaceType == value)
return;
m_SurfaceType = value;
Dirty(ModificationScope.Graph);
}
}
[SerializeField]
[EnumControl("")]
[EnumControl("Blend")]
public AlphaMode alphaMode
{
get { return m_AlphaMode; }

}
}
[SerializeField]
private bool m_TwoSided;
[ToggleControl("Two Sided")]
public Toggle twoSided
{
get { return new Toggle(m_TwoSided); }
set
{
if (m_TwoSided == value.isOn)
return;
m_TwoSided = value.isOn;
Dirty(ModificationScope.Graph);
}
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Unlit-Master-Node"; }
}
base.UpdateNodeAfterDeserialization();
name = "Unlit Master";
AddSlot(new ColorRGBMaterialSlot(ColorSlotId, ColorSlotName, ColorSlotName, SlotType.Input, Color.grey, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 1, ShaderStage.Fragment));

AlphaSlotId,
AlphaThresholdSlotId
});
if (!subShaders.Any())
AddSubShader(new LightWeightUnlitSubShader());
}
public VisualElement CreateSettingsElement()

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/ChannelMixerNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Channel-Mixer-Node"; }
}
const int InputSlotId = 0;
const int OutputSlotId = 1;
const string kInputSlotName = "In";

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/ContrastNode.cs


name = "Contrast";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Contrast-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Contrast", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/HueNode.cs


name = "Hue";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Hue-Node"; }
}
[SerializeField]
private HueMode m_HueMode = HueMode.Degrees;

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/InvertColorsNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Invert-Colors-Node"; }
}
const int InputSlotId = 0;
const int OutputSlotId = 1;
const string kInputSlotName = "In";

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/ReplaceColorNode.cs


name = "Replace Color";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Replace-Color-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_ReplaceColor", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/SaturationNode.cs


name = "Saturation";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Saturation-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Saturation", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Adjustment/WhiteBalanceNode.cs


name = "White Balance";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/White-Balance-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_WhiteBalance", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Blend/BlendNode.cs


name = "Blend";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Blend-Node"; }
}
string GetCurrentBlendName()
{
return System.Enum.GetName(typeof(BlendMode), m_BlendMode);

6
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs


name = "Dither";
UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Dither-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Dither", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Channel-Mask-Node"; }
}
const int InputSlotId = 0;
const int OutputSlotId = 1;
const string kInputSlotName = "In";

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Mask/ColorMaskNode.cs


name = "Color Mask";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Color-Mask-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_ColorMask", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalBlendNode.cs


name = "Normal Blend";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Blend-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_NormalBlend", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalCreateNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Create-Node"; }
}
string GetFunctionName()
{
return string.Format("Unity_NormalCreate_{0}", precision);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalStrengthNode.cs


name = "Normal Strength";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Strength-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_NormalStrength", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalUnpackNode.cs


name = "Normal Unpack";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Unpack-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_NormalUnpack", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Artistic/Utility/ColorspaceConversion.cs


name = "Colorspace Conversion";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Colorspace-Conversion-Node"; }
}
[SerializeField]
ColorspaceConversion m_Conversion = new ColorspaceConversion(Colorspace.RGB, Colorspace.RGB);

5
com.unity.shadergraph/Editor/Data/Nodes/Channel/CombineNode.cs


name = "Combine";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Combine-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Combine", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Channel/FlipNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Flip-Node"; }
}
const int InputSlotId = 0;
const int OutputSlotId = 1;
const string kInputSlotName = "In";

5
com.unity.shadergraph/Editor/Data/Nodes/Channel/SplitNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Split-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector4.zero));

15
com.unity.shadergraph/Editor/Data/Nodes/Channel/SwizzleNode.cs


using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;

{
name = "Swizzle";
UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Swizzle-Node"; }
}
const int InputSlotId = 0;

if (inputValueType == ConcreteSlotValueType.Vector1)
visitor.AddShaderChunk(string.Format("{0} {1} = {2};", outputSlotType, outputName, inputValue), false);
else if (generationMode == GenerationMode.ForReals)
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.{3}{4}{5}{6};", outputSlotType, outputName, inputValue, s_ComponentList[m_RedChannel], s_ComponentList[m_GreenChannel], s_ComponentList[m_BlueChannel], s_ComponentList[m_AlphaChannel]), false);
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.{3}{4}{5}{6};",
outputSlotType,
outputName,
inputValue,
s_ComponentList[m_RedChannel].ToString(CultureInfo.InvariantCulture),
s_ComponentList[m_GreenChannel].ToString(CultureInfo.InvariantCulture),
s_ComponentList[m_BlueChannel].ToString(CultureInfo.InvariantCulture),
s_ComponentList[m_AlphaChannel].ToString(CultureInfo.InvariantCulture)), false);
else
visitor.AddShaderChunk(string.Format("{0} {1} = {0}({3}[((int){2} >> 0) & 3], {3}[((int){2} >> 2) & 3], {3}[((int){2} >> 4) & 3], {3}[((int){2} >> 6) & 3]);",
outputSlotType,

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/BooleanNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Boolean-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new BooleanMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, false));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/ColorNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Color-Node"; }
}
[SerializeField]
Color m_Color = new Color(UnityEngine.Color.clear, ColorMode.Default);

8
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/ConstantNode.cs


using System.Collections.Generic;
using System.Globalization;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
using UnityEditor.Graphing;

UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Constant-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));

public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk(precision + " " + GetVariableNameForNode() + " = " + m_constantList[constant] + ";", true);
visitor.AddShaderChunk(precision + " " + GetVariableNameForNode() + " = " + m_constantList[constant].ToString(CultureInfo.InvariantCulture) + ";", true);
}
public override string GetVariableNameForSlot(int slotId)

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/IntegerNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Integer-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/SliderNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Slider-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/TimeNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Time-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector1Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Vector-1-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector2Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Vector-2-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector2MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector3Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Vector-3-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/Vector4Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Vector-4-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BitangentVectorNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Bitangent-Vector-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1)));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/NormalVectorNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Normal-Vector-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1)));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/PositionNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Position-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Screen-Position-Node"; }
}
[SerializeField]
private ScreenSpaceType m_ScreenSpaceType = ScreenSpaceType.Default;

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/TangentVectorNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Tangent-Vector-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1, 1)));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/UVNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/UV-Node"; }
}
public override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector2.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Vertex-Color-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.one));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/View-Direction-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-2x2-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Matrix2MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-3x3-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Matrix3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-4x4-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Matrix4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));

8
com.unity.shadergraph/Editor/Data/Nodes/Input/Matrix/TransformationMatrixNode.cs


using UnityEditor.Graphing;
using System.Collections.Generic;
using System.Globalization;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;

UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Transformation-Matrix-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Matrix4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));

public override string GetVariableNameForSlot(int slotId)
{
return m_matrixList[matrix];
return m_matrixList[matrix].ToString(CultureInfo.InvariantCulture);
}
public bool RequiresVertexColor()

8
com.unity.shadergraph/Editor/Data/Nodes/Input/PBR/DielectricSpecularNode.cs


using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;

{
name = "Dielectric Specular";
UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Dielectric-Specular-Node"; }
}
[SerializeField]

sb.AppendLine("{0}3 {1} = pow(_{2}_IOR - 1, 2) / pow(_{2}_IOR + 1, 2);", precision, GetVariableNameForSlot(kOutputSlotId), GetVariableNameForNode());
break;
default:
sb.AppendLine("{0}3 {1} = {0}3{2};", precision, GetVariableNameForSlot(kOutputSlotId), m_MaterialList[material.type]);
sb.AppendLine("{0}3 {1} = {0}3{2};", precision, GetVariableNameForSlot(kOutputSlotId), m_MaterialList[material.type].ToString(CultureInfo.InvariantCulture));
break;
}
visitor.AddShaderChunk(sb.ToString(), false);

8
com.unity.shadergraph/Editor/Data/Nodes/Input/PBR/MetalReflectanceNode.cs


using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;

{
name = "Metal Reflectance";
UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Metal-Reflectance-Node"; }
}
[SerializeField]

public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3{2};", precision, GetVariableNameForSlot(kOutputSlotId), m_MaterialList[material]), true);
visitor.AddShaderChunk(string.Format("{0}3 {1} = {0}3{2};", precision, GetVariableNameForSlot(kOutputSlotId), m_MaterialList[material].ToString(CultureInfo.InvariantCulture)), true);
}
}
}

5
com.unity.shadergraph/Editor/Data/Nodes/Input/PropertyNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Property-Node"; }
}
private void UpdateNode()
{
var graph = owner as AbstractMaterialGraph;

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/AmbientNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Ambient-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new ColorRGBMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/CameraNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Camera-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/FogNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Fog-Node"; }
}
const int OutputSlotId = 0;
const int OutputSlot1Id = 1;
const string k_OutputSlotName = "Color";

7
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/LightProbeNode.cs


name = "Light Probe";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Light-Probe-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_LightProbe", BindingFlags.Static | BindingFlags.NonPublic);

return
@"
{
Out = ShadeSH9(float4(Normal , 1));
Out = SampleSH(Normal);
}
";
}

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/ObjectNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Object-Node"; }
}
public override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/ReflectionProbeNode.cs


name = "Reflection Probe";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Reflection-Probe-Node"; }
}
public override PreviewMode previewMode
{
get

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Scene/ScreenNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Screen-Node"; }
}
public override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/CubemapAssetNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Cubemap-Asset-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new CubemapMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleCubemapNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sample-Cubemap-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleTexture2DNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sample-Texture-2D-Node"; }
}
[SerializeField]
private TextureType m_TextureType = TextureType.Default;

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SamplerStateNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sampler-State-Node"; }
}
public override bool hasPreview { get { return false; } }
private const int kOutputSlotId = 0;

5
com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/Texture2DAssetNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Texture-2D-Asset-Node"; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Texture2DMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));

36
com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs


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

{
get { return typeof(T); }
}
public IEnumerable<T> subShaders
{
get { return m_SubShaders; }

{
if (m_SubShaders.Contains(subshader))
return;
return;
Dirty(ModificationScope.Node);
Dirty(ModificationScope.Graph);
Dirty(ModificationScope.Node);
Dirty(ModificationScope.Graph);
}
public string GetShader(GenerationMode mode, string outputName, out List<PropertyCollector.TextureInfo> configuredTextures)

public override void OnAfterDeserialize()
{
base.OnAfterDeserialize();
base.OnAfterDeserialize();
}
public override void UpdateNodeAfterDeserialization()
{
base.UpdateNodeAfterDeserialization();
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
foreach (var type in assembly.GetTypesOrNothing())
{
var isValid = !type.IsAbstract && type.IsPublic && !type.IsGenericType && type.IsClass && typeof(T).IsAssignableFrom(type);
if (isValid && !subShaders.Any(s => s.GetType() == type))
{
try
{
var subShader = (T)Activator.CreateInstance(type);
AddSubShader(subShader);
}
catch (Exception e)
{
Debug.LogException(e);
}
}
}
}
}
}
}

2
com.unity.shadergraph/Editor/Data/Nodes/Math/Basic/MultiplyNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new DynamicValueMaterialSlot(Input1SlotId, kInput1SlotName, kInput1SlotName, SlotType.Input, Matrix4x4.zero));
AddSlot(new DynamicValueMaterialSlot(Input2SlotId, kInput2SlotName, kInput2SlotName, SlotType.Input, new Matrix4x4(new Vector4(2,2,2,2), Vector4.zero, Vector4.zero, Vector4.zero)));
AddSlot(new DynamicValueMaterialSlot(Input2SlotId, kInput2SlotName, kInput2SlotName, SlotType.Input, new Matrix4x4(new Vector4(2,2,2,2), new Vector4(2,2,2,2), new Vector4(2,2,2,2), new Vector4(2,2,2,2))));
AddSlot(new DynamicValueMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Matrix4x4.zero));
RemoveSlotsNameNotMatching(new[] { Input1SlotId, Input2SlotId, OutputSlotId });
}

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixConstructionNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-Construction-Node"; }
}
[SerializeField]
MatrixAxis m_Axis;

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixDeterminantNode.cs


name = "Matrix Determinant";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-Determinant-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_MatrixDeterminant", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixSplitNode.cs


UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-Split-Node"; }
}
[SerializeField]
MatrixAxis m_Axis;

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Matrix/MatrixTransposeNode.cs


name = "Matrix Transpose";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Matrix-Transpose-Node"; }
}
public override bool hasPreview
{
get { return false; }

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Round/CeilingNode.cs


name = "Ceiling";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Ceiling-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Ceiling", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Round/FloorNode.cs


name = "Floor";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Floor-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Floor", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Round/RoundNode.cs


name = "Round";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Round-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Round", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Round/SignNode.cs


name = "Sign";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sign-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Sign", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Round/StepNode.cs


name = "Step";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Step-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Step", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Round/TruncateNode.cs


name = "Truncate";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Truncate-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Truncate", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/ArccosineNode.cs


name = "Arccosine";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Arccosine-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Arccosine", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/ArcsineNode.cs


name = "Arcsine";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Arcsine-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Arcsine", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/Arctangent2Node.cs


name = "Arctangent2";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Arctangent2-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Arctangent2", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/ArctangentNode.cs


name = "Arctangent";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Arctangent-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Arctangent", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/CosineNode.cs


name = "Cosine";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Cosine-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Cosine", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/DegreesToRadiansNode.cs


name = "Degrees To Radians";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Degrees-To-Radians-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_DegreesToRadians", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/HyperbolicCosineNode.cs


name = "Hyperbolic Cosine";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Hyperbolic-Cosine-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_HyperbolicCosine", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSineNode.cs


name = "Hyperbolic Sine";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Hyperbolic-Sine-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_HyperbolicSine", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/HyperbolicTangentNode.cs


name = "Hyperbolic Tangent";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Hyperbolic-Tangent-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_HyperbolicTangent", BindingFlags.Static | BindingFlags.NonPublic);

5
com.unity.shadergraph/Editor/Data/Nodes/Math/Trigonometry/RadiansToDegreesNode.cs


name = "Radians To Degrees";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Radians-To-Degrees-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_RadiansToDegrees", BindingFlags.Static | BindingFlags.NonPublic);

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

正在加载...
取消
保存