浏览代码

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

/main
RinaldoTjan 8 年前
当前提交
41da8598
共有 323 个文件被更改,包括 1022 次插入155 次删除
  1. 6
      MaterialGraphProject/Assets/Andre/New Material.mat
  2. 2
      MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
  3. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  4. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/LevelsNodePresenter.cs
  5. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
  6. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
  7. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/CubemapNode.cs
  8. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/CartesianToPolarNode.cs
  9. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/CheckerboardNode.cs
  10. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Trigonometry/DegreesToRadiansNode.cs
  11. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/GradientRampNode.cs
  12. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/HexNode.cs
  13. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/ParticleNode.cs
  14. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Trigonometry/RadiansToDegreesNode.cs
  15. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/ReciprocalNode.cs
  16. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVTileNode.cs
  17. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/LineNode.cs
  18. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVPannerNode.cs
  19. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/AddNode.cs
  20. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector4Node.cs
  21. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Legacy/LegacyBlendNode.cs
  22. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/DivNode.cs
  23. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/DotNode.cs
  24. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/FresnelNode.cs
  25. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/MultiplyNode.cs
  26. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/ReflectNode.cs
  27. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Time/SinTimeNode.cs
  28. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/SubtractNode.cs
  29. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel/SwizzleNode.cs
  30. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Time/TimeNode.cs
  31. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Normal/UnpackNormalNode.cs
  32. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs
  33. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
  34. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector3Node.cs
  35. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
  36. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/ScreenPosNode.cs
  37. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpacePositionNode.cs
  38. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceViewDirectionNode.cs
  39. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceNormalNode.cs
  40. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceTangentNode.cs
  41. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceBitangentNode.cs
  42. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/VertexColorNode.cs
  43. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/UVNode.cs
  44. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureNode.cs
  45. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/LevelsNode.cs
  46. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/HSVtoRGBNode.cs
  47. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/HueNode.cs
  48. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoHSVNode.cs
  49. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/ContrastNode.cs
  50. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/DepthTextureNode.cs
  51. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/MotionVectorTextureNode.cs
  52. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoLuminanceNode.cs
  53. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/SaturationNode.cs
  54. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/LinearToRGBNode.cs
  55. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoLinearNode.cs
  56. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureLODNode.cs
  57. 53
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVRotatorNode.cs
  58. 104
      MaterialGraphProject/Assets/Brandon/NoiseNode.cs
  59. 12
      MaterialGraphProject/Assets/Brandon/NoiseNode.cs.meta
  60. 50
      MaterialGraphProject/Assets/Eduardo/Editor/AddManyNodePresenter.cs
  61. 12
      MaterialGraphProject/Assets/Eduardo/Editor/AddManyNodePresenter.cs.meta
  62. 70
      MaterialGraphProject/Assets/Eduardo/FunctionNAddNode.cs
  63. 12
      MaterialGraphProject/Assets/Eduardo/FunctionNAddNode.cs.meta
  64. 141
      MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
  65. 12
      MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs.meta
  66. 1
      MaterialGraphProject/Assets/TestGraph.ShaderGraph
  67. 9
      MaterialGraphProject/Assets/TestGraph.ShaderGraph.meta
  68. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art.meta
  69. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel.meta
  70. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input.meta
  71. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Legacy.meta
  72. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math.meta
  73. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Normal.meta
  74. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural.meta
  75. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV.meta
  76. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments.meta
  77. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion.meta
  78. 141
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel/CombineNode.cs
  79. 147
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel/SplitNode.cs
  80. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry.meta
  81. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData.meta
  82. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture.meta
  83. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Time.meta
  84. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector.meta
  85. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced.meta

6
MaterialGraphProject/Assets/Andre/New Material.mat


m_Texture: {fileID: 8900000, guid: f7111c407ddfe4109af9703cb740eaf9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_02e4013b_5c99_456a_a8d8_cafbb1dfc0da_Uniform:
m_Texture: {fileID: 2800000, guid: 5a5e07ee958edbd468227e1d9ac4726a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Texture: {fileID: 10305, guid: 0000000000000000f000000000000000, type: 0}
m_Scale: {x: 1, y: 2}
m_Offset: {x: 0, y: 0}
- _BumpMap:

2
MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件

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


typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter);
typeMapper[typeof(AbstractSubGraphIONode)] = typeof(SubgraphIONodePresenter);
typeMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterPresenter);
typeMapper[typeof(LevelNode)] = typeof(LevelNodePresenter);
typeMapper[typeof(LevelsNode)] = typeof(LevelsNodePresenter);
typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/LevelsNodePresenter.cs


namespace UnityEditor.MaterialGraph.Drawing
{
class LevelControlPresenter : GraphControlPresenter
class LevelsControlPresenter : GraphControlPresenter
var tNode = node as LevelNode;
var tNode = node as LevelsNode;
if (tNode == null)
return;

}
[Serializable]
public class LevelNodePresenter : PropertyNodePresenter
public class LevelsNodePresenter : PropertyNodePresenter
var instance = CreateInstance<LevelControlPresenter>();
var instance = CreateInstance<LevelsControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter>(base.GetControlData()) { instance };
}

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


float3 worldSpaceNormal = normalize(IN.worldNormal);
float4 Texture_5537060b_db74_4900_8f2b_178ba97b7f11 = tex2D (Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform, uv0.xy);
float Remap_26b4b7a4_1c55_4c03_9830_fc5d53b3a504_Output = unity_remap_float (Texture_5537060b_db74_4900_8f2b_178ba97b7f11.r, float2 (0,1), float2 (7,-2));
float4 Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9 = texCUBElod (Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9_Uniform, float4(reflect(-IN.worldViewDir, normalize(IN.worldNormal)).xyz,Remap_26b4b7a4_1c55_4c03_9830_fc5d53b3a504_Output));
float4 Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9 = texCUBElod (Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9_Uniform, float4(reflect(-worldSpaceViewDirection, worldSpaceNormal).xyz,Remap_26b4b7a4_1c55_4c03_9830_fc5d53b3a504_Output));
o.Emission = Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9;
}

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


fileFormatVersion: 2
guid: 9ab5e16c2083a4fe689209a8c1ae425e
timeCreated: 1495490387
<<<<<<< HEAD
timeCreated: 1495529915
=======
timeCreated: 1495532053
>>>>>>> f9e75cae7d0f088d17985a220f4ca7ae3da1222a
licenseType: Pro
ShaderImporter:
defaultTextures: []

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/CubemapNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Cubemap")]
[Title("Input/Texture/Cubemap")]
protected const string kUVSlotName = "Refl";
protected const string kUVSlotName = "RefVector";
protected const string kOutputSlotRGBAName = "RGBA";
protected const string kOutputSlotRName = "R";
protected const string kOutputSlotGName = "G";

38
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/CartesianToPolarNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Cartesian To Polar Node")]
public class CartesianToPolarNode : Function3Input, IGeneratesFunction
[Title("UV/Cartesian To Polar")]
public class CartesianToPolarNode : Function1Input, IGeneratesFunction
name = "CartesianToPolarNode";
name = "CartesianToPolar";
}
protected override string GetFunctionName()

protected override string GetInputSlot1Name()
protected override string GetInputSlotName()
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()
protected override MaterialSlot GetInputSlot()
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);
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
outputString.AddShaderChunk(GetFunctionPrototype("uv", "horizontalTileScale", "verticalTileScale"), false);
outputString.AddShaderChunk(GetFunctionPrototype("uv"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float radius = length(uv);", false);

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/CheckerboardNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Checkerboard Node")]
[Title("Procedural/Checkerboard")]
name = "CheckerboardNode";
name = "Checkerboard";
}
protected override string GetFunctionName()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Trigonometry/DegreesToRadiansNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/Degrees To Radians Node")]
[Title("Math/Trigonometry/Degrees To Radians")]
public class DegreesToRadiansNode : Function1Input
{
public DegreesToRadiansNode()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/GradientRampNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Gradient Ramp Node")]
[Title("Procedural/Gradient Ramp")]
name = "GradientRampNode";
name = "GradientRamp";
}
protected override string GetFunctionName()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/HexNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Hex Node")]
[Title("Procedural/Hex")]
name = "HexNode";
name = "Hex";
}
protected override string GetFunctionName()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/ParticleNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Particle Node")]
[Title("Procedural/Particle")]
name = "ParticleNode";
name = "Particle";
}
protected override string GetFunctionName()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Trigonometry/RadiansToDegreesNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Trigonometry/Radians To Degrees Node")]
[Title("Math/Trigonometry/Radians To Degrees")]
public class RadiansToDegreesNode : Function1Input
{
public RadiansToDegreesNode()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/ReciprocalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Advanced/Reciprocal Node")]
[Title("Math/Advanced/Reciprocal")]
name = "ReciprocalNode";
name = "Reciprocal";
}
protected override string GetFunctionName()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVTileNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Tile Node")]
[Title("UV/UV Tile")]
name = "UVTileNode";
name = "UVTile";
}
protected override string GetFunctionName()

20
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/LineNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Line Node")]
[Title("Procedural/Line")]
name = "LineNode";
name = "Line";
}
protected override string GetFunctionName()

outputString.AddShaderChunk(GetFunctionPrototype("uv", "a", "b"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
//float line(vec2 a, vec2 b, vec2 p)
//{
// vec2 aTob = b - a;
// vec2 aTop = p - a;
// float t = dot(aTop, aTob) / dot(aTob, aTob);
// t = clamp(t, 0.0, 1.0);
// float d = length(p - (a + aTob * t));
// d = 1.0 / d;
// return clamp(d, 0.0, 1.0);
//}
outputString.AddShaderChunk("float2 aTob = b - a;", false);
outputString.AddShaderChunk("float2 aTop = uv - a;", false);

6
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVPannerNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Panner")]
[Title("UV/UV Panner")]
name = "Panner";
name = "UVPanner";
return "unity_pan_" + precision;
return "unity_uvpanner_" + precision;
}
protected override string GetInputSlot1Name()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/AddNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Add Node")]
[Title("Math/Basic/Add")]
name = "AddNode";
name = "Add";
}
protected override string GetFunctionName()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector4Node.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Vector 4 Node")]
[Title("Input/Vector/Vector 4")]
public class Vector4Node : PropertyNode, IGeneratesBodyCode
{
[SerializeField]

public Vector4Node()
{
name = "V4Node";
name = "Vector4";
UpdateNodeAfterDeserialization();
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Legacy/LegacyBlendNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Art/Blend Node")]
public class BlendNode : Function2Input, IGeneratesFunction
[Title("Legacy/Blend")]
public class LegacyBlendNode : Function2Input, IGeneratesFunction
public BlendNode()
public LegacyBlendNode()
name = "BlendNode";
name = "Blend";
}
public enum Operation

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/DivNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Div Node")]
[Title("Math/Basic/Divide")]
name = "DivNode";
name = "Divide";
}
protected override string GetFunctionName() {return "unity_div_" + precision; }

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/DotNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Dot Node")]
[Title("Math/Vector/Dot Product")]
name = "DotNode";
name = "DotProduct";
}
protected override string GetFunctionName()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/FresnelNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Fresnel Node")]
[Title("Math/Vector/Fresnel")]
name = "FresnelNode";
name = "Fresnel";
}
protected override MaterialSlot GetInputSlot1()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/MultiplyNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Multiply Node")]
[Title("Math/Basic/Multiply")]
name = "MultiplyNode";
name = "Multiply";
}
protected override string GetFunctionName()

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/ReflectNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Reflect Node")]
[Title("Math/Vector/Reflect")]
name = "ReflectNode";
name = "Reflect";
}
protected override string GetInputSlot1Name() {return "Normal"; }

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Time/SinTimeNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Sine Time Node")]
[Title("Input/Time/Sine Time")]
name = "Sine Time";
name = "SineTime";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/SubtractNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Subtract Node")]
[Title("Math/Basic/Subtract")]
name = "SubtractNode";
name = "Subtract";
}
protected override string GetFunctionName() {return "unity_subtract_" + precision; }

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel/SwizzleNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Channels/Swizzle Node")]
[Title("Channel/Swizzle")]
public class SwizzleNode : Function1Input
{
public enum SwizzleChannel

public SwizzleNode()
{
name = "SwizzleNode";
name = "Swizzle";
}
protected override string GetFunctionName()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Time/TimeNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Time Node")]
[Title("Input/Time/Time")]
public class TimeNode : AbstractMaterialNode, IRequiresTime
{
private const string kOutputSlotName = "Time";

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Normal/UnpackNormalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Channels/Unpack Normal Node")]
[Title("Normal/Unpack Normal")]
name = "UnpackNormalNode";
name = "UnpackNormal";
}
public override bool hasPreview

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Vector 1 Node")]
[Title("Input/Vector/Vector 1")]
public class Vector1Node : PropertyNode, IGeneratesBodyCode
{
[SerializeField]

public Vector1Node()
{
name = "V1Node";
name = "Vector1";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Vector 2 Node")]
[Title("Input/Vector/Vector 2")]
public class Vector2Node : PropertyNode, IGeneratesBodyCode
{
private const int kOutputSlotId = 0;

public Vector2Node()
{
name = "V2Node";
name = "Vector2";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector3Node.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Vector 3 Node")]
[Title("Input/Vector/Vector 3")]
public class Vector3Node : PropertyNode, IGeneratesBodyCode
{
private const int kOutputSlotId = 0;

public Vector3Node()
{
name = "V3Node";
name = "Vector3";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Color Node")]
[Title("Input/Color")]
public class ColorNode : PropertyNode, IGeneratesBodyCode
{
[SerializeField]

public ColorNode()
{
name = "ColorNode";
name = "Color";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/ScreenPosNode.cs


bool RequiresScreenPosition();
}
[Title("Input/Screen Pos Node")]
[Title("Input/Scene Data/Screen Position")]
name = "ScreenPos";
name = "ScreenPosition";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpacePositionNode.cs


bool RequiresWorldPosition();
}
[Title("Input/World Space Position Node")]
[Title("Input/Geometry/World Space Position")]
public class WorldSpacePositionNode : AbstractMaterialNode, IMayRequireWorldPosition
{
private const int kOutputSlotId = 0;

public WorldSpacePositionNode()
{
name = "World Space Pos";
name = "WorldSpacePosition";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceViewDirectionNode.cs


bool RequiresViewDirection();
}
[Title("Input/World Space View Direction Node")]
[Title("Input/Geometry/World Space View Direction")]
public class WorldSpaceViewDirectionNode : AbstractMaterialNode, IMayRequireViewDirection
{
private const int kOutputSlotId = 0;

public WorldSpaceViewDirectionNode()
{
name = "World View Direction";
name = "WorldSpaceViewDirection";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceNormalNode.cs


bool RequiresNormal();
}
[Title("Input/World Normal Node")]
[Title("Input/Geometry/World Normal")]
public class WorldSpaceNormalNode : AbstractMaterialNode, IMayRequireNormal
{
public const int kOutputSlotId = 0;

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

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceTangentNode.cs


bool RequiresTangent();
}
[Title("Input/World Tangent Node")]
[Title("Input/Geometry/World Tangent")]
public class WorldSpaceTangentNode : AbstractMaterialNode, IMayRequireTangent
{
public const int kOutputSlotId = 0;

{
name = "World Tangent";
name = "WorldTangent";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceBitangentNode.cs


bool RequiresBitangent();
}
[Title("Input/World Bitangent Node")]
[Title("Input/Geometry/World Bitangent")]
public class WorldSpaceBitangentNode : AbstractMaterialNode, IMayRequireBitangent
{
public const int kOutputSlotId = 0;

{
name = "World Bitangent";
name = "WorldBitangent";
UpdateNodeAfterDeserialization();
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/VertexColorNode.cs


bool RequiresVertexColor();
}
[Title("Input/Vertex Color Node")]
[Title("Input/Geometry/Vertex Color")]
public class VertexColorNode : AbstractMaterialNode, IMayRequireVertexColor
{
private const int kOutputSlotId = 0;

public VertexColorNode()
{
name = "Vertex Color";
name = "VertexColor";
UpdateNodeAfterDeserialization();
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/UVNode.cs


bool RequiresMeshUV(UVChannel channel);
}
[Title("Input/UV Node")]
[Title("Input/Geometry/UV")]
public class UVNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
{
public const int OutputSlotId = 0;

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureNode.cs


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

10
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/LevelsNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Range/Level Node")]
public class LevelNode : Function1Input, IGeneratesFunction
[Title("Art/Adjustments/Levels")]
public class LevelsNode : Function1Input, IGeneratesFunction
{
[SerializeField]
private float m_InputMin = 0.0f;

}
}
public LevelNode()
public LevelsNode()
name = "LevelNode";
name = "Levels";
return "unity_level_" + precision;
return "unity_levels_" + precision;
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/HSVtoRGBNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/HSVtoRGB")]
[Title ("Art/Conversion/HSVtoRGB")]
public class HSVtoRGBNode : Function1Input, IGeneratesFunction
{
public HSVtoRGBNode ()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/HueNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Color/Hue")]
[Title("Art/Adjustments/Hue")]
public class HueNode : Function1Input, IGeneratesFunction
{
public HueNode()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoHSVNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoHSV")]
[Title ("Art/Conversion/RGBtoHSV")]
public class RGBtoHSVNode : Function1Input, IGeneratesFunction
{
public RGBtoHSVNode ()

6
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/ContrastNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/Contrast")]
public class Contrast : Function3Input, IGeneratesFunction
[Title ("Art/Adjustments/Contrast")]
public class ContrastNode : Function3Input, IGeneratesFunction
public Contrast()
public ContrastNode()
{
name = "Contrast";
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/DepthTextureNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Depth Texture")]
[Title("Input/Scene Data/Depth Texture")]
public class DepthTextureNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV
{
protected const string kUVSlotName = "UV";

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/MotionVectorTextureNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Motion Vector Texture")]
[Title("Input/Scene Data/Motion Vector Texture")]
public class MotionVectorTextureNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV
{
protected const string kUVSlotName = "UV";

6
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoLuminanceNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoLuminance")]
public class RGBtoLuminance : Function1Input, IGeneratesFunction
[Title ("Art/Conversion/RGBtoLuminance")]
public class RGBtoLuminanceNode : Function1Input, IGeneratesFunction
public RGBtoLuminance()
public RGBtoLuminanceNode()
{
name = "RGBtoLuminance";
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/SaturationNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/Saturation")]
public class Saturation : Function2Input, IGeneratesFunction
[Title ("Art/Adjustments/Saturation")]
public class SaturationNode : Function2Input, IGeneratesFunction
public Saturation()
public SaturationNode()
{
name = "Saturation";
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/LinearToRGBNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/LineartoRGB")]
[Title ("Art/Conversion/LineartoRGB")]
public class LineartoRGBNode : Function1Input, IGeneratesFunction
{
public LineartoRGBNode()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoLinearNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoLinear")]
[Title ("Art/Conversion/RGBtoLinear")]
public class RGBtoLinearNode : Function1Input, IGeneratesFunction
{
public RGBtoLinearNode()

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureLODNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/TextureLOD")]
[Title("Input/Texture/TextureLOD")]
public class TextureLODNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV
{
protected const string kUVSlotName = "UV";

53
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVRotatorNode.cs


using UnityEngine.Graphing;
using System.Collections.Generic;
using System.Linq;
[Title("UV/Rotator")]
public class UVRotatorNode : Function2Input, IGeneratesFunction
[Title("UV/UV Rotator")]
public class UVRotatorNode : Function2Input, IGeneratesFunction, IMayRequireMeshUV
{
private const string kUVSlotName = "UV";
private const string kRotationSlotName = "Rotation";

protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, kUVSlotName, kUVSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero);
return new MaterialSlot(OutputSlotId, kUVSlotName, kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
protected override string GetFunctionCallBody(string input1Value, string input2Value)
{
//get input UV slot
var uvName = string.Format("{0}", UVChannel.uv0.GetUVName());
bool isConnected = false;
var uvSlot = FindInputSlot<MaterialSlot>(InputSlot1Id);
if (uvSlot != null)
{
var edges = owner.GetEdges(uvSlot.slotReference).ToList();
if (edges.Count > 0)
{
var edge = edges[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
uvName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Vector4, true);
isConnected = true;
}
}
if (isConnected)
return GetFunctionName() + " (" + input1Value + ", " + input2Value + ")";
else
return GetFunctionName() + " (" + uvName + ", " + input2Value + ")";
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();

outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
public bool RequiresMeshUV(UVChannel channel)
{
if (channel != UVChannel.uv0)
{
return false;
}
var uvSlot = FindInputSlot<MaterialSlot>(InputSlot1Id);
if (uvSlot == null)
return true;
var edges = owner.GetEdges(uvSlot.slotReference).ToList();
return edges.Count == 0;
}
}
}

104
MaterialGraphProject/Assets/Brandon/NoiseNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Noise")]
public class NoiseNode : Function1Input, IGeneratesFunction
{
public NoiseNode()
{
name = "Noise";
}
protected override string GetFunctionName()
{
return "unity_noise_" + precision;
}
protected override string GetInputSlotName()
{
return "UV";
}
protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, 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("inline float unity_noise_randomValue (float2 uv)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("inline float unity_noise_interpolate (float a, float b, float t)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return (1.0-t)*a + (t*b);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("inline float unity_valueNoise (float2 uv)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float2 i = floor(uv);", false);
outputString.AddShaderChunk("float2 f = frac(uv);", false);
outputString.AddShaderChunk("f = f * f * (3.0 - 2.0 * f);", false);
outputString.AddShaderChunk("uv = abs(frac(uv) - 0.5);", false);
outputString.AddShaderChunk("float2 c0 = i + float2(0.0, 0.0);", false);
outputString.AddShaderChunk("float2 c1 = i + float2(1.0, 0.0);", false);
outputString.AddShaderChunk("float2 c2 = i + float2(0.0, 1.0);", false);
outputString.AddShaderChunk("float2 c3 = i + float2(1.0, 1.0);", false);
outputString.AddShaderChunk("float r0 = unity_noise_randomValue(c0);", false);
outputString.AddShaderChunk("float r1 = unity_noise_randomValue(c1);", false);
outputString.AddShaderChunk("float r2 = unity_noise_randomValue(c2);", false);
outputString.AddShaderChunk("float r3 = unity_noise_randomValue(c3);", false);
outputString.AddShaderChunk("float bottomOfGrid = unity_noise_interpolate(r0, r1, f.x);", false);
outputString.AddShaderChunk("float topOfGrid = unity_noise_interpolate(r2, r3, f.x);", false);
outputString.AddShaderChunk("float t = unity_noise_interpolate(bottomOfGrid, topOfGrid, f.y);", false);
outputString.AddShaderChunk("return t;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk(GetFunctionPrototype("uv"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float t = 0.0;", false);
outputString.AddShaderChunk("for(int i = 0; i < 3; i++)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float freq = pow(2.0, float(i));", false);
outputString.AddShaderChunk("float amp = pow(0.5, float(3-i));", false);
outputString.AddShaderChunk("t += unity_valueNoise(float2(uv.x/freq, uv.y/freq))*amp;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("return t;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

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


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

50
MaterialGraphProject/Assets/Eduardo/Editor/AddManyNodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class AddManyContolPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var addNode = node as UnityEngine.MaterialGraph.AddManyNode;
if (addNode == null)
return;
if (GUILayout.Button("Add Input"))
{
addNode.AddInputSlot();
addNode.OnModified();
}
if (GUILayout.Button("Remove Input"))
{
addNode.RemoveInputSlot();
addNode.OnModified();
}
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class AddManyNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<AddManyContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

12
MaterialGraphProject/Assets/Eduardo/Editor/AddManyNodePresenter.cs.meta


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

70
MaterialGraphProject/Assets/Eduardo/FunctionNAddNode.cs


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

12
MaterialGraphProject/Assets/Eduardo/FunctionNAddNode.cs.meta


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

141
MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs


using UnityEngine.Graphing;
using System.Linq;
using System.Collections;
using System;
namespace UnityEngine.MaterialGraph
{
public abstract class FunctionNInNOut : AbstractMaterialNode, IGeneratesBodyCode
{
public FunctionNInNOut()
{
name = "FunctionNInNOut";
}
public override void UpdateNodeAfterDeserialization()
{
base.UpdateNodeAfterDeserialization();
foreach (var slot in GetSlots<MaterialSlot>())
{
slot.showValue = true;
}
}
public int AddSlot(string displayName, string nameInShader, SlotType slotType, SlotValueType valueType)
{
int nextSlotId;
if (slotType == SlotType.Output)
nextSlotId = -( GetOutputSlots<MaterialSlot>().Count() + 1 );
else
nextSlotId = GetInputSlots<MaterialSlot>().Count() + 1;
AddSlot(new MaterialSlot(nextSlotId, displayName, nameInShader, slotType, valueType, Vector4.zero, true));
return nextSlotId;
}
public void RemoveOutputSlot()
{
var lastSlotId = -GetOutputSlots<ISlot>().Count();
RemoveSlotById(lastSlotId);
}
public void RemoveInputSlot()
{
var lastSlotId = GetInputSlots<ISlot>().Count();
RemoveSlotById(lastSlotId);
}
private void RemoveSlotById(int slotID)
{
if (slotID == 0)
return;
RemoveSlot(slotID);
}
public string GetSlotTypeName(int slotId)
{
return ConvertConcreteSlotValueTypeToString(FindSlot<MaterialSlot>(slotId).concreteValueType);
}
protected string GetShaderOutputName(int slotId)
{
return FindSlot<MaterialSlot>(slotId).shaderOutputName;
}
// Must override this
protected abstract string GetFunctionName();
private string GetFunctionParameters()
{
string param = "";
int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
if (inSlot.isOutputSlot)
param += "out ";
param += precision + GetSlotTypeName(inSlot.id) + " ";
param += GetShaderOutputName(inSlot.id);
if (remainingParams > 1)
param += ", ";
--remainingParams;
}
return param;
}
private string GetFunctionCallParameters(GenerationMode generationMode)
{
string param = "";
int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
param += GetSlotValue(inSlot.id, generationMode);
if (remainingParams > 1)
param += ", ";
--remainingParams;
}
return param;
}
protected string GetFunctionPrototype()
{
return "inline " + "void" + " " + GetFunctionName() +
" (" +
GetFunctionParameters() +
")";
}
private string GetFunctionCall(GenerationMode generationMode)
{
return GetFunctionName() +
" (" +
GetFunctionCallParameters(generationMode) +
");";
}
private string GetOutputDeclaration()
{
string outDeclaration = "";
foreach (ISlot outSlot in GetOutputSlots<ISlot>())
{
outDeclaration += "\n " + precision + GetSlotTypeName(outSlot.id) + " " + GetVariableNameForSlot(outSlot.id) + ";\n";
}
return outDeclaration;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetOutputDeclaration(), false);
outputString.AddShaderChunk(GetFunctionCall(generationMode), false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs.meta


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

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

9
MaterialGraphProject/Assets/TestGraph.ShaderGraph.meta


fileFormatVersion: 2
guid: 037778188549d9b4e8102cd29dea21a9
timeCreated: 1495526245
licenseType: Pro
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art.meta


fileFormatVersion: 2
guid: 8ee6f8ab31f6bf349a63fdd21fc88664
folderAsset: yes
timeCreated: 1495532491
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel.meta


fileFormatVersion: 2
guid: 9e3d3d0ce68bbc843b9b8734ab8d4f02
folderAsset: yes
timeCreated: 1495531110
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input.meta


fileFormatVersion: 2
guid: 0ab9e53346965db4a8ee81a2b978dca5
folderAsset: yes
timeCreated: 1495526789
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Legacy.meta


fileFormatVersion: 2
guid: eb0cb153896a18c4ebb6d116283dfda4
folderAsset: yes
timeCreated: 1495532221
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math.meta


fileFormatVersion: 2
guid: e63f07e66d070412bb6e9582ca1eba72
folderAsset: yes
timeCreated: 1495526358
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Normal.meta


fileFormatVersion: 2
guid: 8443203ba8104ff4bb0a6a0ed978034e
folderAsset: yes
timeCreated: 1495532369
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural.meta


fileFormatVersion: 2
guid: e74e11761cab2b446b96ce63e2d657b3
folderAsset: yes
timeCreated: 1495530729
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV.meta


fileFormatVersion: 2
guid: f9c248f478f706147ba7b8a660035472
folderAsset: yes
timeCreated: 1495529881
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments.meta


fileFormatVersion: 2
guid: 75cc6d701e07fe246ba5377a454f74c4
folderAsset: yes
timeCreated: 1495532497
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion.meta


fileFormatVersion: 2
guid: 9134a2b351ed9f140bfbb2d46f9075b5
folderAsset: yes
timeCreated: 1495532965
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

141
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel/CombineNode.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Channel/Combine")]
public class CombineNode : PropertyNode, IGeneratesBodyCode
{
protected const string kOutputSlot0Id = "Input0";
protected const string kOutputSlot1Id = "Input1";
protected const string kOutputSlot2Id = "Input2";
protected const string kOutputSlot3Id = "Input3";
protected const string kOutputSlotRGBAName = "RGBA";
protected const string kOutputSlotRGBSlotName = "RGB";
protected const string kOutputSlotRGSlotName = "RG";
public const int InputSlot0Id = 0;
public const int InputSlot1Id = 1;
public const int InputSlot2Id = 2;
public const int InputSlot3Id = 3;
public const int OutputSlotRGBAId = 4;
public const int OutputSlotRGBId = 5;
public const int OutputSlotRGId = 6;
public CombineNode()
{
name = "Combine";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(InputSlot0Id, kOutputSlot0Id, kOutputSlot0Id, SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(InputSlot1Id, kOutputSlot1Id, kOutputSlot1Id, SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(InputSlot2Id, kOutputSlot2Id, kOutputSlot2Id, SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(InputSlot3Id, kOutputSlot3Id, kOutputSlot3Id, SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRGBId, kOutputSlotRGBSlotName, kOutputSlotRGBSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRGId, kOutputSlotRGSlotName, kOutputSlotRGSlotName, SlotType.Output, SlotValueType.Vector2, Vector4.zero));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { InputSlot0Id, InputSlot1Id, InputSlot2Id, InputSlot3Id, OutputSlotRGBAId, OutputSlotRGBId, OutputSlotRGId }; }
}
[SerializeField]
private Vector4 m_Value;
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 PropertyType propertyType { get { return PropertyType.Vector4; } }
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 + "4 " + propertyName + ";", true);
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
var inputValue = GetSlotValue(InputSlot0Id, generationMode);
visitor.AddShaderChunk(precision + "4 " + propertyName + " = " + inputValue + ";", false);
//visitor.AddShaderChunk(precision + "4 " + propertyName + " = " + precision + "4 (" + m_Value.x + ", " + m_Value.y + ", " + m_Value.z + ", " + m_Value.w + ");", true);
}
protected virtual MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlot0Id, GetInputSlotName(), kOutputSlot0Id, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual string GetInputSlotName() { return "Input"; }
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector4,
m_Vector4 = m_Value
};
}
/*public override string GetVariableNameForSlot(int slotId)
{
string slotOutput;
switch (slotId)
{
case OutputSlotRId:
slotOutput = ".r";
break;
case OutputSlotGId:
slotOutput = ".g";
break;
case OutputSlotBId:
slotOutput = ".b";
break;
case OutputSlotAId:
slotOutput = ".a";
break;
default:
slotOutput = "";
break;
}
return propertyName + slotOutput;
//return GetVariableNameForNode() + slotOutput;
}*/
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(GetPreviewProperty());
}
}
}

147
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Channel/SplitNode.cs


using System;
using System.Collections.Generic;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Channel/Split")]
public class SplitNode : PropertyNode, IGeneratesBodyCode
{
protected const string kInputSlotName = "Input";
protected const string kOutputSlotRName = "R";
protected const string kOutputSlotGName = "G";
protected const string kOutputSlotBName = "B";
protected const string kOutputSlotAName = "A";
protected const string kOutputSlotRGBName = "RGB";
protected const string kOutputSlotRGName = "RG";
public const int InputSlotId = 0;
public const int OutputSlotRId = 1;
public const int OutputSlotGId = 2;
public const int OutputSlotBId = 3;
public const int OutputSlotAId = 4;
public const int OutputSlotRGBId = 5;
public const int OutputSlotRGId = 6;
public SplitNode()
{
name = "Split";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRId, kOutputSlotRName, kOutputSlotRName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRGBId, kOutputSlotRGBName, kOutputSlotRGBName, SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotRGId, kOutputSlotRGName, kOutputSlotRGName, SlotType.Output, SlotValueType.Vector2, Vector4.zero));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { InputSlotId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, OutputSlotRGBId, OutputSlotRGId }; }
}
[SerializeField]
private Vector4 m_Value;
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 PropertyType propertyType { get { return PropertyType.Vector4; } }
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 + "4 " + propertyName + ";", true);
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
var inputValue = GetSlotValue(InputSlotId, generationMode);
visitor.AddShaderChunk(precision + "4 " + propertyName + " = " + inputValue + ";", false);
//visitor.AddShaderChunk(precision + "4 " + propertyName + " = " + precision + "4 (" + m_Value.x + ", " + m_Value.y + ", " + m_Value.z + ", " + m_Value.w + ");", true);
}
protected virtual MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual string GetInputSlotName() { return "Input"; }
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector4,
m_Vector4 = m_Value
};
}
public override string GetVariableNameForSlot(int slotId)
{
string slotOutput;
switch (slotId)
{
case OutputSlotRId:
slotOutput = ".r";
break;
case OutputSlotGId:
slotOutput = ".g";
break;
case OutputSlotBId:
slotOutput = ".b";
break;
case OutputSlotAId:
slotOutput = ".a";
break;
case OutputSlotRGBId:
slotOutput = ".rgb";
break;
case OutputSlotRGId:
slotOutput = ".rg";
break;
default:
slotOutput = "";
break;
}
return propertyName + slotOutput;
//return GetVariableNameForNode() + slotOutput;
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(GetPreviewProperty());
}
}
}

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry.meta


fileFormatVersion: 2
guid: 5e9138df313dc9e4fa20f92625c26b59
folderAsset: yes
timeCreated: 1495527166
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData.meta


fileFormatVersion: 2
guid: ad6f48f5ba4c9a24ab7b9df345b45d6f
folderAsset: yes
timeCreated: 1495527773
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture.meta


fileFormatVersion: 2
guid: 07cc6493671f2344089936cf4a0ab49b
folderAsset: yes
timeCreated: 1495528572
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Time.meta


fileFormatVersion: 2
guid: 5d0ea40228d32a44c94e79db32eb2060
folderAsset: yes
timeCreated: 1495529303
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector.meta


fileFormatVersion: 2
guid: 1ccfba538a5b85b43a9d78f3057e00f2
folderAsset: yes
timeCreated: 1495526799
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced.meta


fileFormatVersion: 2
guid: 198ec765a01574320a8199338d27d9f1
folderAsset: yes
timeCreated: 1495526831
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

正在加载...
取消
保存