浏览代码

Cleanup

Cleaned up new nodes
Changed Function3Input kShaderNames to be protected
/main
Matt Dean 8 年前
当前提交
2c5dc651
共有 93 个文件被更改,包括 1904 次插入629 次删除
  1. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Function3Input.cs
  2. 34
      MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs
  3. 24
      MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs.meta
  4. 28
      MaterialGraphProject/Assets/Matt&Andre/LogNode.cs
  5. 24
      MaterialGraphProject/Assets/Matt&Andre/LogNode.cs.meta
  6. 34
      MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs
  7. 24
      MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs.meta
  8. 90
      MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs
  9. 24
      MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs.meta
  10. 90
      MaterialGraphProject/Assets/Matt&Andre/HueNode.cs
  11. 24
      MaterialGraphProject/Assets/Matt&Andre/HueNode.cs.meta
  12. 58
      MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs
  13. 24
      MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs.meta
  14. 58
      MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs
  15. 16
      MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs.meta
  16. 24
      MaterialGraphProject/Assets/Matt/Contrast.cs.meta
  17. 96
      MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs
  18. 24
      MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs.meta
  19. 24
      MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs.meta
  20. 34
      MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs
  21. 434
      MaterialGraphProject/Assets/TestAssets/Sky1.jpg
  22. 152
      MaterialGraphProject/Assets/TestAssets/ColorGuide.tif.meta
  23. 152
      MaterialGraphProject/Assets/TestAssets/Gradient.png.meta
  24. 152
      MaterialGraphProject/Assets/TestAssets/sfn_vertexcolor.png.meta
  25. 25
      MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs
  26. 9
      MaterialGraphProject/Assets/Matt&Andre.meta
  27. 9
      MaterialGraphProject/Assets/Matt.meta
  28. 183
      MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs
  29. 64
      MaterialGraphProject/Assets/Matt/Contrast.cs
  30. 15
      MaterialGraphProject/Assets/Matt/DDX.cs
  31. 12
      MaterialGraphProject/Assets/Matt/DDX.cs.meta
  32. 31
      MaterialGraphProject/Assets/Matt/DDXY.cs
  33. 12
      MaterialGraphProject/Assets/Matt/DDXY.cs.meta
  34. 15
      MaterialGraphProject/Assets/Matt/DDY.cs
  35. 12
      MaterialGraphProject/Assets/Matt/DDY.cs.meta
  36. 104
      MaterialGraphProject/Assets/Matt/DepthTexture.cs
  37. 44
      MaterialGraphProject/Assets/Matt/Desaturate.cs
  38. 12
      MaterialGraphProject/Assets/Matt/Desaturate.cs.meta
  39. 15
      MaterialGraphProject/Assets/Matt/Distance.cs
  40. 12
      MaterialGraphProject/Assets/Matt/Distance.cs.meta
  41. 104
      MaterialGraphProject/Assets/Matt/MotionVectorTexture.cs
  42. 12
      MaterialGraphProject/Assets/Matt/MotionVectorTexture.cs.meta
  43. 48
      MaterialGraphProject/Assets/Matt/NormalBlend.cs
  44. 12
      MaterialGraphProject/Assets/Matt/NormalBlend.cs.meta
  45. 42
      MaterialGraphProject/Assets/Matt/RGBtoLuminance.cs
  46. 12
      MaterialGraphProject/Assets/Matt/RGBtoLuminance.cs.meta
  47. 56
      MaterialGraphProject/Assets/Matt/Saturation.cs
  48. 12
      MaterialGraphProject/Assets/Matt/Saturation.cs.meta
  49. 9
      MaterialGraphProject/Assets/NewNodes.meta
  50. 0
      /MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs
  51. 0
      /MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs.meta
  52. 0
      /MaterialGraphProject/Assets/Matt&Andre/LogNode.cs
  53. 0
      /MaterialGraphProject/Assets/Matt&Andre/LogNode.cs.meta
  54. 0
      /MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs
  55. 0
      /MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs.meta
  56. 0
      /MaterialGraphProject/Assets/Matt/DepthTexture.cs.meta
  57. 0
      /MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs
  58. 0
      /MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs.meta
  59. 0
      /MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs
  60. 0
      /MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs.meta
  61. 0
      /MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs
  62. 0
      /MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs.meta
  63. 0
      /MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs
  64. 0
      /MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs.meta
  65. 0
      /MaterialGraphProject/Assets/Matt&Andre/HueNode.cs
  66. 0
      /MaterialGraphProject/Assets/Matt&Andre/HueNode.cs.meta
  67. 0
      /MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs
  68. 0
      /MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs.meta
  69. 0
      /MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs
  70. 0
      /MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs.meta
  71. 0
      /MaterialGraphProject/Assets/Matt/Contrast.cs.meta
  72. 0
      /MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs
  73. 0
      /MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs.meta
  74. 0
      /MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs.meta
  75. 0
      /MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs
  76. 0
      /MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs.meta
  77. 0
      /MaterialGraphProject/Assets/Matt&Andre/SignNode.cs
  78. 0
      /MaterialGraphProject/Assets/Matt&Andre/SignNode.cs.meta
  79. 0
      /MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs
  80. 0
      /MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs.meta
  81. 0
      /MaterialGraphProject/Assets/Matt&Andre/StepNode.cs
  82. 0
      /MaterialGraphProject/Assets/Matt&Andre/StepNode.cs.meta
  83. 0
      /MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs
  84. 0
      /MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs.meta
  85. 0
      /MaterialGraphProject/Assets/TestAssets.meta
  86. 0
      /MaterialGraphProject/Assets/TestAssets
  87. 0
      /MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs
  88. 0
      /MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs.meta
  89. 0
      /MaterialGraphProject/Assets/CubemapNode.cs
  90. 0
      /MaterialGraphProject/Assets/CubemapNode.cs.meta

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

16
MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs.meta


fileFormatVersion: 2
guid: ea3f39b56fc9544ff80cbe84aa0753d0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
fileFormatVersion: 2
guid: ea3f39b56fc9544ff80cbe84aa0753d0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

24
MaterialGraphProject/Assets/Matt/Contrast.cs.meta


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

96
MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoHSV")]
public class RGBtoHSVNode : Function1Input, IGeneratesFunction
{
public RGBtoHSVNode ()
{
name = "RGBtoHSV";
}
protected override string GetFunctionName ()
{
return "unity_rgbtohsv_" + precision;
}
protected override MaterialSlot GetInputSlot ()
{
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk (precision + "4 K = " + precision + "4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);", false);
outputString.AddShaderChunk (precision + "4 P = lerp(" + precision + "4(arg1.bg, K.wz), " + precision + "4(arg1.gb, K.xy), step(arg1.b, arg1.g));", false);
outputString.AddShaderChunk (precision + "4 Q = lerp(" + precision + "4(P.xyw, arg1.r), " + precision + "4(arg1.r, P.yzx), step(P.x, arg1.r));", false);
outputString.AddShaderChunk (precision + " D = Q.x - min(Q.w, Q.y);", false);
outputString.AddShaderChunk (precision + " E = 1e-10;", false);
outputString.AddShaderChunk ("return " + precision + "3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoHSV")]
public class RGBtoHSVNode : Function1Input, IGeneratesFunction
{
public RGBtoHSVNode ()
{
name = "RGBtoHSV";
}
protected override string GetFunctionName ()
{
return "unity_rgbtohsv_" + precision;
}
protected override MaterialSlot GetInputSlot ()
{
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk (precision + "4 K = " + precision + "4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);", false);
outputString.AddShaderChunk (precision + "4 P = lerp(" + precision + "4(arg1.bg, K.wz), " + precision + "4(arg1.gb, K.xy), step(arg1.b, arg1.g));", false);
outputString.AddShaderChunk (precision + "4 Q = lerp(" + precision + "4(P.xyw, arg1.r), " + precision + "4(arg1.r, P.yzx), step(P.x, arg1.r));", false);
outputString.AddShaderChunk (precision + " D = Q.x - min(Q.w, Q.y);", false);
outputString.AddShaderChunk (precision + " E = 1e-10;", false);
outputString.AddShaderChunk ("return " + precision + "3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

24
MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs.meta


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

24
MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs.meta


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

34
MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs


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

434
MaterialGraphProject/Assets/TestAssets/Sky1.jpg
文件差异内容过多而无法显示
查看文件

152
MaterialGraphProject/Assets/TestAssets/ColorGuide.tif.meta


fileFormatVersion: 2
guid: 9c50a18d04437449b86568cfcbb668a7
timeCreated: 1490800222
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9c50a18d04437449b86568cfcbb668a7
timeCreated: 1490800222
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

152
MaterialGraphProject/Assets/TestAssets/Gradient.png.meta


fileFormatVersion: 2
guid: 543701356bb512c4cbd1e20cceb22ebb
timeCreated: 1490973774
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 543701356bb512c4cbd1e20cceb22ebb
timeCreated: 1490973774
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

152
MaterialGraphProject/Assets/TestAssets/sfn_vertexcolor.png.meta


fileFormatVersion: 2
guid: ed6958aa821014dc9bc55ee355394931
timeCreated: 1490797376
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ed6958aa821014dc9bc55ee355394931
timeCreated: 1490797376
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

25
MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs


protected const string kOutputSlotGName = "G";
protected const string kOutputSlotBName = "B";
protected const string kOutputSlotAName = "A";
protected const string kOutputSlotRGBASlotName = "Output";
public const int InputSlotId = 0;
public const int OutputSlotRId = 1;

public const int OutputSlotRGBAId = 5;
public ComponentSplitNode()
{

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(OutputSlotRGBAId, kOutputSlotRGBASlotName, kOutputSlotRGBASlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
get { return new[] { InputSlotId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId }; }
get { return new[] { InputSlotId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, OutputSlotRGBAId }; }
}
[SerializeField]

public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector4,
m_Vector4 = m_Value
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector4,
m_Vector4 = m_Value
};
}

public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_Texture = defaultTexture
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_Texture = defaultTexture
};
}

9
MaterialGraphProject/Assets/Matt&Andre.meta


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

9
MaterialGraphProject/Assets/Matt.meta


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

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


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

64
MaterialGraphProject/Assets/Matt/Contrast.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/Contrast")]
public class Contrast : Function3Input, IGeneratesFunction
{
public Contrast()
{
name = "Contrast";
}
protected override string GetFunctionName ()
{
return "unity_contrast_" + precision;
}
protected override MaterialSlot GetInputSlot1 ()
{
return new MaterialSlot (InputSlot1Id, GetInputSlot1Name (), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetInputSlot3()
{
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
protected override string GetInputSlot2Name()
{
return "Contrast";
}
protected override string GetInputSlot3Name()
{
return "Midpoint";
}
// Contrast (reacts better when applied in log)
// Optimal range: [0.0, 2.0]]
// From PostProcessing
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1", "arg2", "arg3"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return (arg1 - arg3) * arg2 + arg3;", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

15
MaterialGraphProject/Assets/Matt/DDX.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/DDX")]
public class DDXNode : Function1Input
{
public DDXNode()
{
name = "DDX";
}
protected override string GetFunctionName() { return "ddx"; }
}
}

12
MaterialGraphProject/Assets/Matt/DDX.cs.meta


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

31
MaterialGraphProject/Assets/Matt/DDXY.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/DDXY")]
public class DDXYNode : Function1Input, IGeneratesFunction
{
public DDXYNode()
{
name = "DDXY";
}
protected override string GetFunctionName()
{
return "unity_ddxy_" + precision;
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("arg1"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return abs(ddx(arg1) + ddy(arg1));", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt/DDXY.cs.meta


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

15
MaterialGraphProject/Assets/Matt/DDY.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/DDY")]
public class DDYNode : Function1Input
{
public DDYNode()
{
name = "DDY";
}
protected override string GetFunctionName() { return "ddy"; }
}
}

12
MaterialGraphProject/Assets/Matt/DDY.cs.meta


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

104
MaterialGraphProject/Assets/Matt/DepthTexture.cs


using System;
using System.Collections.Generic;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Depth Texture")]
public class DepthTextureNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV
{
protected const string kUVSlotName = "UV";
protected const string kOutputSlotName = "Output";
public const int UvSlotId = 0;
public const int OutputSlotId = 1;
public override bool hasPreview { get { return true; } }
public Texture2D defaultTexture { get; set; }
public DepthTextureNode()
{
name = "DepthTexture";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero, false));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { OutputSlotId, UvSlotId }; }
}
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
if (uvSlot == null)
return;
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName());
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.Vector2, true);
}
string body = "tex2D (_CameraDepthTexture, " + uvName + ")";
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + " = " + body + ";", true);
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(GetPreviewProperty());
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk("sampler2D _CameraDepthTexture;", true);
}
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_Texture = defaultTexture
};
}
public override string GetVariableNameForSlot(int slotId)
{
return GetVariableNameForNode();
}
public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public bool RequiresMeshUV(UVChannel channel)
{
if (channel != UVChannel.uv0)
{
return false;
}
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
if (uvSlot == null)
return true;
var edges = owner.GetEdges(uvSlot.slotReference).ToList();
return edges.Count == 0;
}
}
}

44
MaterialGraphProject/Assets/Matt/Desaturate.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Color/Desaturate")]
public class DesaturateNode : Function1Input, IGeneratesFunction
{
public DesaturateNode()
{
name = "Desaturate";
}
protected override string GetFunctionName()
{
return "unity_desaturate_" + precision;
}
protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("arg1"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk(precision+" intensity = "+precision+" (arg1.r * 0.3 + arg1.g * 0.59 + arg1.b * 0.11);", false);
outputString.AddShaderChunk("return " + precision + "3(intensity, intensity, intensity);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt/Desaturate.cs.meta


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

15
MaterialGraphProject/Assets/Matt/Distance.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/Distance")]
public class DistanceNode : Function2Input
{
public DistanceNode()
{
name = "Distance";
}
protected override string GetFunctionName() { return "distance"; }
}
}

12
MaterialGraphProject/Assets/Matt/Distance.cs.meta


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

104
MaterialGraphProject/Assets/Matt/MotionVectorTexture.cs


using System;
using System.Collections.Generic;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Motion Vector Texture")]
public class MotionVectorTextureNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV
{
protected const string kUVSlotName = "UV";
protected const string kOutputSlotName = "Output";
public const int UvSlotId = 0;
public const int OutputSlotId = 1;
public override bool hasPreview { get { return true; } }
public Texture2D defaultTexture { get; set; }
public MotionVectorTextureNode()
{
name = "MotionVectorTexture";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero, false));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { OutputSlotId, UvSlotId }; }
}
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
if (uvSlot == null)
return;
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName());
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.Vector2, true);
}
string body = "tex2D (_CameraMotionVectorTexture, " + uvName + ")";
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + " = " + body + ";", true);
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(GetPreviewProperty());
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk("sampler2D _CameraMotionVectorTexture;", true);
}
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_Texture = defaultTexture
};
}
public override string GetVariableNameForSlot(int slotId)
{
return GetVariableNameForNode();
}
public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public bool RequiresMeshUV(UVChannel channel)
{
if (channel != UVChannel.uv0)
{
return false;
}
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
if (uvSlot == null)
return true;
var edges = owner.GetEdges(uvSlot.slotReference).ToList();
return edges.Count == 0;
}
}
}

12
MaterialGraphProject/Assets/Matt/MotionVectorTexture.cs.meta


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

48
MaterialGraphProject/Assets/Matt/NormalBlend.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Art/Normal Blend")]
public class NormalBlendNode : Function2Input, IGeneratesFunction
{
public NormalBlendNode()
{
name = "Normal Blend";
}
protected override string GetFunctionName()
{
return "unity_normalblend_" + precision;
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return normalize("+precision+"3(arg1.rg + arg2.rg, arg1.b * arg2.b));", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt/NormalBlend.cs.meta


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

42
MaterialGraphProject/Assets/Matt/RGBtoLuminance.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoLuminance")]
public class RGBtoLuminance : Function1Input, IGeneratesFunction
{
public RGBtoLuminance()
{
name = "RGBtoLuminance";
}
protected override string GetFunctionName ()
{
return "unity_rgbtoluminance_" + precision;
}
protected override MaterialSlot GetInputSlot ()
{
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
// Convert rgb to luminance with rgb in linear space with sRGB primaries and D65 white point (from PostProcessing)
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return dot(arg1, "+precision+outputDimension+"(0.2126729, 0.7151522, 0.0721750));", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt/RGBtoLuminance.cs.meta


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

56
MaterialGraphProject/Assets/Matt/Saturation.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/Saturation")]
public class Saturation : Function2Input, IGeneratesFunction
{
public Saturation()
{
name = "Saturation";
}
protected override string GetFunctionName ()
{
return "unity_saturation_" + precision;
}
protected override MaterialSlot GetInputSlot1 ()
{
return new MaterialSlot (InputSlot1Id, GetInputSlot1Name (), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
protected override string GetInputSlot2Name()
{
return "Saturation";
}
// RGB Saturation (closer to a vibrance effect than actual saturation)
// Recommended workspace: ACEScg (linear)
// Optimal range: [0.0, 2.0]
// From PostProcessing
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1", "arg2"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk(precision+" luma = dot(arg1, " + precision + outputDimension + "(0.2126729, 0.7151522, 0.0721750));", false);
outputString.AddShaderChunk ("return luma.xxx + arg2.xxx * (arg1 - luma.xxx);", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}

12
MaterialGraphProject/Assets/Matt/Saturation.cs.meta


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

9
MaterialGraphProject/Assets/NewNodes.meta


fileFormatVersion: 2
guid: 5e38909e3b20f43b28137daed5bd62bf
folderAsset: yes
timeCreated: 1495449911
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/MaterialGraphProject/Assets/NewNodes/Maths/Advance/FmodNode.cs → /MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/Advance/FmodNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/FmodNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/Advance/LogNode.cs → /MaterialGraphProject/Assets/Matt&Andre/LogNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/Advance/LogNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/LogNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/CeilNode.cs → /MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/CeilNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/CeilNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/DepthTexture.cs.meta → /MaterialGraphProject/Assets/Matt/DepthTexture.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/ExponentialNode.cs → /MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/ExponentialNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/ExponentialNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/FloorNode.cs → /MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/FloorNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/FloorNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/FractionNode.cs → /MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/FractionNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/FractionNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/HSVtoRGBNode.cs → /MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/HSVtoRGBNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/HSVtoRGBNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/HueNode.cs → /MaterialGraphProject/Assets/Matt&Andre/HueNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/HueNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/HueNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/InverseLerpNode.cs → /MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/InverseLerpNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/InverseLerpNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/OneMinus.cs → /MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs

/MaterialGraphProject/Assets/NewNodes/Maths/OneMinus.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/OneMinus.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/RGBtoHCVNode.cs.meta → /MaterialGraphProject/Assets/Matt/Contrast.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/RGBtoHSVNode.cs → /MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/RGBtoHSVNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/RGBtoHSVNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/RemapNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/RoundNode.cs → /MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/RoundNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/RoundNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/SignNode.cs → /MaterialGraphProject/Assets/Matt&Andre/SignNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/SignNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/SignNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/SquareRootNode.cs → /MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/SquareRootNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/SquareRootNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/StepNode.cs → /MaterialGraphProject/Assets/Matt&Andre/StepNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/StepNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/StepNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Maths/TruncNode.cs → /MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs

/MaterialGraphProject/Assets/NewNodes/Maths/TruncNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/TruncNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/TestAssets.meta → /MaterialGraphProject/Assets/TestAssets.meta

/MaterialGraphProject/Assets/NewNodes/TestAssets → /MaterialGraphProject/Assets/TestAssets

/MaterialGraphProject/Assets/NewNodes/WIP/ComponentSplitNode.cs → /MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs

/MaterialGraphProject/Assets/NewNodes/WIP/ComponentSplitNode.cs.meta → /MaterialGraphProject/Assets/Matt&Andre/ComponentSplitNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/WIP/CubemapNode.cs → /MaterialGraphProject/Assets/CubemapNode.cs

/MaterialGraphProject/Assets/NewNodes/WIP/CubemapNode.cs.meta → /MaterialGraphProject/Assets/CubemapNode.cs.meta

正在加载...
取消
保存