浏览代码

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

/main
Florent Guinier 8 年前
当前提交
fe87f870
共有 101 个文件被更改,包括 2885 次插入170 次删除
  1. 7
      MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs
  2. 1
      MaterialGraphProject/Assets/Eduardo/ConstantsNode.cs
  3. 2
      MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
  4. 141
      MaterialGraphProject/Assets/GeneratedShader.shader
  5. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs
  6. 4
      MaterialGraphProject/Assets/GraphView/Editor.meta
  7. 2
      MaterialGraphProject/Assets/Matt/EyeMaster.ShaderGraph
  8. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ColorNodePresenter.cs
  9. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GradientNodePresenter.cs
  10. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  11. 49
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Vector1NodePresenter.cs
  12. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
  13. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
  14. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyChunkTests.cs
  15. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  16. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
  17. 54
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs
  18. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
  19. 26
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
  20. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/CheckerboardNode.cs
  21. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs
  22. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs
  23. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SlotValue.cs
  24. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVTileNode.cs
  25. 110
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
  26. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/MetallicMasterNode.cs
  27. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/SpecularMasterNode.cs
  28. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs
  29. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs
  30. 29
      MaterialGraphProject/Assets/_MingWai/GradientNode.cs
  31. 102
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs
  32. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs
  33. 43
      MaterialGraphProject/Assets/Andre/Nodes/Editor/TransformNodePresenter.cs
  34. 12
      MaterialGraphProject/Assets/Andre/Nodes/Editor/TransformNodePresenter.cs.meta
  35. 196
      MaterialGraphProject/Assets/Andre/Nodes/TransformNode.cs
  36. 12
      MaterialGraphProject/Assets/Andre/Nodes/TransformNode.cs.meta
  37. 1
      MaterialGraphProject/Assets/Andre/Shaders/StandardOpaqueShader.ShaderGraph
  38. 9
      MaterialGraphProject/Assets/Andre/Shaders/StandardOpaqueShader.ShaderGraph.meta
  39. 1
      MaterialGraphProject/Assets/Andre/Shaders/TestingGraph.ShaderGraph
  40. 9
      MaterialGraphProject/Assets/Andre/Shaders/TestingGraph.ShaderGraph.meta
  41. 83
      MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat
  42. 9
      MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat.meta
  43. 64
      MaterialGraphProject/Assets/Eduardo/VertexNormalNode.cs
  44. 12
      MaterialGraphProject/Assets/Eduardo/VertexNormalNode.cs.meta
  45. 64
      MaterialGraphProject/Assets/Eduardo/VertexPositionNode.cs
  46. 12
      MaterialGraphProject/Assets/Eduardo/VertexPositionNode.cs.meta
  47. 363
      MaterialGraphProject/Assets/Eduardo/eduardoScene.unity
  48. 8
      MaterialGraphProject/Assets/Eduardo/eduardoScene.unity.meta
  49. 9
      MaterialGraphProject/Assets/Florent.meta
  50. 22
      MaterialGraphProject/Assets/Matt/CommonMatrixType.cs
  51. 12
      MaterialGraphProject/Assets/Matt/CommonMatrixType.cs.meta
  52. 9
      MaterialGraphProject/Assets/Matt/Examples.meta
  53. 1
      MaterialGraphProject/Assets/Matt/Test.ShaderGraph
  54. 9
      MaterialGraphProject/Assets/Matt/Test.ShaderGraph.meta
  55. 40
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix2NodePresenter.cs
  56. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix2NodePresenter.cs.meta
  57. 41
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix3NodePresenter.cs
  58. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix3NodePresenter.cs.meta
  59. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix4NodePresenter.cs
  60. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix4NodePresenter.cs.meta
  61. 51
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs
  62. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs.meta
  63. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs
  64. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs.meta
  65. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters.meta
  66. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix.meta
  67. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix.meta
  68. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/NoiseNode.cs.meta
  69. 60
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs
  70. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs.meta
  71. 55
      MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs
  72. 12
      MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs.meta
  73. 67
      MaterialGraphProject/Assets/_MingWai/RandomRangeNode.cs
  74. 12
      MaterialGraphProject/Assets/_MingWai/RandomRangeNode.cs.meta
  75. 121
      MaterialGraphProject/Assets/_MingWai/ScatterNode.cs
  76. 12
      MaterialGraphProject/Assets/_MingWai/ScatterNode.cs.meta
  77. 9
      MaterialGraphProject/Assets/Florent/GeneratedTexture.meta
  78. 1
      MaterialGraphProject/Assets/Matt/Examples/HueStrip.ShaderGraph
  79. 9
      MaterialGraphProject/Assets/Matt/Examples/HueStrip.ShaderGraph.meta
  80. 1
      MaterialGraphProject/Assets/Matt/Examples/Swirl.ShaderGraph
  81. 9
      MaterialGraphProject/Assets/Matt/Examples/Swirl.ShaderGraph.meta
  82. 103
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs
  83. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs.meta
  84. 103
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs
  85. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs.meta
  86. 103
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix4Node.cs
  87. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix4Node.cs.meta
  88. 68
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs
  89. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs.meta
  90. 123
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs
  91. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs.meta
  92. 12
      MaterialGraphProject/Assets/Brandon/NoiseNode.cs.meta
  93. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/NoiseNode.cs
  94. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs
  95. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs.meta
  96. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs

7
MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs


UpdateNodeAfterDeserialization();
}
/* public override bool hasPreview
{
get { return true; }
}*/
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector2.zero));

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

1
MaterialGraphProject/Assets/Eduardo/ConstantsNode.cs


static Dictionary<ConstantType, float> m_constantList = new Dictionary<ConstantType, float>
{
{ConstantType.PI, 3.1415926f },
{ConstantType.TAU, 6.28318530f},
{ConstantType.PHI, 1.618034f},
{ConstantType.E, 2.718282f},

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

141
MaterialGraphProject/Assets/GeneratedShader.shader


Shader "Hidden/PreviewShader/Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output" {
Properties {
Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform("", Float) = 0.1
Shader "Generated.ExportTextureMasterNode3bf8de92-956b-458c-bbd4-470b91d6bd57"
{
Properties
{
[NonModifiableTextureData] TextureAsset_a266f89a_2f3e_47a6_a8c0_5f05a62b6679_Uniform("TextureAsset", 2D) = "white" {}
SubShader {
// inside SubShader
Tags
{
"Queue"="Geometry"
"RenderType"="Opaque"
"IgnoreProjector"="True"
}
// inside Pass
ZWrite On
SubShader
{
Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Opaque" }
ZWrite Off
Pass {
Pass
{
#pragma vertex vert
#include "UnityCustomRenderTexture.cginc"
#pragma vertex CustomRenderTextureVertexShader_Preview
#include "UnityCG.cginc"
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25_normalDir;
float Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform;
struct v2f
#pragma target 4.0
v2f_customrendertexture CustomRenderTextureVertexShader_Preview(appdata_base IN)
float4 pos : SV_POSITION;
float4 color : COLOR;
float3 worldNormal : TEXCOORD1;
v2f_customrendertexture OUT;
OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.primitiveID = 0;//TODO
OUT.localTexcoord = IN.texcoord;
OUT.globalTexcoord = IN.texcoord;
OUT.direction = CustomRenderTextureComputeCubeDirection(OUT.globalTexcoord.xy);
return OUT;
}
};
sampler2D TextureAsset_a266f89a_2f3e_47a6_a8c0_5f05a62b6679_Uniform;
float4 TextureAsset_a266f89a_2f3e_47a6_a8c0_5f05a62b6679_Uniform_TexelSize;
float4 convolutionFilter0_da4b8ee3_365e_467c_8166_39db9bd7c370;
float4 convolutionFilter1_da4b8ee3_365e_467c_8166_39db9bd7c370;
float4 convolutionFilter2_da4b8ee3_365e_467c_8166_39db9bd7c370;
float4 convolutionFilter3_da4b8ee3_365e_467c_8166_39db9bd7c370;
float4 convolutionFilter4_da4b8ee3_365e_467c_8166_39db9bd7c370;
float4 convolutionFilter5_da4b8ee3_365e_467c_8166_39db9bd7c370;
float4 convolutionFilter6_da4b8ee3_365e_467c_8166_39db9bd7c370;
inline float unity_posterize_float (float input, float stepsize)
inline float4 unity_convolution_float (sampler2D textSampler, float2 baseUv, float4 weights0,float4 weights1,float4 weights2,float4 weights3,float4 weights4,float4 weights5,float4 weights6, float2 texelSize)
return floor(input / stepsize) * stepsize;
fixed4 fetches = fixed4(0,0,0,0);
fixed weight = 1;
weight = weights0.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-2,-2));
weight = weights0.y;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-1,-2));
weight = weights0.z;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(0,-2));
weight = weights0.w;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(1,-2));
weight = weights1.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(2,-2));
weight = weights1.y;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-2,-1));
weight = weights1.z;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-1,-1));
weight = weights1.w;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(0,-1));
weight = weights2.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(1,-1));
weight = weights2.y;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(2,-1));
weight = weights2.z;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-2,0));
weight = weights2.w;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-1,0));
weight = weights3.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(0,0));
weight = weights3.y;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(1,0));
weight = weights3.z;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(2,0));
weight = weights3.w;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-2,1));
weight = weights4.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-1,1));
weight = weights4.y;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(0,1));
weight = weights4.z;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(1,1));
weight = weights4.w;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(2,1));
weight = weights5.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-2,2));
weight = weights5.y;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(-1,2));
weight = weights5.z;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(0,2));
weight = weights5.w;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(1,2));
weight = weights6.x;
fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2(2,2));
fetches /= weights6.w;
return fetches;
v2f vert (appdata_full v)
float4 frag(v2f_customrendertexture IN) : COLOR
v2f o = (v2f)0;
o.pos = UnityObjectToClipPos(v.vertex);;
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
float3 viewDir = UnityWorldSpaceViewDir(worldPos);
float4 screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));
float3 worldNormal = UnityObjectToWorldNormal(v.normal);
o.worldNormal = worldNormal;
return o;
}
half4 frag (v2f IN) : COLOR
{
float3 worldSpaceNormal = normalize(IN.worldNormal);
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25 = ShadeSH9(float4(worldSpaceNormal.xyz , 1));
float4 Split_f630c862_c9a4_4765_b085_f9b01dd46061 = float4(ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25, 1.0);
float Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output = unity_posterize_float (Split_f630c862_c9a4_4765_b085_f9b01dd46061.r, Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform);
return half4(Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output, Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output, Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output, 1.0);
half4 uv0 = float4(IN.localTexcoord.xyz,1.0);
float4 Convolution_da4b8ee3_365e_467c_8166_39db9bd7c370_Output = unity_convolution_float (TextureAsset_a266f89a_2f3e_47a6_a8c0_5f05a62b6679_Uniform, uv0.xy, convolutionFilter0_da4b8ee3_365e_467c_8166_39db9bd7c370, convolutionFilter1_da4b8ee3_365e_467c_8166_39db9bd7c370, convolutionFilter2_da4b8ee3_365e_467c_8166_39db9bd7c370, convolutionFilter3_da4b8ee3_365e_467c_8166_39db9bd7c370, convolutionFilter4_da4b8ee3_365e_467c_8166_39db9bd7c370, convolutionFilter5_da4b8ee3_365e_467c_8166_39db9bd7c370, convolutionFilter6_da4b8ee3_365e_467c_8166_39db9bd7c370, TextureAsset_a266f89a_2f3e_47a6_a8c0_5f05a62b6679_Uniform_TexelSize.xy);
return Convolution_da4b8ee3_365e_467c_8166_39db9bd7c370_Output;
}
ENDCG

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


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

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

4
MaterialGraphProject/Assets/GraphView/Editor.meta


fileFormatVersion: 2
guid: 9635695807dafd94992e8eb6a9346b63
guid: 7a91bd168256a4fecb2d532dc2f38d8a
timeCreated: 1485805545
timeCreated: 1495668355
licenseType: Pro
DefaultImporter:
userData:

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

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


using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{

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

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


Event e = Event.current;
if (prevWindow != EditorWindow.focusedWindow.ToString() && EditorWindow.focusedWindow.ToString() != "(UnityEditor.GradientPicker)")
if (EditorWindow.focusedWindow != null && prevWindow != EditorWindow.focusedWindow.ToString() && EditorWindow.focusedWindow.ToString() != "(UnityEditor.GradientPicker)")
{
cNode.UpdateGradient();
prevWindow = EditorWindow.focusedWindow.ToString();

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


using UnityEditor.Graphing.Drawing;
using UnityEngine.MaterialGraph;
using System.Collections.Generic;
using System.Linq;
using RMGUI.GraphView;
namespace UnityEditor.MaterialGraph.Drawing
{

typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter);
typeMapper[typeof(ColorNode)] = typeof(ColorNodePresenter);
typeMapper[typeof(GradientNode)] = typeof(GradientNodePresenter);
typeMapper[typeof(ScatterNode)] = typeof(ScatterNodePresenter);
typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
typeMapper[typeof(TextureAssetNode)] = typeof(TextureAssetNodePresenter);
typeMapper[typeof(TextureLODNode)] = typeof(TextureLODNodePresenter);

typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
typeMapper[typeof(IfNode)] = typeof(IfNodePresenter);
typeMapper[typeof(CustomCodeNode)] = typeof(CustomCodePresenter);
typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodePresenter);
typeMapper[typeof(Matrix3Node)] = typeof(Matrix3NodePresenter);
typeMapper[typeof(Matrix4Node)] = typeof(Matrix4NodePresenter);
typeMapper[typeof(MatrixCommonNode)] = typeof(MatrixCommonNodePresenter);
typeMapper[typeof(TransformNode)] = typeof(TransformNodePresenter);
}
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)
{
return allChildren.OfType<NodeAnchorPresenter>()
.Where(nap => nap.IsConnectable() &&
nap.orientation == startAnchor.orientation &&
nap.direction != startAnchor.direction &&
nodeAdapter.GetAdapter(nap.source, startAnchor.source) != null &&
(startAnchor is GraphAnchorPresenter && ((GraphAnchorPresenter)nap).slot is MaterialSlot &&
((MaterialSlot)((GraphAnchorPresenter)startAnchor).slot).IsCompatibleWithInputSlotType(((MaterialSlot)((GraphAnchorPresenter)nap).slot).valueType)))
.ToList();
}
}
}

49
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Vector1NodePresenter.cs


using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine.MaterialGraph;
using UnityEngine;
public override void OnGUIHandler()
{
base.OnGUIHandler();

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

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


Shader "Graph/UnityEngine.MaterialGraph.MetallicMasterNode0dd415f6-2593-4617-b37c-c9d9dd315a4c"
Shader "Graph/UnityEngine.MaterialGraph.MetallicMasterNode68c240e8-1bfd-46d4-86b7-3459bc630675"
Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform("", Float) = 0.1
}

#pragma glsl
#pragma debug
inline float unity_posterize_float (float input, float stepsize)
{
return floor(input / stepsize) * stepsize;
}
float Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform;
float3 worldNormal;
};

void surf (Input IN, inout SurfaceOutputStandard o)
{
float3 worldSpaceNormal = normalize(IN.worldNormal);
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25 = ShadeSH9(float4(worldSpaceNormal.xyz , 1));
float4 Split_f630c862_c9a4_4765_b085_f9b01dd46061 = float4(ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25, 1.0);
float Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output = unity_posterize_float (Split_f630c862_c9a4_4765_b085_f9b01dd46061.r, Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform);
float Posterize_3187d243_6c53_430c_9d5e_fa7a1561872c_Output = unity_posterize_float (Split_f630c862_c9a4_4765_b085_f9b01dd46061.g, Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform);
float Posterize_c83cc006_d2b4_4a06_8f45_52c85f6e2a73_Output = unity_posterize_float (Split_f630c862_c9a4_4765_b085_f9b01dd46061.b, Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform);
float4 Combine_2e6d43a4_be04_453e_a0f2_a0520f41fea5_Output = float4(Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output,Posterize_3187d243_6c53_430c_9d5e_fa7a1561872c_Output,Posterize_c83cc006_d2b4_4a06_8f45_52c85f6e2a73_Output,0.0);
o.Emission = Combine_2e6d43a4_be04_453e_a0f2_a0520f41fea5_Output;
}
ENDCG

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


fileFormatVersion: 2
guid: 9ab5e16c2083a4fe689209a8c1ae425e
timeCreated: 1495643268
timeCreated: 1495720140
licenseType: Pro
ShaderImporter:
defaultTextures: []

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


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

18
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs


return ConcreteSlotValueType.Vector4;
case SlotValueType.sampler2D:
return ConcreteSlotValueType.sampler2D;
case SlotValueType.Matrix2:
return ConcreteSlotValueType.Matrix2;
case SlotValueType.Matrix3:
return ConcreteSlotValueType.Matrix3;
case SlotValueType.Matrix4:
return ConcreteSlotValueType.Matrix4;
}
return ConcreteSlotValueType.Error;
}

return "4";
case ConcreteSlotValueType.sampler2D:
return "sampler2D";
case ConcreteSlotValueType.Matrix2:
return "2x2";
case ConcreteSlotValueType.Matrix3:
return "3x3";
case ConcreteSlotValueType.Matrix4:
return "4x4";
default:
return "Error";
}

return PropertyType.Vector3;
case ConcreteSlotValueType.Vector4:
return PropertyType.Vector4;
case ConcreteSlotValueType.Matrix2:
return PropertyType.Matrix2;
case ConcreteSlotValueType.Matrix3:
return PropertyType.Matrix3;
case ConcreteSlotValueType.Matrix4:
return PropertyType.Matrix4;
default:
return PropertyType.Vector4;
}

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


[Title("Input/Color")]
public class ColorNode : PropertyNode, IGeneratesBodyCode
{
[SerializeField]
[SerializeField]
private bool m_HDR;
[SerializeField]
public bool HDR
{
get { return m_HDR; }
set
{
if (m_HDR == value)
return;
m_HDR = value;
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
}
}
public ColorNode()
{

public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new ColorPropertyChunk(propertyName, description, color, PropertyChunk.HideState.Visible));
visitor.AddShaderProperty(new ColorPropertyChunk(propertyName, description, color, m_HDR ? ColorPropertyChunk.ColorType.HDR : ColorPropertyChunk.ColorType.Default , PropertyChunk.HideState.Visible));
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

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


[SerializeField]
private float m_Value;
[SerializeField]
private FloatPropertyChunk.FloatType m_floatType;
[SerializeField]
private Vector3 m_rangeValues = new Vector3(0f, 1f, 2f);
public const int OutputSlotId = 0;
private const string kOutputSlotName = "Value";

}
}
public FloatPropertyChunk.FloatType floatType
{
get { return m_floatType; }
set
{
if (m_floatType == value)
return;
m_floatType = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public Vector3 rangeValues
{
get { return m_rangeValues; }
set
{
if (m_rangeValues == value)
return;
m_rangeValues = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible));
if (exposedState == ExposedState.Exposed) {
switch(m_floatType){
case FloatPropertyChunk.FloatType.Float:
visitor.AddShaderProperty (new FloatPropertyChunk (propertyName, description, m_Value, PropertyChunk.HideState.Visible));
break;
case FloatPropertyChunk.FloatType.Toggle:
visitor.AddShaderProperty (new FloatPropertyChunk (propertyName, description, m_Value, m_floatType, PropertyChunk.HideState.Visible));
break;
case FloatPropertyChunk.FloatType.Range:
visitor.AddShaderProperty (new FloatPropertyChunk (propertyName, description, m_Value, m_floatType, m_rangeValues, PropertyChunk.HideState.Visible));
break;
case FloatPropertyChunk.FloatType.PowerSlider:
visitor.AddShaderProperty (new FloatPropertyChunk (propertyName, description, m_Value, m_floatType, m_rangeValues, PropertyChunk.HideState.Visible));
break;
}
}
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

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


if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
return;
visitor.AddShaderChunk(precision + "2 " + propertyName + " = " + precision + "2 (" + m_Value.x + ", " + m_Value.y + ");", true);
visitor.AddShaderChunk(precision + "2x2 " + propertyName + " = " + precision + "2 " + propertyName + " = " + precision + "2 (" + m_Value.x + ", " + m_Value.y + ");", true);
}
public override PreviewProperty GetPreviewProperty()

26
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs


return "(3)";
case ConcreteSlotValueType.Vector4:
return "(4)";
case ConcreteSlotValueType.Matrix2:
return "(2x2)";
case ConcreteSlotValueType.Matrix3:
return "(3x3)";
case ConcreteSlotValueType.Matrix4:
return "(4x4)";
default:
return "(E)";
}

case SlotValueType.Vector3:
concreteValueType = ConcreteSlotValueType.Vector3;
break;
case SlotValueType.Matrix2:
concreteValueType = ConcreteSlotValueType.Matrix2;
break;
case SlotValueType.Matrix3:
concreteValueType = ConcreteSlotValueType.Matrix3;
break;
case SlotValueType.Matrix4:
concreteValueType = ConcreteSlotValueType.Matrix4;
break;
default:
concreteValueType = ConcreteSlotValueType.Vector4;
break;

visitor.AddShaderChunk(matOwner.precision + AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(concreteValueType) + " " + matOwner.GetVariableNameForSlot(id) + ";", true);
}
public bool IsCompatibleWithInputSlotType(SlotValueType inputType)
{
return (inputType == SlotValueType.Dynamic || valueType == SlotValueType.Vector1 || valueType <= inputType);
}
public string GetDefaultValue(GenerationMode generationMode)
{
var matOwner = owner as AbstractMaterialNode;

return matOwner.precision + "3 (" + m_CurrentValue.x + "," + m_CurrentValue.y + "," + m_CurrentValue.z + ")";
case ConcreteSlotValueType.Vector4:
return matOwner.precision + "4 (" + m_CurrentValue.x + "," + m_CurrentValue.y + "," + m_CurrentValue.z + "," + m_CurrentValue.w + ")";
case ConcreteSlotValueType.Matrix2:
return matOwner.precision + "2x2 (" + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.y + ", "+ m_CurrentValue.y + ")";
case ConcreteSlotValueType.Matrix3:
return matOwner.precision + "3x3 (" + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ")";
case ConcreteSlotValueType.Matrix4:
return matOwner.precision + "4x4 (" + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.x + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.y + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.z + ", " + m_CurrentValue.w + ", " + m_CurrentValue.w + ", " + m_CurrentValue.w + ", " + m_CurrentValue.w + ")";
default:
return "error";
}

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


protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, new Vector4(10,0,0,0));
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, new Vector4(10, 0, 0, 0));
}
protected override MaterialSlot GetOutputSlot()
{

42
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Voronoi Noise")]
public class VoronoiNoiseNode : Function2Input, IGeneratesFunction
public class VoronoiNoiseNode : FunctionNInNOut, IGeneratesFunction
AddSlot("UV", "uv", Graphing.SlotType.Input, SlotValueType.Vector2, Vector4.zero);
AddSlot("AngleOffset", "angleOffset", Graphing.SlotType.Input, SlotValueType.Vector1, new Vector4(2.0f,0,0,0));
AddSlot("Cellular", "n1", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("Tile", "n2", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("1 - Cellular", "n3", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
}
protected override string GetFunctionName()

protected override string GetInputSlot1Name()
{
return "UV";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override string GetInputSlot2Name()
{
return "AngleOffset";
}
protected override MaterialSlot GetInputSlot2()
public override bool hasPreview
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector2.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
get
{
return true;
}
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)

outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk(GetFunctionPrototype("uv", "angleOffset"), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();

outputString.AddShaderChunk("float3 res = float3(8.0, 0.0, 0.0);", false);
outputString.AddShaderChunk("for(int y=-1; y<=1; y++)", false);
outputString.AddShaderChunk("{", false);

outputString.Indent();
outputString.AddShaderChunk("res = float3(d, offset.x, offset.y);", false);
outputString.AddShaderChunk("n1 = res.x;", false);
outputString.AddShaderChunk("n2 = res.y;", false);
outputString.AddShaderChunk("n3 = 1.0 - res.x;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);

outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("return res.x;", false);
outputString.Deindent();

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


Float,
Vector2,
Vector3,
Vector4
Vector4,
Matrix2,
Matrix3,
Matrix4
}
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SlotValue.cs


[Serializable]
public enum SlotValueType
{
Matrix4,
Matrix3,
Matrix2,
sampler2D,
Dynamic,
Vector4,

public enum ConcreteSlotValueType
{
Matrix4 = 8,
Matrix3 = 7,
Matrix2 = 6,
sampler2D = 5,
Vector4 = 4,
Vector3 = 3,

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


protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, new Vector2(2,2));
}
protected override MaterialSlot GetOutputSlot()

110
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs


public const string SmoothnessSlotName = "Smoothness";
public const string OcclusionSlotName = "Occlusion";
public const string AlphaSlotName = "Alpha";
public const string VertexOffsetName = "VertexPosition";
public const int AlbedoSlotId = 0;
public const int NormalSlotId = 1;

public const int AlphaSlotId = 6;
public const int VertexOffsetId = 7;
[SerializeField]
private SurfaceMaterialOptions m_MaterialOptions = new SurfaceMaterialOptions();

public abstract string GetSurfaceOutputName();
public abstract string GetLightFunction();
void GenerateNodeFunctionsAndPropertyUsages(
ShaderGenerator shaderBody,
ShaderGenerator propertyUsages,
ShaderGenerator nodeFunction,
GenerationMode mode,
int[] validNodeIds)
{
var activeNodeList = new List<INode>();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, this, NodeUtils.IncludeSelf.Include,
new List<int>(validNodeIds));
foreach (var node in activeNodeList.OfType<AbstractMaterialNode>())
{
if (node is IGeneratesFunction)
(node as IGeneratesFunction).GenerateNodeFunction(nodeFunction, mode);
node.GeneratePropertyUsages(propertyUsages, mode);
}
var nodes = ListPool<INode>.Get();
//Get the rest of the nodes for all the other slots
NodeUtils.DepthFirstCollectNodesFromNode(nodes, this, NodeUtils.IncludeSelf.Exclude, new List<int>(vertexInputs));
for (var i = 0; i < nodes.Count; i++)
{
var node = nodes[i];
if (node is IGeneratesBodyCode)
(node as IGeneratesBodyCode).GenerateNodeCode(shaderBody, mode);
}
ListPool<INode>.Release(nodes);
}
void GenerateVertexShaderInternal(
ShaderGenerator propertyUsages,
ShaderGenerator shaderBody,
ShaderGenerator nodeFunction,
ShaderGenerator vertexShaderBlock,
GenerationMode mode)
{
GenerateNodeFunctionsAndPropertyUsages(vertexShaderBlock, propertyUsages, nodeFunction, mode, vertexInputs);
var slot = FindInputSlot<MaterialSlot>(VertexOffsetId);
foreach (var edge in owner.GetEdges(slot.slotReference))
{
var outputRef = edge.outputSlot;
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
if (fromNode == null)
continue;
var remapper = fromNode as INodeGroupRemapper;
if (remapper != null && !remapper.IsValidSlotConnection(outputRef.slotId))
continue;
vertexShaderBlock.AddShaderChunk("v.vertex.xyz = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
}
}
public override string GetSubShader(GenerationMode mode, PropertyGenerator shaderPropertiesVisitor)
{
var templateLocation = ShaderGenerator.GetTemplatePath("subshader.template");

shaderBodyVisitor,
shaderFunctionVisitor,
shaderInputVisitor,
vertexShaderBlock,
mode);
GenerateVertexShaderInternal(
shaderPropertyUsagesVisitor,
shaderBodyVisitor,
shaderFunctionVisitor,
vertexShaderBlock,
mode);

return Regex.Replace(resultShader, @"\r\n|\n\r|\n|\r", Environment.NewLine);
}
protected abstract int[] surfaceInputs
{
get;
}
protected abstract int[] vertexInputs
{
get;
}
private void GenerateSurfaceShaderInternal(
ShaderGenerator propertyUsages,
ShaderGenerator shaderBody,

GenerationMode mode)
{
var activeNodeList = new List<INode>();
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, this);
NodeUtils.DepthFirstCollectNodesFromNode(activeNodeList, this, NodeUtils.IncludeSelf.Include,
new List<int>(surfaceInputs));
foreach (var node in activeNodeList.OfType<AbstractMaterialNode>())
{

var nodes = ListPool<INode>.Get();
//Get the rest of the nodes for all the other slots
NodeUtils.DepthFirstCollectNodesFromNode(nodes, this, NodeUtils.IncludeSelf.Exclude);
NodeUtils.DepthFirstCollectNodesFromNode(nodes, this, NodeUtils.IncludeSelf.Exclude, new List<int>(surfaceInputs));
for (var i = 0; i < nodes.Count; i++)
{
var node = nodes[i];

foreach (var slot in GetInputSlots<MaterialSlot>())
{
foreach (var edge in owner.GetEdges(slot.slotReference))
if (surfaceInputs.Contains(slot.id))
var outputRef = edge.outputSlot;
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
if (fromNode == null)
continue;
foreach (var edge in owner.GetEdges(slot.slotReference))
{
var outputRef = edge.outputSlot;
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
if (fromNode == null)
continue;
var remapper = fromNode as INodeGroupRemapper;
if (remapper != null && !remapper.IsValidSlotConnection(outputRef.slotId))
continue;
var remapper = fromNode as INodeGroupRemapper;
if (remapper != null && !remapper.IsValidSlotConnection(outputRef.slotId))
continue;
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
}
}
}
}

35
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/MetallicMasterNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(VertexOffsetId, VertexOffsetName, VertexOffsetName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));

MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId
AlphaSlotId,
VertexOffsetId
protected override int[] surfaceInputs
{
get
{
return new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
};
}
}
protected override int[] vertexInputs
{
get
{
return new[]
{
VertexOffsetId
};
}
}
public override string GetSurfaceOutputName()
{
return SurfaceOutputStructureName;

30
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/SpecularMasterNode.cs


UpdateNodeAfterDeserialization();
}
protected override int[] surfaceInputs
{
get
{
return new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
SpecularSlotId
};
}
}
protected override int[] vertexInputs
{
get
{
return new[]
{
VertexOffsetId
};
}
}
AddSlot(new MaterialSlot(VertexOffsetId, VertexOffsetName, VertexOffsetName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs


{
public class ColorPropertyChunk : PropertyChunk
{
public enum ColorType
{
Default,
HDR
}
private ColorType m_colorType;
public ColorPropertyChunk(string propertyName, string propertyDescription, Color defaultColor, HideState hideState)
public ColorPropertyChunk(string propertyName, string propertyDescription, Color defaultColor, ColorType colorType, HideState hideState)
m_colorType = colorType;
m_DefaultColor = defaultColor;
}

public override string GetPropertyString()
{
var result = new StringBuilder();
if(m_colorType == ColorType.HDR)
result.Append ("[HDR]");
result.Append(propertyName);
result.Append("(\"");
result.Append(propertyDescription);

39
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs


{
public class FloatPropertyChunk : PropertyChunk
{
public enum FloatType
{
Float,
Toggle,
Range,
PowerSlider
}
private readonly FloatType m_FloatType;
private readonly Vector3 m_rangeValues;
public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, HideState hideState)
: base(propertyName, propertyDescription, hideState)
{

public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, FloatType floatType, HideState hideState)
: base(propertyName, propertyDescription, hideState)
{
m_FloatType = floatType;
m_DefaultValue = defaultValue;
}
public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, FloatType floatType, Vector3 rangeValues, HideState hideState)
: base(propertyName, propertyDescription, hideState)
{
m_FloatType = floatType;
m_rangeValues = rangeValues;
m_DefaultValue = defaultValue;
}
public float defaultValue
{
get { return m_DefaultValue; }

{
var result = new StringBuilder();
if (m_FloatType == FloatType.Toggle)
result.Append ("[Toggle]");
else if(m_FloatType == FloatType.PowerSlider)
result.Append ("[PowerSlider(" + m_rangeValues.z + ")]");
result.Append("\", Float) = ");
if (m_FloatType == FloatType.Float || m_FloatType == FloatType.Toggle) {
result.Append ("\", Float) = ");
}else if(m_FloatType == FloatType.Range || m_FloatType == FloatType.PowerSlider){
result.Append ("\", Range(");
result.Append (m_rangeValues.x + ", " + m_rangeValues.y);
result.Append (")) = ");
}
result.Append(defaultValue);
return result.ToString();
}

29
MaterialGraphProject/Assets/_MingWai/GradientNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Gradient Editor")]
public class GradientNode : Function1Input, IGeneratesFunction
public class GradientNode : FunctionNInNOut, IGeneratesFunction
{
[SerializeField]
private Gradient m_gradient;

public GradientNode()
{
name = "Gradient";
AddSlot("Value", "v", Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.one);
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
AddSlot("R", "finalR", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("G", "finalG", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("B", "finalB", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("A", "finalA", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
UpdateNodeAfterDeserialization();
}

}
protected override string GetInputSlotName()
public override bool hasPreview
return "Value";
get { return true; }
protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector2.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector4, Vector2.zero);
}
private void GNF(ShaderGenerator visitor, GenerationMode generationMode)
{

//Start
outputString.AddShaderChunk(GetFunctionPrototype("v"), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();

//Result
outputString.AddShaderChunk("return float4(gradcolor,gradalpha);", false);
outputString.AddShaderChunk("finalColor = float4(gradcolor,gradalpha);", false);
outputString.AddShaderChunk("finalR = finalColor.r;", false);
outputString.AddShaderChunk("finalG = finalColor.g;", false);
outputString.AddShaderChunk("finalB = finalColor.b;", false);
outputString.AddShaderChunk("finalA = finalColor.a;", false);
//End

102
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs


using UnityEngine.Graphing;
[Title("Matrix/Multiply Node")]
public class MatrixMultiplyNode : Function2Input, IGeneratesFunction
[Title("Math/Matrix/MultiplyMatrix")]
public class MatrixMultiplyNode : AbstractMaterialNode, IGeneratesBodyCode, 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;
public override bool hasPreview
{
get { return false; }
}
name = "MatrixMultiplyNode";
name = "MultiplyMatrix";
UpdateNodeAfterDeserialization();
protected override string GetFunctionName()
protected string GetFunctionName()
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputSlot1());
AddSlot(GetInputSlot2());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { InputSlot1Id, InputSlot2Id, OutputSlotId }; }
}
protected MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
}
protected MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
}
protected MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero);
}
protected virtual string GetInputSlot1Name()
{
return "Input1";
}
protected virtual string GetInputSlot2Name()
{
return "Input2";
}
protected string GetOutputSlotName()
{
return "Output";
}
protected 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 string GetFunctionCallBody(string input1Value, string input2Value)
{
return GetFunctionName() + " (" + input1Value + ", " + input2Value + ")";
}
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}
private string input1Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot1Id).concreteValueType); }
}
private string input2Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)

21
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs


using UnityEngine.Graphing;
[Title("Matrix/Transpose Node")]
[Title("Math/Matrix/TransposeMatrix")]
name = "MatrixTranspose";
name = "TransposeMatrix";
}
public override bool hasPreview
{
get { return false; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)

outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero);
}
}
}

43
MaterialGraphProject/Assets/Andre/Nodes/Editor/TransformNodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine.MaterialGraph;
using UnityEngine;
namespace UnityEditor.MaterialGraph.Drawing
{
class TransformControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as TransformNode;
if (tNode == null)
return;
//EditorGUILayout.BeginHorizontal ();
tNode.spaceFrom = (SimpleMatrixType)EditorGUILayout.EnumPopup ("From", tNode.spaceFrom);
tNode.spaceTo = (SimpleMatrixType)EditorGUILayout.EnumPopup ("To", tNode.spaceTo);
//EditorGUILayout.BeginHorizontal ();
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class TransformNodePresenter : PropertyNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<TransformControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter>(base.GetControlData()) { instance };
}
}
}

12
MaterialGraphProject/Assets/Andre/Nodes/Editor/TransformNodePresenter.cs.meta


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

196
MaterialGraphProject/Assets/Andre/Nodes/TransformNode.cs


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

12
MaterialGraphProject/Assets/Andre/Nodes/TransformNode.cs.meta


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

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

9
MaterialGraphProject/Assets/Andre/Shaders/StandardOpaqueShader.ShaderGraph.meta


fileFormatVersion: 2
guid: 6e097b4224bbd407cb33de4f4b78ff0c
timeCreated: 1495651266
licenseType: Pro
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

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

9
MaterialGraphProject/Assets/Andre/Shaders/TestingGraph.ShaderGraph.meta


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

83
MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: EduardoTestMat
m_Shader: {fileID: 4800000, guid: 9ab5e16c2083a4fe689209a8c1ae425e, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- Texture_8fd49eff_ec05_41e3_9bc1_5bdfc20db019_Uniform:
m_Texture: {fileID: 2800000, guid: 6ff1e57e8df9d2948bb6d703d02af730, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_ec519094_93da_4612_af61_2f8bcdc6589e_Uniform:
m_Texture: {fileID: 2800000, guid: 6ff1e57e8df9d2948bb6d703d02af730, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

9
MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat.meta


fileFormatVersion: 2
guid: 51689361644e44b41aa59664b34a6e45
timeCreated: 1495654926
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

64
MaterialGraphProject/Assets/Eduardo/VertexNormalNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Geometry/Vertex Normal")]
public class VertexNormalNode : AbstractMaterialNode
{
private const string kOutputSlotName = "XYZW";
private const string kOutputSlotNameXYZ = "XYZ";
private const string kOutputSlotNameX = "X";
private const string kOutputSlotNameY = "Y";
private const string kOutputSlotNameZ = "Z";
private const string kOutputSlotNameW = "W";
public const int OutputSlotId = 0;
public const int OutputSlotIdXYZ = 1;
public const int OutputSlotIdX = 2;
public const int OutputSlotIdY = 3;
public const int OutputSlotIdZ = 4;
public const int OutputSlotIdW = 5;
public VertexNormalNode()
{
name = "VertexNormal";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdXYZ, kOutputSlotNameXYZ, kOutputSlotNameXYZ, SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdX, kOutputSlotNameX, kOutputSlotNameX, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { OutputSlotId, OutputSlotIdXYZ, OutputSlotIdX, OutputSlotIdY, OutputSlotIdZ, OutputSlotIdW }; }
}
public override string GetVariableNameForSlot(int slotId)
{
switch (slotId)
{
case OutputSlotIdXYZ:
return "v.normal.xyz";
case OutputSlotIdX:
return "v.normal.x";
case OutputSlotIdY:
return "v.normal.y";
case OutputSlotIdZ:
return "v.normal.z";
case OutputSlotIdW:
return "v.normal.w";
default:
return "v.normal";
}
}
}
}

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


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

64
MaterialGraphProject/Assets/Eduardo/VertexPositionNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Geometry/Vertex Position")]
public class VertexPositionNode : AbstractMaterialNode
{
private const string kOutputSlotName = "XYZW";
private const string kOutputSlotNameXYZ = "XYZ";
private const string kOutputSlotNameX = "X";
private const string kOutputSlotNameY = "Y";
private const string kOutputSlotNameZ = "Z";
private const string kOutputSlotNameW = "W";
public const int OutputSlotId = 0;
public const int OutputSlotIdXYZ = 1;
public const int OutputSlotIdX = 2;
public const int OutputSlotIdY = 3;
public const int OutputSlotIdZ = 4;
public const int OutputSlotIdW = 5;
public VertexPositionNode()
{
name = "VertexPostion";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdXYZ, kOutputSlotNameXYZ, kOutputSlotNameXYZ, SlotType.Output, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdX, kOutputSlotNameX, kOutputSlotNameX, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdY, kOutputSlotNameY, kOutputSlotNameY, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdZ, kOutputSlotNameZ, kOutputSlotNameZ, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotIdW, kOutputSlotNameW, kOutputSlotNameW, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { OutputSlotId, OutputSlotIdXYZ ,OutputSlotIdX, OutputSlotIdY, OutputSlotIdZ, OutputSlotIdW }; }
}
public override string GetVariableNameForSlot(int slotId)
{
switch (slotId)
{
case OutputSlotIdXYZ:
return "v.vertex.xyz";
case OutputSlotIdX:
return "v.vertex.x";
case OutputSlotIdY:
return "v.vertex.y";
case OutputSlotIdZ:
return "v.vertex.z";
case OutputSlotIdW:
return "v.vertex.w";
default:
return "v.vertex";
}
}
}
}

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


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

363
MaterialGraphProject/Assets/Eduardo/eduardoScene.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.18028316, g: 0.22571331, b: 0.306922, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 9
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &165786477
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 165786481}
- component: {fileID: 165786480}
- component: {fileID: 165786479}
- component: {fileID: 165786478}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &165786478
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 165786477}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 51689361644e44b41aa59664b34a6e45, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!65 &165786479
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 165786477}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &165786480
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 165786477}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &165786481
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 165786477}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &545929005
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 545929010}
- component: {fileID: 545929009}
- component: {fileID: 545929008}
- component: {fileID: 545929007}
- component: {fileID: 545929006}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &545929006
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545929005}
m_Enabled: 1
--- !u!124 &545929007
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545929005}
m_Enabled: 1
--- !u!92 &545929008
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545929005}
m_Enabled: 1
--- !u!20 &545929009
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545929005}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &545929010
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545929005}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1301173965
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1301173967}
- component: {fileID: 1301173966}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1301173966
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1301173965}
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_FalloffTable:
m_Table[0]: 0
m_Table[1]: 0
m_Table[2]: 0
m_Table[3]: 0
m_Table[4]: 0
m_Table[5]: 0
m_Table[6]: 0
m_Table[7]: 0
m_Table[8]: 0
m_Table[9]: 0
m_Table[10]: 0
m_Table[11]: 0
m_Table[12]: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1301173967
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1301173965}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}

8
MaterialGraphProject/Assets/Eduardo/eduardoScene.unity.meta


fileFormatVersion: 2
guid: 418471c069e40784489ba3ba9d0bb95b
timeCreated: 1495655530
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Florent.meta


fileFormatVersion: 2
guid: e9dab59e587c7f244adde1add29b34fc
folderAsset: yes
timeCreated: 1495531757
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

22
MaterialGraphProject/Assets/Matt/CommonMatrixType.cs


namespace UnityEngine.MaterialGraph
{
public enum CommonMatrixType
{
ModelView,
View,
Projection,
ViewProjection,
TransposeModelView,
InverseTransposeModelView,
ObjectToWorld,
WorldToObject
};
public enum SimpleMatrixType
{
World,
Local,
Tangent,
View
};
}

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


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

9
MaterialGraphProject/Assets/Matt/Examples.meta


fileFormatVersion: 2
guid: 6a5311f2c2db6e34f8da2333309aab50
folderAsset: yes
timeCreated: 1495713891
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

9
MaterialGraphProject/Assets/Matt/Test.ShaderGraph.meta


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

40
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix2NodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
class Matrix2ControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as UnityEngine.MaterialGraph.Matrix2Node;
if (tNode == null)
return;
tNode[0] = EditorGUILayout.Vector2Field("", tNode[0]);
tNode[1] = EditorGUILayout.Vector2Field("", tNode[1]);
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class Matrix2NodePresenter : PropertyNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<Matrix2ControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter>(base.GetControlData()) { instance };
}
}
}

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


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

41
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix3NodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
class Matrix3ControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as UnityEngine.MaterialGraph.Matrix3Node;
if (tNode == null)
return;
tNode[0] = EditorGUILayout.Vector3Field("", tNode[0]);
tNode[1] = EditorGUILayout.Vector3Field("", tNode[1]);
tNode[2] = EditorGUILayout.Vector3Field("", tNode[2]);
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class Matrix3NodePresenter : PropertyNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<Matrix3ControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter>(base.GetControlData()) { instance };
}
}
}

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


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

42
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix4NodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
class Matrix4ControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as UnityEngine.MaterialGraph.Matrix4Node;
if (tNode == null)
return;
tNode[0] = EditorGUILayout.Vector4Field("", tNode[0]);
tNode[1] = EditorGUILayout.Vector4Field("", tNode[1]);
tNode[2] = EditorGUILayout.Vector4Field("", tNode[2]);
tNode[3] = EditorGUILayout.Vector4Field("", tNode[3]);
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight * 4 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class Matrix4NodePresenter : PropertyNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<Matrix4ControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter>(base.GetControlData()) { instance };
}
}
}

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


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

51
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class MatrixCommonContolPresenter : GraphControlPresenter
{
private string[] m_MatrixTypeNames;
private string[] matrixTypeNames
{
get
{
if (m_MatrixTypeNames == null)
m_MatrixTypeNames = Enum.GetNames(typeof(CommonMatrixType));
return m_MatrixTypeNames;
}
}
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as UnityEngine.MaterialGraph.MatrixCommonNode;
if (cNode == null)
return;
cNode.matrix = (CommonMatrixType)EditorGUILayout.Popup((int)cNode.matrix, matrixTypeNames, EditorStyles.popup);
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class MatrixCommonNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<MatrixCommonContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

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


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

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs


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

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


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

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


fileFormatVersion: 2
guid: 7ed888a282fe7b54e968311cd68c4862
folderAsset: yes
timeCreated: 1495638073
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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


fileFormatVersion: 2
guid: 278936628273864438e48ff64aa20e32
folderAsset: yes
timeCreated: 1495662409
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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


fileFormatVersion: 2
guid: bfc8dbcaa9711c945b8fd983b819335d
folderAsset: yes
timeCreated: 1495700996
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/NoiseNode.cs.meta


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

60
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("UV/Twist")]
public class TwistNode : Function2Input, IGeneratesFunction
{
public TwistNode()
{
name = "Twist";
}
protected override string GetFunctionName()
{
return "unity_twist_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override string GetInputSlot2Name()
{
return "Twist";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector1, Vector2.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "twist"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float angle = twist * length(uv);", false);
outputString.AddShaderChunk("float x = cos(angle) * uv.x - sin(angle) * uv.y;", false);
outputString.AddShaderChunk("float y = sin(angle) * uv.x + cos(angle) * uv.y;", false);
outputString.AddShaderChunk("return float2(x, y);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs.meta


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

55
MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Art/Adjustments/ColorBalance")]
public class ColorBalanceNode : FunctionNInNOut, IGeneratesFunction
{
public ColorBalanceNode()
{
name = "ColorBalance";
AddSlot("Color", "inputColor", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.one);
AddSlot("AdjustRGB", "adjustRGB", Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.zero);
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
protected override string GetFunctionName()
{
return "unity_colorbalance_" + precision;
}
public override bool hasPreview
{
get { return true; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float red = 0;", false);
outputString.AddShaderChunk("float green = 0;", false);
outputString.AddShaderChunk("float blue = 0;", false);
outputString.AddShaderChunk("red = 1.00f / (1-adjustRGB.r) * inputColor.r;", false);
outputString.AddShaderChunk("green = 1.00f / (1-adjustRGB.g) * inputColor.g;", false);
outputString.AddShaderChunk("blue = 1.00f / (1-adjustRGB.b) * inputColor.b;", false);
outputString.AddShaderChunk("red = clamp(red,0.00f,1.00f);", false);
outputString.AddShaderChunk("green = clamp(green,0.00f,1.00f);", false);
outputString.AddShaderChunk("blue = clamp(blue,0.00f,1.00f);", false);
outputString.AddShaderChunk("finalColor.r = red;", false);
outputString.AddShaderChunk("finalColor.g = green;", false);
outputString.AddShaderChunk("finalColor.b = blue;", false);
outputString.AddShaderChunk("finalColor.a = inputColor.a;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs.meta


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

67
MaterialGraphProject/Assets/_MingWai/RandomRangeNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Range/RandomRange")]
public class RandomRangeNode : Function3Input, IGeneratesFunction
{
public RandomRangeNode()
{
name = "RandomRange";
}
protected override string GetFunctionName()
{
return "unity_randomrange_" + precision;
}
protected override string GetInputSlot1Name()
{
return "Seed";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override string GetInputSlot2Name()
{
return "Min";
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector2.zero);
}
protected override string GetInputSlot3Name()
{
return "Max";
}
protected override MaterialSlot GetInputSlot3()
{
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector3.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("seed", "min", "max"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float randomno = frac(sin(dot(seed, float2(12.9898, 78.233)))*43758.5453);", false);
outputString.AddShaderChunk("return floor(randomno * (max - min + 1)) + min;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/_MingWai/RandomRangeNode.cs.meta


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

121
MaterialGraphProject/Assets/_MingWai/ScatterNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Scatter")]
public class ScatterNode : FunctionNInNOut, IGeneratesFunction
{
[SerializeField]
private int m_num = 1 ;
public int num
{
get { return m_num; }
set
{
if (m_num == value)
{
return;
}
m_num = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public ScatterNode()
{
name = "Scatter";
AddSlot("Texture", "inputTex", Graphing.SlotType.Input, SlotValueType.sampler2D, Vector4.zero);
AddSlot("UV", "inputUV", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one);
AddSlot("Seed", "seed", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.one);
AddSlot("PositionRange", "p_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("RotationRange", "r_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("ScaleRange", "s_range", Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
UpdateNodeAfterDeserialization();
}
protected override string GetFunctionName()
{
return "unity_scatter_" + precision;
}
public override bool hasPreview
{
get { return true; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
//RotateUVFunction ===================================================================
outputString.AddShaderChunk("inline float2 rotateUV( float2 arg1, float arg2 )", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
//center texture's pivot
outputString.AddShaderChunk("arg1.xy -= 0.5;", false);
//rotation matrix
outputString.AddShaderChunk(precision + " s = sin(arg2);", false);
outputString.AddShaderChunk(precision + " c = cos(arg2);", false);
outputString.AddShaderChunk(precision + "2x2 rMatrix = float2x2(c, -s, s, c);", false);
//center rotation matrix
outputString.AddShaderChunk("rMatrix *= 0.5;", false);
outputString.AddShaderChunk("rMatrix += 0.5;", false);
outputString.AddShaderChunk("rMatrix = rMatrix*2 - 1;", false);
//multiply the UVs by the rotation matrix
outputString.AddShaderChunk("arg1.xy = mul(arg1.xy, rMatrix);", false);
outputString.AddShaderChunk("arg1.xy += 0.5;", false);
outputString.AddShaderChunk("return " + "arg1;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
//RamdomFunction ===================================================================
outputString.AddShaderChunk("inline float randomrange(float2 randomseed, float min, float max)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("float randomno = frac(sin(dot(randomseed, float2(12.9898, 78.233)))*43758.5453);", false);
outputString.AddShaderChunk("return floor(randomno * (max - min + 1)) + min;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
//ScatterFunction ===================================================================
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("finalColor = float4(0,0,0,0);", false);
outputString.AddShaderChunk("float2 newuv = inputUV;", false);
outputString.AddShaderChunk("float4 tex = tex2D(inputTex,newuv);", false);
for (int i=0; i<m_num; i++)
{
//random UV
outputString.AddShaderChunk("newuv *= randomrange(seed,s_range.x,s_range.y);", false); //Scale
outputString.AddShaderChunk("newuv = rotateUV(newuv,randomrange(seed,r_range.x,r_range.y));", false); //Rotate
outputString.AddShaderChunk("newuv += randomrange(seed,p_range.x,p_range.y));", false); //Position
//seamless
//sample
outputString.AddShaderChunk("tex = tex2D(inputTex,newuv);", false);
//blend together
outputString.AddShaderChunk("finalColor += tex/"+m_num+";", false);
}
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/_MingWai/ScatterNode.cs.meta


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

9
MaterialGraphProject/Assets/Florent/GeneratedTexture.meta


fileFormatVersion: 2
guid: fbb15485f0112484eaa58e88a4ac393f
folderAsset: yes
timeCreated: 1495654193
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

9
MaterialGraphProject/Assets/Matt/Examples/HueStrip.ShaderGraph.meta


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

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

9
MaterialGraphProject/Assets/Matt/Examples/Swirl.ShaderGraph.meta


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

103
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Matrix/Matrix 2")]
public class Matrix2Node : AbstractMaterialNode, IGeneratesBodyCode
{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Value";
[SerializeField]
private Vector2[] m_Value = new Vector2[2];
public Vector2 this[int index]
{
get { return m_Value[index]; }
set
{
if (m_Value[index] == value)
return;
m_Value[index] = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public Matrix2Node()
{
name = "Matrix2";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix2, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public string propertyName
{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
}
}
public override string GetVariableNameForSlot(int slotId)
{
return propertyName;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "2 " + propertyName + " = " + precision + "2x2 (" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[1].x + ", " + m_Value[1].y + ");", true);
}
[SerializeField]
private string m_Description = string.Empty;
public string description
{
get
{
return string.IsNullOrEmpty(m_Description) ? name : m_Description;
}
set { m_Description = value; }
}
// TODO - Remove Property entries everywhere?
// Matrix cant be a shader property
/*public override PropertyType propertyType
{
get { return PropertyType.Matrix2; }
}*/
/*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 + "2 " + propertyName + ";", true);
}*/
/*public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector4 = m_Value
};
}*/
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs.meta


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

103
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Matrix/Matrix 3")]
public class Matrix3Node : AbstractMaterialNode, IGeneratesBodyCode
{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Value";
[SerializeField]
private Vector3[] m_Value = new Vector3[3];
public Vector3 this[int index]
{
get { return m_Value[index]; }
set
{
if (m_Value[index] == value)
return;
m_Value[index] = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public Matrix3Node()
{
name = "Matrix3";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public string propertyName
{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
}
}
public override string GetVariableNameForSlot(int slotId)
{
return propertyName;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "3x3 " + propertyName + " = " + precision + "3x3 (" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[0].z + ", " + m_Value[1].x + ", " + m_Value[1].y + ", " + m_Value[1].z + ", " + m_Value[2].x + ", " + m_Value[2].y + ", " + m_Value[2].z + ");", true);
}
[SerializeField]
private string m_Description = string.Empty;
public string description
{
get
{
return string.IsNullOrEmpty(m_Description) ? name : m_Description;
}
set { m_Description = value; }
}
// TODO - Remove Property entries everywhere?
// Matrix cant be a shader property
/*public override PropertyType propertyType
{
get { return PropertyType.Matrix2; }
}*/
/*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 + "2 " + propertyName + ";", true);
}*/
/*public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector4 = m_Value
};
}*/
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs.meta


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

103
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix4Node.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Matrix/Matrix 4")]
public class Matrix4Node : AbstractMaterialNode, IGeneratesBodyCode
{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Value";
[SerializeField]
private Vector4[] m_Value = new Vector4[4];
public Vector4 this[int index]
{
get { return m_Value[index]; }
set
{
if (m_Value[index] == value)
return;
m_Value[index] = value;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
}
public Matrix4Node()
{
name = "Matrix4";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public string propertyName
{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
}
}
public override string GetVariableNameForSlot(int slotId)
{
return propertyName;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "4x4 " + propertyName + " = " + precision + "4x4 (" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[0].z + ", " + m_Value[0].w + ", " + m_Value[1].x + ", " + m_Value[1].y + ", " + m_Value[1].z + ", " + m_Value[1].w + ", " + m_Value[2].x + ", " + m_Value[2].y + ", " + m_Value[2].z + ", " + m_Value[2].w + ", " + m_Value[3].x + ", " + m_Value[3].y + ", " + m_Value[3].z + ", " + m_Value[3].w + ");", true);
}
[SerializeField]
private string m_Description = string.Empty;
public string description
{
get
{
return string.IsNullOrEmpty(m_Description) ? name : m_Description;
}
set { m_Description = value; }
}
// TODO - Remove Property entries everywhere?
// Matrix cant be a shader property
/*public override PropertyType propertyType
{
get { return PropertyType.Matrix2; }
}*/
/*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 + "2 " + propertyName + ";", true);
}*/
/*public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector4 = m_Value
};
}*/
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix4Node.cs.meta


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

68
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs


using System.ComponentModel;
using UnityEngine.Graphing;
using System.Collections.Generic;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Matrix/CommonMatrix")]
public class MatrixCommonNode : AbstractMaterialNode
{
static Dictionary<CommonMatrixType, string> m_matrixList = new Dictionary<CommonMatrixType, string>
{
{CommonMatrixType.ModelView, "UNITY_MATRIX_MV"},
{CommonMatrixType.View, "UNITY_MATRIX_V"},
{CommonMatrixType.Projection, "UNITY_MATRIX_P"},
{CommonMatrixType.ViewProjection, "UNITY_MATRIX_VP"},
{CommonMatrixType.TransposeModelView, "UNITY_MATRIX_T_MV"},
{CommonMatrixType.InverseTransposeModelView, "UNITY_MATRIX_IT_MV"},
{CommonMatrixType.ObjectToWorld, "unity_ObjectToWorld"},
{CommonMatrixType.WorldToObject, "unity_WorldToObject"},
};
[SerializeField]
private CommonMatrixType m_matrix = CommonMatrixType.ModelView;
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Output";
public override bool hasPreview { get { return false; } }
public CommonMatrixType matrix
{
get { return m_matrix; }
set
{
if (m_matrix == value)
return;
m_matrix = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public MatrixCommonNode()
{
name = "CommonMatrix";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override string GetVariableNameForSlot(int slotId)
{
return m_matrixList[matrix];
}
public bool RequiresVertexColor()
{
return true;
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs.meta


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

123
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Matrix/MultiplyMatrixByVector")]
public class MatrixMultiplyByVectorNode : AbstractMaterialNode, IGeneratesBodyCode, 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;
public override bool hasPreview
{
get { return false; }
}
public MatrixMultiplyByVectorNode()
{
name = "MultiplyMatrixByVector";
UpdateNodeAfterDeserialization();
}
protected string GetFunctionName()
{
return "unity_matrix_multiplybyvector_" + precision;
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputSlot1());
AddSlot(GetInputSlot2());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { InputSlot1Id, InputSlot2Id, OutputSlotId }; }
}
protected MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
}
protected MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector4, Vector4.zero);
}
protected MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
protected virtual string GetInputSlot1Name()
{
return "Input1";
}
protected virtual string GetInputSlot2Name()
{
return "Input2";
}
protected string GetOutputSlotName()
{
return "Output";
}
protected 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 string GetFunctionCallBody(string input1Value, string input2Value)
{
return GetFunctionName() + " (" + input1Value + ", " + input2Value + ")";
}
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}
private string input1Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot1Id).concreteValueType); }
}
private string input2Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}
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 mul(arg1, arg2);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs.meta


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

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:

/MaterialGraphProject/Assets/Brandon/NoiseNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/NoiseNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixMultiplyNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixMultiplyNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixTransposeNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs

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

正在加载...
取消
保存