浏览代码

Merge remote-tracking branch 'origin/hackweek2017' into hackweek2017

/main
ChrisTchou 8 年前
当前提交
683c517e
共有 886 个文件被更改,包括 4546 次插入387 次删除
  1. 146
      MaterialGraphProject/Assets/Andre/Materials/Mat.mat
  2. 8
      MaterialGraphProject/Assets/Andre/Nodes/Editor/TransformNodePresenter.cs
  3. 2
      MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs
  4. 194
      MaterialGraphProject/Assets/Andre/Nodes/TransformNode.cs
  5. 2
      MaterialGraphProject/Assets/Andre/Shaders/TestingGraph.ShaderGraph
  6. 1
      MaterialGraphProject/Assets/Eduardo/ConstantsNode.cs
  7. 2
      MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
  8. 4
      MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat
  9. 54
      MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
  10. 26
      MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs
  11. 127
      MaterialGraphProject/Assets/GeneratedShader.shader
  12. 4
      MaterialGraphProject/Assets/GraphView/Editor.meta
  13. 2
      MaterialGraphProject/Assets/Matt/AnisotropicMaster.ShaderGraph
  14. 2
      MaterialGraphProject/Assets/Matt/Test.ShaderGraph
  15. 2
      MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs
  16. 5
      MaterialGraphProject/Assets/TestAssets/Materials/Default.mat
  17. 2
      MaterialGraphProject/Assets/TestAssets/Teapot.fbx.meta
  18. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  19. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
  20. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
  21. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/subshader.template
  22. 29
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  23. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Function2Input.cs
  24. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/ScreenPosNode.cs
  25. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
  26. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
  27. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Range/RemapNode.cs
  28. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/CheckerboardNode.cs
  29. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs
  30. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs
  31. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SlotValue.cs
  32. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVTileNode.cs
  33. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
  34. 35
      MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs
  35. 122
      MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs
  36. 9
      MaterialGraphProject/ProjectSettings/ProjectSettings.asset
  37. 67
      MaterialGraphProject/ProjectSettings/QualitySettings.asset
  38. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs
  39. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs
  40. 9
      MaterialGraphProject/Assets/Brandon/Electricity.meta
  41. 9
      MaterialGraphProject/Assets/Florent.meta
  42. 22
      MaterialGraphProject/Assets/Matt/CommonMatrixType.cs
  43. 12
      MaterialGraphProject/Assets/Matt/CommonMatrixType.cs.meta
  44. 9
      MaterialGraphProject/Assets/Matt/Examples.meta
  45. 63
      MaterialGraphProject/Assets/Matt/UnlitMasterNode.cs
  46. 12
      MaterialGraphProject/Assets/Matt/UnlitMasterNode.cs.meta
  47. 335
      MaterialGraphProject/Assets/NewNodes/WIP/POMNode.cs
  48. 12
      MaterialGraphProject/Assets/NewNodes/WIP/POMNode.cs.meta
  49. 1
      MaterialGraphProject/Assets/POM_Graph.ShaderGraph
  50. 9
      MaterialGraphProject/Assets/POM_Graph.ShaderGraph.meta
  51. 9
      MaterialGraphProject/Assets/Rinaldo/DemoScene.meta
  52. 1001
      MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif
  53. 84
      MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif.meta
  54. 21
      MaterialGraphProject/Assets/TestAssets/TangentMap1.jpg
  55. 75
      MaterialGraphProject/Assets/TestAssets/TangentMap1.jpg.meta
  56. 33
      MaterialGraphProject/Assets/TestAssets/TangentMap2.jpg
  57. 75
      MaterialGraphProject/Assets/TestAssets/TangentMap2.jpg.meta
  58. 12
      MaterialGraphProject/Assets/TestAssets/TangentMap3.jpg
  59. 75
      MaterialGraphProject/Assets/TestAssets/TangentMap3.jpg.meta
  60. 151
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs
  61. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs.meta
  62. 51
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs
  63. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs.meta
  64. 64
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/SamplerStatePresenter.cs
  65. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/SamplerStatePresenter.cs.meta
  66. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs
  67. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs.meta
  68. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureSamplerPresenter.cs
  69. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureSamplerPresenter.cs.meta
  70. 445
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_height.png
  71. 75
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_height.png.meta
  72. 137
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga
  73. 75
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga.meta
  74. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp
  75. 75
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp.meta
  76. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/tesselationSubshader.template
  77. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/tesselationSubshader.template.meta
  78. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters.meta
  79. 68
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs
  80. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs.meta
  81. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraDirNode.cs
  82. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraDirNode.cs.meta
  83. 36
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraPosNode.cs
  84. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraPosNode.cs.meta
  85. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix.meta
  86. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/NoiseNode.cs.meta
  87. 60
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs
  88. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs.meta
  89. 133
      MaterialGraphProject/Assets/Vlad/SamplerStateNode.cs
  90. 12
      MaterialGraphProject/Assets/Vlad/SamplerStateNode.cs.meta
  91. 246
      MaterialGraphProject/Assets/Vlad/TextureSamplerNode.cs
  92. 12
      MaterialGraphProject/Assets/Vlad/TextureSamplerNode.cs.meta
  93. 55
      MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs
  94. 12
      MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs.meta

146
MaterialGraphProject/Assets/Andre/Materials/Mat.mat


disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- Cubemap_181b280a_a8b7_461e_bbeb_30fa23931a56_Uniform:
m_Texture: {fileID: 8900000, guid: f7111c407ddfe4109af9703cb740eaf9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Cubemap_cfafd4ef_c0b8_4ca3_9f3c_7068e7916d3e_Uniform:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Cubemap_dc3182b8_fe99_45ed_8c1d_67fb354034bd_Uniform:
m_Texture: {fileID: 8900000, guid: f7111c407ddfe4109af9703cb740eaf9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9_Uniform:
m_Texture: {fileID: 8900000, guid: f7111c407ddfe4109af9703cb740eaf9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- TextureAsset_ebbe75eb_728a_4e6c_b8a1_994df86c74ad_Uniform:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_02e4013b_5c99_456a_a8d8_cafbb1dfc0da_Uniform:
m_Texture: {fileID: 2800000, guid: 5a5e07ee958edbd468227e1d9ac4726a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_401188ed_6e9e_4a8a_9f5c_a7853502ba40_Uniform:
m_Texture: {fileID: 2800000, guid: aa460a2956f927d4ab684aa4970bf76a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform:
m_Texture: {fileID: 10305, guid: 0000000000000000f000000000000000, type: 0}
m_Scale: {x: 1, y: 2}
m_Offset: {x: 0, y: 0}
- Texture_6df69ae7_cb4c_435c_a029_13f370817e4c_Uniform:
m_Texture: {fileID: 2800000, guid: 84462bdfeee9d694bbebf34e5f3faa74, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_73d7755c_9da7_46d2_90c6_35c2a880d380_Uniform:
m_Texture: {fileID: 2800000, guid: 5a5e07ee958edbd468227e1d9ac4726a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_7e044bc6_b639_4457_83f6_752bfaedcb11_Uniform:
m_Texture: {fileID: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_8304e17f_0ca3_45b8_9081_4e083e4ffba7_Uniform:
m_Texture: {fileID: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_aa489395_d5b1_4bce_a08c_71ce4329894d_Uniform:
m_Texture: {fileID: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_bac51ec0_c299_4919_8bbd_573b26865795_Uniform:
m_Texture: {fileID: 2800000, guid: 556373d2abe91394795e2c7b920330f0, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_c007d40f_e93f_40ea_9867_1b70cebcd3fd_Uniform:
m_Texture: {fileID: 2800000, guid: aa460a2956f927d4ab684aa4970bf76a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_cfc1ad3f_b7ac_495b_a5d4_bbf5e525f27c_Uniform:
m_Texture: {fileID: 2800000, guid: 46dd7a1d84b1ee64ca65752c24cfd890, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_d48530d7_5921_4987_918e_46411222e797_Uniform:
m_Texture: {fileID: 2800000, guid: 5b01c9e873ba169449186e98e1483a23, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_d6d1ed65_5575_444c_8f92_38740ace2353_Uniform:
m_Texture: {fileID: 2800000, guid: 5a5e07ee958edbd468227e1d9ac4726a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_f6eb7ab6_0df6_4d1f_a833_847f9eefa1ce_Uniform:
m_Texture: {fileID: 2800000, guid: 915047e45d68d412f9e6857db8439117, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_fd9422b7_6255_4b8e_b616_78346d444d21_Uniform:
m_Texture: {fileID: 2800000, guid: 84462bdfeee9d694bbebf34e5f3faa74, 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_TexEnvs: []
- Toggle_bda28932_b1ab_4b0b_ba54_ca5db612047a_Uniform: 0.6
- Vector1_15d5efb3_faea_4990_90ce_629f350a50cb_Uniform: 0
- Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform: 0.05
- Vector1_36d8f7c7_3ada_4604_9149_df2ba1745b80_Uniform: 8
- Vector1_48a064e9_29c4_4cdd_8bf7_34902bb50605_Uniform: 3
- Vector1_681e693a_7812_42ab_a37b_8a1edc00d63e_Uniform: 0.005
- Vector1_bc1392c9_f4d7_47a8_8add_f4f4b00fdfe5_Uniform: 0
- _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}
- Vector1_a2ac4923_bc39_4a5c_924e_e77bd500d4f3_Uniform: 1
m_Colors: []

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


if (tNode == null)
return;
//tNode.floatType = (FloatPropertyChunk.FloatType)EditorGUILayout.EnumPopup ("Float", tNode.floatType);
//EditorGUILayout.BeginHorizontal ();
tNode.spaceFrom = (SimpleMatrixType)EditorGUILayout.EnumPopup ("From", tNode.spaceFrom);
tNode.spaceTo = (SimpleMatrixType)EditorGUILayout.EnumPopup ("To", tNode.spaceTo);
//EditorGUILayout.BeginHorizontal ();
return (EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
return (EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}

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


public class ToggleNode : PropertyNode, IGeneratesBodyCode
{
[SerializeField]
private float m_Float;
//private float m_Float;
private bool m_ToggleState;
private const int kOutputSlotId = 0;

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


namespace UnityEngine.MaterialGraph
using UnityEngine.Graphing;
using System.Collections.Generic;
namespace UnityEngine.MaterialGraph
public class TransformNode : Function1Input
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);
}
}
}
UpdateNodeAfterDeserialization ();
protected override string GetFunctionName ()
public sealed override void UpdateNodeAfterDeserialization()
AddSlot(GetInputSlot());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
//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
protected int[] validSlots
{
get { return new[] {InputSlotId, OutputSlotId}; }
}
//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
protected virtual MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero);
}
//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
protected virtual MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero);
}
//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
protected virtual string GetInputSlotName()
{
return "Input";
}
return "exp";
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;
}
}
}

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

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
文件差异内容过多而无法显示
查看文件

4
MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat


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}

54
MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs


else
nextSlotId = GetInputSlots<MaterialSlot>().Count() + 1;
bool useDefaultValue = (valueType != SlotValueType.sampler2D);
bool useDefaultValue = (valueType != SlotValueType.Texture2D);
AddSlot(new MaterialSlot(nextSlotId, displayName, nameInShader, slotType, valueType, defaultValue, useDefaultValue));
return nextSlotId;
}

public string GetSlotTypeName(int slotId)
{
return ConvertConcreteSlotValueTypeToString(FindSlot<MaterialSlot>(slotId).concreteValueType);
}
public ConcreteSlotValueType GetSlotValueType(int slotId)
{
return FindSlot<MaterialSlot>(slotId).concreteValueType;
}
protected string GetShaderOutputName(int slotId)

if (inSlot.isOutputSlot)
param += "out ";
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.sampler2D)
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.Texture2D
&& FindSlot<MaterialSlot>(inSlot.id).concreteValueType != ConcreteSlotValueType.SamplerState
)
param += precision;
param += GetSlotTypeName(inSlot.id) + " ";
param += GetShaderOutputName(inSlot.id);

int remainingParams = GetSlots<ISlot>().Count();
foreach (ISlot inSlot in GetSlots<ISlot>())
{
param += GetSlotValue(inSlot.id, generationMode);
if (FindSlot<MaterialSlot>(inSlot.id).concreteValueType == ConcreteSlotValueType.SamplerState)
param += GetSamplerInput(inSlot.id);
else
param += GetSlotValue(inSlot.id, generationMode);
if (remainingParams > 1)
param += ", ";

private string GetFunctionCall(GenerationMode generationMode)
{
return GetFunctionName() +
string prefix = "";
string sufix = "";
foreach (ISlot slot in GetInputSlots<MaterialSlot>())
{
if (GetSlotValueType(slot.id) == ConcreteSlotValueType.Texture2D || GetSlotValueType(slot.id) == ConcreteSlotValueType.SamplerState)
{
prefix = "#ifdef UNITY_COMPILER_HLSL \n";
sufix = "\n #endif";
}
}
return prefix + GetFunctionName() +
");";
");" + sufix;
}
private string GetOutputDeclaration()

outputString.AddShaderChunk(GetFunctionCall(generationMode), false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
public string GetSamplerInput(int slotID)
{
//default sampler if no input is provided
var samplerName = "my_linear_repeat_sampler";
//Sampler input slot
var samplerSlot = FindInputSlot<MaterialSlot>(slotID);
if (samplerSlot != null)
{
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList();
if (edgesSampler.Count > 0)
{
var edge = edgesSampler[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true);
}
}
return samplerName;
}
}
}

26
MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Utility/Heightmap To Normalmap")]
public class HeightToNormalNode : FunctionNInNOut, IGeneratesFunction
public class HeightToNormalNode : FunctionNInNOut, IGeneratesFunction, IGenerateProperties
AddSlot("HeightMap", "heightmap", Graphing.SlotType.Input, SlotValueType.sampler2D, Vector4.zero);
AddSlot("HeightMap", "heightmap", Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
AddSlot("UV", "texCoord", Graphing.SlotType.Input, SlotValueType.Vector2, Vector4.zero);
AddSlot("Offset", "texOffset", Graphing.SlotType.Input, SlotValueType.Vector1, new Vector4(0.005f, 0,0,0));
AddSlot("Strength", "strength", Graphing.SlotType.Input, SlotValueType.Vector1, new Vector4(8,0,0,0));

get { return true; }
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
base.GeneratePropertyUsages(visitor, generationMode);
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk("SamplerState my_linear_repeat_sampler;", false);
visitor.AddShaderChunk("#endif", false);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();

outputString.AddShaderChunk("float2 offsetV = float2(texCoord.x, texCoord.y + texOffset);", false);
outputString.AddShaderChunk("float normalSample = tex2D(heightmap, texCoord).r;", false);
outputString.AddShaderChunk("float uSample = tex2D(heightmap, offsetU).r;", false);
outputString.AddShaderChunk("float vSample = tex2D(heightmap, offsetV).r;", false);
outputString.AddShaderChunk("float normalSample = 0;", false);
outputString.AddShaderChunk("float uSample = 0;", false);
outputString.AddShaderChunk("float vSample = 0;", false);
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
outputString.AddShaderChunk("normalSample = heightmap.Sample(my_linear_repeat_sampler, texCoord).r;", false);
outputString.AddShaderChunk("uSample = heightmap.Sample(my_linear_repeat_sampler, offsetU).r;", false);
outputString.AddShaderChunk("vSample = heightmap.Sample(my_linear_repeat_sampler, offsetV).r;", false);
visitor.AddShaderChunk("#endif", false);
outputString.AddShaderChunk("float uMinusNormal = uSample - normalSample;", false);
outputString.AddShaderChunk("float vMinusNormal = vSample - normalSample;", false);

127
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 "Graph/Generated.MetallicMasterNode554b91b5-7a00-4f5f-b71a-f7729fcbdee8"
{
Properties
{
[NonModifiableTextureData] TextureAsset_8f4a8771_6c8f_4107_9c0b_83da34d57a9b_Uniform("TextureAsset", 2D) = "white" {}
SubShader {
// inside SubShader
SubShader
{
"Queue"="Geometry"
"IgnoreProjector"="True"
"Queue"="Geometry"
// inside Pass
Blend One Zero
Cull Back
ZTest LEqual
Blend One Zero
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
LOD 200
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard vertex:vert
#pragma glsl
#pragma debug
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25_normalDir;
float Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform;
#ifdef UNITY_COMPILER_HLSL
Texture2D TextureAsset_8f4a8771_6c8f_4107_9c0b_83da34d57a9b_Uniform;
#endif
float HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_texOffset;
float HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_strength;
#ifdef UNITY_COMPILER_HLSL
SamplerState my_linear_repeat_sampler;
#endif
#ifdef UNITY_COMPILER_HLSL
#endif
inline void unity_HeightToNormal (Texture2D heightmap, float2 texCoord, float texOffset, float strength, out float3 normalRes)
{
float2 offsetU = float2(texCoord.x + texOffset, texCoord.y);
float2 offsetV = float2(texCoord.x, texCoord.y + texOffset);
float normalSample = 0;
float uSample = 0;
float vSample = 0;
normalSample = heightmap.Sample(my_linear_repeat_sampler, texCoord).r;
uSample = heightmap.Sample(my_linear_repeat_sampler, offsetU).r;
vSample = heightmap.Sample(my_linear_repeat_sampler, offsetV).r;
float uMinusNormal = uSample - normalSample;
float vMinusNormal = vSample - normalSample;
uMinusNormal = uMinusNormal * strength;
vMinusNormal = vMinusNormal * strength;
float3 va = float3(1, 0, uMinusNormal);
float3 vb = float3(0, 1, vMinusNormal);
normalRes = cross(va, vb);
}
struct v2f
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float3 worldNormal : TEXCOORD1;
};
struct Input
{
float4 color : COLOR;
half4 meshUV0;
inline float unity_posterize_float (float input, float stepsize)
{
return floor(input / stepsize) * stepsize;
}
};
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.meshUV0 = v.texcoord;
v2f vert (appdata_full v)
{
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;
}
void surf (Input IN, inout SurfaceOutputStandard o)
{
half4 uv0 = IN.meshUV0;
float4 UV_de8d7b89_7b50_499d_aa73_0f2a725356e6_UV = uv0;
float3 HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_normalRes;
#ifdef UNITY_COMPILER_HLSL
unity_HeightToNormal (TextureAsset_8f4a8771_6c8f_4107_9c0b_83da34d57a9b_Uniform, UV_de8d7b89_7b50_499d_aa73_0f2a725356e6_UV, HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_texOffset, HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_strength, HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_normalRes);
#endif
o.Normal = HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_normalRes;
o.Normal += 1e-6;
return o;
}
}
ENDCG
}
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);
}
ENDCG
}
}
Fallback Off
}
FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
}

4
MaterialGraphProject/Assets/GraphView/Editor.meta


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

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

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

2
MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs


protected virtual MaterialSlot GetTextureSlot()
{
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.sampler2D, Vector4.zero);
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
}
protected virtual MaterialSlot GetOutputSlot()

5
MaterialGraphProject/Assets/TestAssets/Materials/Default.mat


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Default
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Shader: {fileID: 4800000, guid: 9ab5e16c2083a4fe689209a8c1ae425e, type: 3}
m_LightmapFlags: 4
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- Vector1_a2ac4923_bc39_4a5c_924e_e77bd500d4f3_Uniform: 1
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1

2
MaterialGraphProject/Assets/TestAssets/Teapot.fbx.meta


useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
normalImportMode: 1
tangentImportMode: 3
normalCalculationMode: 4
importAnimation: 1

20
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(TextureSamplerNode)] = typeof(TextureSamplerNodePresenter);
typeMapper[typeof(SamplerStateNode)] = typeof(SamplerStateNodePresenter);
typeMapper[typeof(CubemapNode)] = typeof(CubeNodePresenter);
typeMapper[typeof(ToggleNode)] = typeof(ToggleNodePresenter);
typeMapper[typeof(UVNode)] = typeof(UVNodePresenter);

typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodePresenter);
typeMapper[typeof(Matrix3Node)] = typeof(Matrix3NodePresenter);
typeMapper[typeof(Matrix4Node)] = typeof(Matrix4NodePresenter);
typeMapper[typeof(MatrixCommonNode)] = typeof(MatrixCommonNodePresenter);
typeMapper[typeof(ConvolutionFilterNode)] = typeof(ConvolutionFilterNodePresenter);
}
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();
}
}
}

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: []

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/subshader.template


#pragma glsl
#pragma debug
${ShaderPropertyUsages}
${ShaderPropertyUsages}
struct Input
{

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


if (edges.Any())
continue;
inputSlot.GeneratePropertyUsages(visitor, generationMode);
if (inputSlot.valueType == SlotValueType.SamplerState)
{
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk(inputSlot.valueType + " my_linear_repeat_sampler;", false);
visitor.AddShaderChunk("#endif", false);
}
else
inputSlot.GeneratePropertyUsages(visitor, generationMode);
}
}

return ConcreteSlotValueType.Vector3;
case SlotValueType.Vector4:
return ConcreteSlotValueType.Vector4;
case SlotValueType.sampler2D:
return ConcreteSlotValueType.sampler2D;
case SlotValueType.Texture2D:
return ConcreteSlotValueType.Texture2D;
case SlotValueType.Matrix2:
return ConcreteSlotValueType.Matrix2;
case SlotValueType.Matrix3:

case SlotValueType.SamplerState:
return ConcreteSlotValueType.SamplerState;
}
return ConcreteSlotValueType.Error;
}

return "3";
case ConcreteSlotValueType.Vector4:
return "4";
case ConcreteSlotValueType.sampler2D:
return "sampler2D";
case ConcreteSlotValueType.Texture2D:
return "Texture2D";
case ConcreteSlotValueType.Matrix2:
return "2x2";
case ConcreteSlotValueType.Matrix3:

case ConcreteSlotValueType.SamplerState:
return "SamplerState";
case ConcreteSlotValueType.Sampler2D:
return "sampler2D";
default:
return "Error";
}

{
switch (slotValue)
{
case ConcreteSlotValueType.sampler2D:
case ConcreteSlotValueType.Texture2D:
return PropertyType.Texture;
case ConcreteSlotValueType.Vector1:
return PropertyType.Float;

return PropertyType.Matrix3;
case ConcreteSlotValueType.Matrix4:
return PropertyType.Matrix4;
case ConcreteSlotValueType.SamplerState:
return PropertyType.SamplerState;
case ConcreteSlotValueType.Sampler2D:
return PropertyType.Texture;
default:
return PropertyType.Vector4;
}

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


+ precision + input2Dimension + " " + arg2Name + ")";
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlot1Id, InputSlot2Id }, new[] { OutputSlotId });
string input1Value = GetSlotValue(InputSlot1Id, generationMode);

get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
private string input1Dimension
protected string input1Dimension
private string input2Dimension
protected string input2Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}

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


UpdateNodeAfterDeserialization();
}
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "ScreenPos";
private const int kOutputSlot1Id = 0;
private const string kOutputSlot1Name = "Raw ScreenPos";
private const int kOutputSlot2Id = 1;
private const string kOutputSlot2Name = "Normalized";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
AddSlot(new MaterialSlot(kOutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(kOutputSlot2Id, kOutputSlot2Name, kOutputSlot2Name, SlotType.Output, SlotValueType.Vector3, Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlot1Id, kOutputSlot2Id });
string returnString = "";
switch (slotId){
case 0:
returnString = ShaderGeneratorNames.ScreenPosition;
break;
case 1:
returnString = "float3(" + ShaderGeneratorNames.ScreenPosition + ".xy / " + ShaderGeneratorNames.ScreenPosition + ".w, 0)";
break;
}
return ShaderGeneratorNames.ScreenPosition;
}

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


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

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


return "(3x3)";
case ConcreteSlotValueType.Matrix4:
return "(4x4)";
case ConcreteSlotValueType.SamplerState:
return "(SS)";
case ConcreteSlotValueType.Texture2D:
return "(T)";
case ConcreteSlotValueType.Sampler2D:
return "(S)";
default:
return "(E)";
}

case SlotValueType.Matrix4:
concreteValueType = ConcreteSlotValueType.Matrix4;
break;
case SlotValueType.Texture2D:
concreteValueType = ConcreteSlotValueType.Texture2D;
break;
case SlotValueType.SamplerState:
concreteValueType = ConcreteSlotValueType.SamplerState;
break;
case SlotValueType.Sampler2D:
concreteValueType = ConcreteSlotValueType.Sampler2D;
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)
{

7
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Range/RemapNode.cs


public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
//new = arg3.x + (arg1 - arg2.x) * (arg3.y - arg3.x) / (arg2.y - arg2.x)
//low2 + (value - low1) * (high2 - low2) / (high1 - low1)
//old = arg1 * ((arg3.y - arg3.x) / (arg2.y - arg2.x)) + arg3.x
outputString.AddShaderChunk ("return arg1 * ((arg3.y - arg3.x) / (arg2.y - arg2.x)) + arg3.x;", false);
outputString.AddShaderChunk ("return arg3.x + (arg1 - arg2.x) * (arg3.y - arg3.x) / (arg2.y - arg2.x);", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);

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.Vector3, Vector3.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;", false);
outputString.Deindent();

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


Vector4,
Matrix2,
Matrix3,
Matrix4
Matrix4,
SamplerState
}
}

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


[Serializable]
public enum SlotValueType
{
Sampler2D,
SamplerState,
sampler2D,
Texture2D,
Dynamic,
Vector4,
Vector3,

public enum ConcreteSlotValueType
{
Sampler2D = 10,
SamplerState = 9,
sampler2D = 5,
Texture2D = 5,
Vector4 = 4,
Vector3 = 3,
Vector2 = 2,

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()

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


foreach (var node in activeNodeList.OfType<AbstractMaterialNode>())
{
string prefix = "";
string sufix = "";
foreach (ISlot slot in node.GetInputSlots<MaterialSlot>())
{
SlotValueType slotValueType = FindSlot<MaterialSlot>(slot.id).valueType;
if (slotValueType == SlotValueType.Texture2D || slotValueType == SlotValueType.SamplerState)
{
prefix = "#ifdef UNITY_COMPILER_HLSL \n";
sufix = "\n #endif";
}
}
{
nodeFunction.AddShaderChunk(prefix, false);
nodeFunction.AddShaderChunk(sufix, false);
}
node.GeneratePropertyUsages(propertyUsages, mode);
}

35
MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs


[Title("Input/Texture/Texture Asset")]
public class TextureAssetNode : PropertyNode
{
protected const string kOutputSlotRGBAName = "Texture";
protected const string outputTexture2D_name = "Texture2D";
protected const string outputSampler2D_name = "Sampler2D";
public const int OutputSlotRgbaId = 0;
public const int outputTexture2D_id = 0;
public const int outputSampler2D_id = 1;
[SerializeField]
private string m_SerializedTexture;

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotRgbaId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, SlotValueType.sampler2D, Vector4.zero, false));
AddSlot(new MaterialSlot(outputTexture2D_id, outputTexture2D_name, outputTexture2D_name, SlotType.Output, SlotValueType.Texture2D, Vector4.zero, false));
AddSlot(new MaterialSlot(outputSampler2D_id, outputSampler2D_name, outputSampler2D_name, SlotType.Output, SlotValueType.Sampler2D, Vector4.zero, false));
get { return new[] { OutputSlotRgbaId }; }
get { return new[] { outputTexture2D_id, outputSampler2D_id }; }
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)

public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk("sampler2D " + propertyName + ";", true);
var slotTexture2D = FindInputSlot<MaterialSlot>(0);
if (slotTexture2D != null)
{
var edgesTexture2D = owner.GetEdges(slotTexture2D.slotReference).ToList();
if (edgesTexture2D.Count > 0)
{
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", true);
visitor.AddShaderChunk("Texture2D " + propertyName + "_T2D;", true);
visitor.AddShaderChunk("#endif", true);
}
}
var slotSampler2D = FindInputSlot<MaterialSlot>(0);
if (slotSampler2D != null)
{
var edgesSampler2D = owner.GetEdges(slotTexture2D.slotReference).ToList();
if (edgesSampler2D.Count > 0)
{
visitor.AddShaderChunk("Sampler2D " + propertyName + "_S2D;", true);
}
}
public override PreviewProperty GetPreviewProperty()

122
MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Tri-Planar Mapping")]
public class UVTriPlanar : Function3Input, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
public class UVTriPlanar : FunctionNInNOut, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
private int slot0, slot1, slot2, slot3, slot4, slot5, slot6 = 0;
private const string kTextureSlotName = "Texture";
private const string kTileSlotName = "Tile";
private const string kBlendSlotName = "Blend";
private string slot0Name = "texRef";
private string slot1Name = "tileFactor";
private string slot2Name = "blendFactor";
private string slot3Name = "samplerRef";
private string slot4Name = "normalRef";
private string slot5Name = "posRef";
private string slot6Name = "outputRef";
protected override string GetFunctionName()
{

protected override MaterialSlot GetInputSlot1()
public UVTriPlanar()
return new MaterialSlot(InputSlot1Id, kTextureSlotName, kTextureSlotName, SlotType.Input, SlotValueType.sampler2D, Vector4.zero, false);
}
name = "UVTriPlanar";
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, kTileSlotName, kTileSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.one);
}
slot0 = AddSlot("Texture", slot0Name, Graphing.SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
slot1 = AddSlot("Tile", slot1Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot2 = AddSlot("Blend", slot2Name, Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
slot3 = AddSlot("Sampler", slot3Name, Graphing.SlotType.Input, SlotValueType.SamplerState, Vector4.zero);
slot4 = AddSlot("Normals", slot4Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot5 = AddSlot("Position", slot5Name, Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.one);
slot6 = AddSlot("RGBA ", slot6Name, Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
protected override MaterialSlot GetInputSlot3()
{
return new MaterialSlot(InputSlot3Id, kBlendSlotName, kBlendSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.one);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, kTextureSlotName, kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
public UVTriPlanar()
{
name = "UVTriPlanar";
UpdateNodeAfterDeserialization();
}

}
}
protected override string GetFunctionPrototype(string arg1Name, string arg2Name, string arg3Name)
{
return "inline " + precision + outputDimension + " " + GetFunctionName() + " ("
+ "sampler2D " + arg1Name + ", "
+ precision + " " + arg2Name + ", "
+ precision + " " + arg3Name +
", float3 normal, float3 pos)";
}
protected override string GetFunctionCallBody(string input1Value, string input2Value, string input3Value)
{
return GetFunctionName() + " (" + input1Value + ", " + input2Value + ", " + input3Value + ", IN.worldNormal, IN.worldPos)";
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
base.GeneratePropertyUsages(visitor, generationMode);
}
//TODO:Externalize
//Reference code from:http://www.chilliant.com/rgb2hsv.html

var textureSlot = FindInputSlot<MaterialSlot>(InputSlot1Id);
if (textureSlot == null)
return;
var textureName = "";
//Sampler input
var samplerName = GetSamplerInput(3);
outputString.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
var edges = owner.GetEdges(textureSlot.slotReference).ToList();
if (edges.Count > 0)
{
var edge = edges[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
textureName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.sampler2D, true);
}
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3"), false);
// outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3", samplerName), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.Indent();
outputString.Indent();
outputString.AddShaderChunk("fixed3 uvs = pos * arg2;", false);
outputString.AddShaderChunk("float3 uvs = " + slot5Name + "*" + slot1Name + ";", false);
outputString.AddShaderChunk("half3 blend = pow(abs(normal), arg3);", false);
outputString.AddShaderChunk("half3 blend = pow(abs(" + slot4Name + ")," + slot2Name + ");", false);
outputString.AddShaderChunk("fixed4 cx = tex2D(arg1, uvs.yz);", false);
outputString.AddShaderChunk("fixed4 cy = tex2D(arg1, uvs.xz);", false);
outputString.AddShaderChunk("fixed4 cz = tex2D(arg1, uvs.xy);", false);
outputString.AddShaderChunk("float4 cx = " + slot0Name + ".Sample(" + slot3Name + ", uvs.yz);", false);
outputString.AddShaderChunk("float4 cy = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xz);", false);
outputString.AddShaderChunk("float4 cz = " + slot0Name + ".Sample(" + slot3Name + ", uvs.xy);", false);
outputString.AddShaderChunk("fixed4 c = cx * blend.x + cy * blend.y + cz * blend.z;", false);
outputString.AddShaderChunk("return " + "c;", false);
outputString.AddShaderChunk(slot6Name + " = cx * blend.x + cy * blend.y + cz * blend.z;", false);
//outputString.AddShaderChunk("return " + "c;", false);
outputString.AddShaderChunk("#endif", true);
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
//Sampler input slot
base.GeneratePropertyUsages(visitor, generationMode);
var samplerSlot = FindInputSlot<MaterialSlot>(slot3);
if (samplerSlot != null)
{
var samplerName = GetSamplerInput(slot3);
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk("SamplerState " + samplerName + ";", true);
visitor.AddShaderChunk("#endif", false);
}
}
var slot = FindInputSlot<MaterialSlot>(InputSlot1Id);
var slot = FindInputSlot<MaterialSlot>(0);
if (slot == null)
return;

9
MaterialGraphProject/ProjectSettings/ProjectSettings.asset


webGLUseEmbeddedResources: 0
webGLUseWasm: 0
webGLCompressionFormat: 1
scriptingDefineSymbols: {}
scriptingDefineSymbols:
1: CROSS_PLATFORM_INPUT
4: CROSS_PLATFORM_INPUT;MOBILE_INPUT
7: CROSS_PLATFORM_INPUT;MOBILE_INPUT
14: CROSS_PLATFORM_INPUT;MOBILE_INPUT
17: MOBILE_INPUT
20: MOBILE_INPUT
22: MOBILE_INPUT
platformArchitecture: {}
scriptingBackend:
Android: 0

67
MaterialGraphProject/ProjectSettings/QualitySettings.asset


shadowProjection: 1
shadowCascades: 1
shadowDistance: 15
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 1
textureQuality: 1
anisotropicTextures: 0

realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
lodBias: .300000012
lodBias: 0.3
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Fast

shadowProjection: 1
shadowCascades: 1
shadowDistance: 20
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 2
textureQuality: 0
anisotropicTextures: 0

realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
lodBias: .400000006
lodBias: 0.4
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Simple

shadowProjection: 1
shadowCascades: 1
shadowDistance: 20
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 0
blendWeights: 2
textureQuality: 0
anisotropicTextures: 1

realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
lodBias: .699999988
lodBias: 0.7
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Good

shadowProjection: 1
shadowCascades: 2
shadowDistance: 40
shadowCascades: 4
shadowDistance: 80
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.074709564, y: 0.15174267, z: 0.2816801}
shadowmaskMode: 1
blendWeights: 2
textureQuality: 0
anisotropicTextures: 1

realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Beautiful

shadowProjection: 1
shadowCascades: 2
shadowDistance: 70
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 4
textureQuality: 0
anisotropicTextures: 2

realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
- serializedVersion: 2
name: Fantastic

shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
blendWeights: 4
textureQuality: 0
anisotropicTextures: 2

realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
m_PerPlatformDefaultQuality: {}
m_PerPlatformDefaultQuality:
Standalone: 0

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


protected MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix3, Vector4.zero);
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Matrix3, Vector4.zero);
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix3, Vector4.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero);
}
protected virtual string GetInputSlot1Name()

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


protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, SlotType.Input, SlotValueType.Matrix3, Vector4.zero);
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix3, Vector4.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero);
}
}
}

9
MaterialGraphProject/Assets/Brandon/Electricity.meta


fileFormatVersion: 2
guid: 19e252e915115064abad85add7ecd46f
folderAsset: yes
timeCreated: 1495737232
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:

63
MaterialGraphProject/Assets/Matt/UnlitMasterNode.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
[Title("Master/Unlit")]
public class UnlitMasterNode : AbstractAdvancedMasterNode
{
public const string LightFunctionName = "Advanced";
public const string SurfaceOutputStructureName = "SurfaceOutputAdvanced";
public UnlitMasterNode()
{
name = "UnlitMaster";
UpdateNodeAfterDeserialization();
}
public override string GetMaterialID()
{
return "SHADINGMODELID_UNLIT";
}
public override int[] GetCustomDataSlots()
{
return new int[] { };
}
public override string[] GetCustomData()
{
return new string[] { };
}
public sealed override void UpdateNodeAfterDeserialization()
{
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));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
AlphaSlotId
});
}
public override string GetSurfaceOutputName()
{
return SurfaceOutputStructureName;
}
public override string GetLightFunction()
{
return LightFunctionName;
}
}
}

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


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

335
MaterialGraphProject/Assets/NewNodes/WIP/POMNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("UV/ParallaxOcclusionMapping")]
public class ParallaxOcclusionMappingNode :
AbstractMaterialNode,
IGeneratesBodyCode,
IGeneratesFunction,
IMayRequireMeshUV,
IMayRequireViewDirection,
IMayRequireNormal,
IMayRequireViewDirectionTangentSpace
{
protected const string kInputHeightScaleShaderName = "HeightScale";
protected const string kTextureSlotShaderName = "Texture";
protected const string kOutputSlotShaderName = "UV";
public const int HeightScaleSlotId = 0; // 'height_scale'
public const int TextureSlotId = 1; // 'tex'
public const int OutputSlotId = 2;
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
public ParallaxOcclusionMappingNode()
{
name = "ParallaxOcclusionMapping";
UpdateNodeAfterDeserialization();
}
public string GetFunctionName()
{
return "unity_parallax_occlusion_mapping_" + precision;
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputHeightScaleSlot());
AddSlot(GetTextureSlot());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { HeightScaleSlotId, TextureSlotId, OutputSlotId }; }
}
protected virtual string GetInputHeightScaleName()
{
return kInputHeightScaleShaderName;
}
protected virtual MaterialSlot GetInputHeightScaleSlot()
{
return new MaterialSlot(
HeightScaleSlotId, GetInputHeightScaleName(), kInputHeightScaleShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected virtual MaterialSlot GetTextureSlot()
{
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero);
}
protected virtual MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector4.zero);
}
protected virtual string GetTextureSlotName()
{
return kTextureSlotShaderName;
}
protected virtual string GetOutputSlotName()
{
return kOutputSlotShaderName;
}
private string inputHeightScaleDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(HeightScaleSlotId).concreteValueType); }
}
protected virtual string GetFunctionPrototype(
string heightScale, string tex, string UVs, string viewTangentSpace, string worldSpaceNormal, string worldSpaceViewDirection)
{
return "inline " + precision + "2 " + GetFunctionName() + " (" +
precision + inputHeightScaleDimension + " " + heightScale + ", " +
"sampler2D " + tex + ", " +
precision + "2 " + UVs + ", " +
precision + "3 " + viewTangentSpace + ", " +
precision + "3 " + worldSpaceNormal + ", " +
precision + "3 " + worldSpaceViewDirection + ")";
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(
this,
new[] { HeightScaleSlotId, TextureSlotId },
new[] { OutputSlotId });
string heightScaleValue = GetSlotValue(HeightScaleSlotId, generationMode);
string textureValue = GetSlotValue(TextureSlotId, generationMode);
visitor.AddShaderChunk(precision + "2 " + GetVariableNameForSlot(OutputSlotId) + " = " +
GetFunctionCallBody(heightScaleValue, textureValue) + ";", true);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(
GetFunctionPrototype("heightScale", "tex", "UVs", "viewTangentSpace", "worldSpaceNormal", "worldSpaceViewDirection" ),
false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk(precision + "2 " + "height_map_dimensions = " + precision + "2" + "(256.0f, 256.0f); //HARDCODE", false);
//height_map.tex.GetDimensions(height_map_dimensions.x, height_map_dimensions.y);
outputString.AddShaderChunk(precision + "2 texcoord= UVs;", false);
// Compute the current gradients:
outputString.AddShaderChunk(precision + "2 " + " texcoords_per_size = texcoord * height_map_dimensions;", false);
// Compute all 4 derivatives in x and y in a single instruction to optimize:
outputString.AddShaderChunk("float2 dx, dy;", false);
outputString.AddShaderChunk(" float4 temp_ddx = ddx(float4(texcoords_per_size, texcoord));", false);
outputString.AddShaderChunk("dx.xy = temp_ddx.zw;", false);
outputString.AddShaderChunk("float4 temp_ddy = ddy(float4(texcoords_per_size, texcoord));", false);
outputString.AddShaderChunk("dy.xy = temp_ddy.zw;", false);
// Start the current sample located at the input texture coordinate, which would correspond
// to computing a bump mapping result:
outputString.AddShaderChunk(precision + "2 " + "result_texcoord = texcoord;", false);
outputString.AddShaderChunk("float height_scale_value = heightScale;", false);
outputString.AddShaderChunk("float height_scale_adjust = height_scale_value;", false);
outputString.AddShaderChunk("float per_pixel_height_scale_value = height_scale_value * heightScale;", false);
// Parallax occlusion mapping offset computation
//--------------
// Utilize dynamic flow control to change the number of samples per ray
// depending on the viewing angle for the surface. Oblique angles require
// smaller step sizes to achieve more accurate precision for computing displacement.
// We express the sampling rate as a linear function of the angle between
// the geometric normal and the view direction ray:
outputString.AddShaderChunk("float max_samples = 30.0f;", false);
outputString.AddShaderChunk("float min_samples = 4.0f;", false);
outputString.AddShaderChunk("float view_dot_normal= dot(worldSpaceNormal, worldSpaceViewDirection);", false);
outputString.AddShaderChunk("int number_of_steps = (int)lerp(max_samples, min_samples, saturate(view_dot_normal));", false);
// Intersect the view ray with the height field profile along the direction of
// the parallax offset ray (computed in the vertex shader. Note that the code is
// designed specifically to take advantage of the dynamic flow control constructs
// in HLSL and is very sensitive to specific syntax. When converting to other examples,
// if still want to use dynamic flow control in the resulting assembly shader,
// care must be applied.
//
// In the below steps we approximate the height field profile as piecewise linear
// curve. We find the pair of endpoints between which the intersection between the
// height field profile and the view ray is found and then compute line segment
// intersection for the view ray and the line segment formed by the two endpoints.
// This intersection is the displacement offset from the original texture coordinate.
// See the above SI3D 06 paper for more details about the process and derivation.
//
outputString.AddShaderChunk("float current_height = 0.0;", false);
outputString.AddShaderChunk("float step_size = 1.0 / (float)number_of_steps;", false);
outputString.AddShaderChunk("float previous_height = 1.0;", false);
outputString.AddShaderChunk("float next_height = 0.0;", false);
outputString.AddShaderChunk("int step_index = 0;", false);
// Optimization: this should move to vertex shader, however, we compute it here for simplicity of
// integration into our shaders for now.
outputString.AddShaderChunk("float3 normalized_view_dir_in_tangent_space = normalize(viewTangentSpace.xyz);", false);
// Compute initial parallax displacement direction:
outputString.AddShaderChunk("float2 parallax_direction = normalize(viewTangentSpace.xy);", false);
// The length of this vector determines the furthest amount of displacement:
outputString.AddShaderChunk("float parallax_direction_length = length(normalized_view_dir_in_tangent_space);", false);
outputString.AddShaderChunk(
"float max_parallax_amount = sqrt(parallax_direction_length * parallax_direction_length - viewTangentSpace.z * viewTangentSpace.z) / viewTangentSpace.z;", false);
// Compute the actual reverse parallax displacement vector:
outputString.AddShaderChunk("float2 parallax_offset_in_tangent_space = parallax_direction * max_parallax_amount;", false);
// Need to scale the amount of displacement to account for different height ranges
// in height maps. This is controlled by an artist-editable parameter:
outputString.AddShaderChunk("parallax_offset_in_tangent_space *= saturate(heightScale);", false);
outputString.AddShaderChunk("float2 texcoord_offset_per_step = step_size * parallax_offset_in_tangent_space;", false);
outputString.AddShaderChunk(precision + "2 " + "current_texcoord_offset = texcoord;", false);
outputString.AddShaderChunk("float current_bound = 1.0;", false);
outputString.AddShaderChunk("float current_parallax_amount = 0.0;", false);
outputString.AddShaderChunk("float2 pt1 = 0;", false);
outputString.AddShaderChunk("float2 pt2 = 0;", false);
outputString.AddShaderChunk(precision + "2 " + "temp_texcoord_offset = 0;", false);
outputString.AddShaderChunk("while (step_index < number_of_steps)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("current_texcoord_offset -= texcoord_offset_per_step;", false);
// Sample height map which in this case is stored in the alpha channel of the normal map:
outputString.AddShaderChunk("current_height = tex2Dgrad(tex, current_texcoord_offset, dx, dy).r;", false);
outputString.AddShaderChunk("current_bound -= step_size;", false);
outputString.AddShaderChunk("if (current_height > current_bound)", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("pt1 = float2(current_bound, current_height);", false);
outputString.AddShaderChunk("pt2 = float2(current_bound + step_size, previous_height);", false);
outputString.AddShaderChunk("temp_texcoord_offset = current_texcoord_offset - texcoord_offset_per_step;", false);
outputString.AddShaderChunk("step_index = number_of_steps + 1;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("else", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("step_index++;", false);
outputString.AddShaderChunk("previous_height = current_height;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.Deindent();
outputString.AddShaderChunk("} // End of while ( step_index < number_of_steps)", false);
outputString.AddShaderChunk("float delta2 = pt2.x - pt2.y;", false);
outputString.AddShaderChunk("float delta1 = pt1.x - pt1.y;", false);
outputString.AddShaderChunk("float denominator = delta2 - delta1;", false);
// SM 3.0 and above requires a check for divide by zero since that operation
// will generate an 'Inf' number instead of 0
outputString.AddShaderChunk("if (denominator== 0.0f) ", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("current_parallax_amount= 0.0f;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("else", false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("current_parallax_amount= (pt1.x* delta2 - pt2.x* delta1) / denominator;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("float2 parallax_offset = parallax_offset_in_tangent_space * (1.0f - current_parallax_amount);", false);
// The computed texture offset for the displaced point on the pseudo-extruded surface:
outputString.AddShaderChunk("float2 parallaxed_texcoord = texcoord - parallax_offset;", false);
outputString.AddShaderChunk("return parallaxed_texcoord;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
protected virtual string GetFunctionCallBody(string heightScale, string texValue)
{
var channel = UVChannel.uv0;
return GetFunctionName() + " (" +
heightScale + ", " +
texValue + ", " +
channel.GetUVName() + ", " +
ShaderGeneratorNames.TangentSpaceViewDirection + ", " +
ShaderGeneratorNames.WorldSpaceNormal + ", " +
ShaderGeneratorNames.WorldSpaceViewDirection + ")";
}
public bool RequiresMeshUV(UVChannel channel)
{
return channel == UVChannel.uv0;
}
public bool RequiresViewDirectionTangentSpace()
{
return true;
}
public bool RequiresNormal()
{
return true;
}
public bool RequiresViewDirection()
{
return true;
}
}
}

12
MaterialGraphProject/Assets/NewNodes/WIP/POMNode.cs.meta


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

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

9
MaterialGraphProject/Assets/POM_Graph.ShaderGraph.meta


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

9
MaterialGraphProject/Assets/Rinaldo/DemoScene.meta


fileFormatVersion: 2
guid: f413b728b2f6460418512648f4132898
folderAsset: yes
timeCreated: 1495695266
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

1001
MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif
文件差异内容过多而无法显示
查看文件

84
MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif.meta


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

21
MaterialGraphProject/Assets/TestAssets/TangentMap1.jpg

之前 之后
宽度: 187  |  高度: 187  |  大小: 6.5 KiB

75
MaterialGraphProject/Assets/TestAssets/TangentMap1.jpg.meta


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

33
MaterialGraphProject/Assets/TestAssets/TangentMap2.jpg

之前 之后
宽度: 187  |  高度: 187  |  大小: 8.7 KiB

75
MaterialGraphProject/Assets/TestAssets/TangentMap2.jpg.meta


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

12
MaterialGraphProject/Assets/TestAssets/TangentMap3.jpg

之前 之后
宽度: 187  |  高度: 187  |  大小: 4.4 KiB

75
MaterialGraphProject/Assets/TestAssets/TangentMap3.jpg.meta


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

151
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine.MaterialGraph;
using UnityEngine;
namespace UnityEditor.MaterialGraph.Drawing
{
class ConvolutionFilterControlPresenter : GraphControlPresenter
{
enum KernelPresets
{
Presets,
BoxBlur,
GaussianBlur,
EdgesDetection,
EnhanceEdges,
Sharpen,
Emboss,
};
private void ApplyPreset(KernelPresets preset, ref float[,] values, ref float divisor)
{
if (preset == KernelPresets.BoxBlur)
{
values = new float[,] { {1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,1} };
divisor = 25;
}
if (preset == KernelPresets.GaussianBlur)
{
values = new float[,] { { 1, 4, 6, 4, 1},
{ 4,16,24,16, 4},
{ 6,24,36,24, 6},
{ 4,16,24,16, 4},
{ 1, 4, 6, 4, 1} };
divisor = 256;
}
if (preset == KernelPresets.EdgesDetection)
{
values = new float[,] { {-1,-1,-1, -1,-1},
{-1,-2,-2, -2,-1},
{-1,-2, 33,-2,-1},
{-1,-2,-2, -2,-1},
{-1,-1,-1, -1,-1} };
divisor = 1;
}
if (preset == KernelPresets.EnhanceEdges)
{
values = new float[,] { { 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 0},
{ 0, 1,-7, 1, 0},
{ 0, 1, 1, 1, 0},
{ 0, 0, 0, 0, 0} };
divisor = 1;
}
if (preset == KernelPresets.Sharpen)
{
values = new float[,] { {-1,-1,-1, -1,-1},
{-1, 2, 2, 2,-1},
{-1, 2, 8, 2,-1},
{-1, 2, 2, 2,-1},
{-1,-1,-1, -1,-1} };
divisor = 8;
}
if (preset == KernelPresets.Emboss)
{
values = new float[,] { {-1,-1,-1,-1, 0},
{-1,-1,-1, 0, 1},
{-1,-1, 0, 1, 1},
{-1, 0, 1, 1, 1},
{ 0, 1, 1, 1, 1} };
divisor = 1;
}
}
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as ConvolutionFilterNode;
if (tNode == null)
return;
float divisor = tNode.GetConvolutionDivisor();
float[,] values = new float[5,5];
for (int row = 0; row < 5; ++row)
{
for (int col = 0; col < 5; ++col)
{
values[row,col] = tNode.GetConvolutionWeight(row,col);
}
}
EditorGUILayout.BeginVertical();
EditorGUI.BeginChangeCheck();
EditorGUILayout.LabelField("Kernel");
KernelPresets kernelPresets = KernelPresets.Presets;
kernelPresets = (KernelPresets)EditorGUILayout.EnumPopup(kernelPresets);
ApplyPreset(kernelPresets, ref values, ref divisor);
for (int col = 0; col < 5; ++col)
{
EditorGUILayout.BeginHorizontal();
for (int row = 0; row < 5; ++row)
{
values[row, col] = EditorGUILayout.FloatField(values[row, col], GUILayout.Width(35));
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.Space();
divisor = EditorGUILayout.FloatField("Divisor", divisor);
EditorGUILayout.EndVertical();
if (EditorGUI.EndChangeCheck())
{
tNode.SetConvolutionDivisor(divisor);
for (int row = 0; row < 5; ++row)
{
for (int col = 0; col < 5; ++col)
{
tNode.SetConvolutionWeight(row, col, values[row, col]);
}
}
}
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight * 10 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class ConvolutionFilterNodePresenter : PropertyNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<ConvolutionFilterControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter>(base.GetControlData()) { instance };
}
}
}

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


fileFormatVersion: 2
guid: f3a416c372d21b6479241e837d4257da
timeCreated: 1495705790
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:

64
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/SamplerStatePresenter.cs


using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class SamplerStateControlPresenter : GraphControlPresenter
{
private string[] samplerFilterMode;
private string[] samplerWrapMode;
private string[] _samplerFilterMode
{
get
{
if (samplerFilterMode == null)
samplerFilterMode = Enum.GetNames(typeof(SamplerStateNode.FilterMode));
return samplerFilterMode;
}
}
private string[] _samplerWrapMode
{
get
{
if (samplerWrapMode == null)
samplerWrapMode = Enum.GetNames(typeof(SamplerStateNode.WrapMode));
return samplerWrapMode;
}
}
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as UnityEngine.MaterialGraph.SamplerStateNode;
if (cNode == null)
return;
cNode.filter = (SamplerStateNode.FilterMode)EditorGUILayout.Popup((int)cNode.filter, _samplerFilterMode, EditorStyles.popup);
cNode.wrap = (SamplerStateNode.WrapMode)EditorGUILayout.Popup((int)cNode.wrap, _samplerWrapMode, EditorStyles.popup);
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class SamplerStateNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<SamplerStateControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

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


fileFormatVersion: 2
guid: 8ffcc48ccff1aea44b90acb362bc0dfc
timeCreated: 1495659152
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:

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


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
class TextureSamplerContolPresenter : GraphControlPresenter
{
private string[] m_TextureTypeNames;
private string[] textureTypeNames
{
get
{
if (m_TextureTypeNames == null)
m_TextureTypeNames = Enum.GetNames(typeof(TextureType));
return m_TextureTypeNames;
}
}
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as UnityEngine.MaterialGraph.TextureAssetNode;
if (tNode == null)
return;
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture), null) as Texture;
tNode.textureType = (TextureType)EditorGUILayout.Popup((int)tNode.textureType, textureTypeNames, EditorStyles.popup);
}
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class TextureSamplerNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<TextureSamplerContolPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

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


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

445
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_height.png

之前 之后
宽度: 256  |  高度: 256  |  大小: 76 KiB

75
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_height.png.meta


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

137
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga
文件差异内容过多而无法显示
查看文件

75
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga.meta


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

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp
文件差异内容过多而无法显示
查看文件

75
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp.meta


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

52
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/tesselationSubshader.template


SubShader
{
${Tags}
${Blending}
${Culling}
${ZTest}
${ZWrite}
LOD ${LOD}
CGPROGRAM
#include "Tessellation.cginc"
#pragma target 4.6
#pragma surface surf ${LightingFunctionName} ${VertexShaderDecl} vertex:Displacement tessellate:tessEdge tessphong:_Phong
#pragma glsl
#pragma debug
//Tessellation Edge Function
float4 tessEdge(appdata v0, appdata v1, appdata v2)
{
float quality = 20-(_Subdivision * 2);
return UnityEdgeLengthBasedTess(v0.vertex, v1.vertex, v2.vertex, quality);
}
//Tessellation Vertex Function
void Displacement (inout appdata v)
{
float d = tex2Dlod(_DisplacementTex, float4(v.texcoord.xy * (_DisplacementTex_ST.xy * float2(_WeaveScale*25, _WeaveScale*25)) + _DisplacementTex_ST.zw, 0, 0)).r * _Displacement*0.1;
v.vertex.xyz += v.normal * (d * 0.5);
}
${ShaderFunctions}
${ShaderPropertyUsages}
struct Input
{
${ShaderInputs}
};
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
${VertexShaderBody}
}
void surf (Input IN, inout ${SurfaceOutputStructureName} o)
{
${PixelShaderBody}
}
ENDCG
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/tesselationSubshader.template.meta


fileFormatVersion: 2
guid: 71a3d46ddb1693340a7de3973be90309
timeCreated: 1481194716
licenseType: Pro
DefaultImporter:
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:

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:

35
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraDirNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Scene Data/Camera Direction")]
public class CamDirNode : AbstractMaterialNode
{
public CamDirNode()
{
name = "CameraDirection";
UpdateNodeAfterDeserialization();
}
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Output";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview2D; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override string GetVariableNameForSlot(int slotId)
{
return "UNITY_MATRIX_IT_MV [2].xyz";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraDirNode.cs.meta


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

36
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraPosNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Scene Data/Camera Position")]
public class CamPosNode : AbstractMaterialNode
{
//TODO - should be a global and immpiment a Imayrequire
public CamPosNode()
{
name = "CameraPosition";
UpdateNodeAfterDeserialization();
}
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Output";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview2D; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override string GetVariableNameForSlot(int slotId)
{
return "_WorldSpaceCameraPos";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraPosNode.cs.meta


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

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:

133
MaterialGraphProject/Assets/Vlad/SamplerStateNode.cs


using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Sampler State")]
public class SamplerStateNode : AbstractMaterialNode, IGeneratesBodyCode
{
public enum FilterMode
{
Linear,
Point
}
public enum WrapMode
{
Repeat,
Clamp
}
static Dictionary<FilterMode, string> filterMode = new Dictionary<FilterMode, string>
{
{FilterMode.Linear, "_linear"},
{FilterMode.Point, "_point"},
};
static Dictionary<WrapMode, string> wrapMode = new Dictionary<WrapMode, string>
{
{WrapMode.Repeat, "_repeat"},
{WrapMode.Clamp, "_clamp"},
};
[SerializeField]
private FilterMode m_filter = FilterMode.Linear;
public FilterMode filter
{
get { return m_filter; }
set
{
if (m_filter == value)
return;
m_filter = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
[SerializeField]
private WrapMode m_wrap = WrapMode.Repeat;
public WrapMode wrap
{
get { return m_wrap; }
set
{
if (m_wrap == value)
return;
m_wrap = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public SamplerStateNode()
{
name = "SamplerState";
UpdateNodeAfterDeserialization();
}
public override bool hasPreview { get { return false; } }
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Sampler Output";
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.SamplerState, Vector4.zero, false));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
/*
public override PropertyType propertyType
{
get { return PropertyType.SamplerState; }
}
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName + "HEEEEEEYYYYY",
m_PropType = PropertyType.Float,
// m_Float = filterMode[filter];
};
}
*/
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
// GetVariableNameForSlot();
}
public override string GetVariableNameForSlot(int slotId)
{
// var slot = FindSlot<MaterialSlot>(slotId);
//if (slot == null)
// throw new ArgumentException(string.Format("Attempting to use MaterialSlot({0}) on node of type {1} where this slot can not be found", slotId, this), "slotId");
return GetVariableNameForNode();
}
//my_linear_repeat_sampler
public override string GetVariableNameForNode()
{
return "my" + filterMode[filter] + wrapMode[wrap] + "_sampler";
}
}
}

12
MaterialGraphProject/Assets/Vlad/SamplerStateNode.cs.meta


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

246
MaterialGraphProject/Assets/Vlad/TextureSamplerNode.cs


using System;
using System.Collections.Generic;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Texture/Texture Sampler")]
public class TextureSamplerNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV
{
private const string kTextureAssetName = "Texture Asset";
private const string kUVSlotName = "UV";
private const string kSamplerName = "Sampler";
protected const string kOutputSlotRGBAName = "RGBA";
public const int TextureAssetSlotId = 0;
public const int UVSlotId = 1;
public const int SamplerSlotId = 2;
public const int OutputSlotRGBAId = 3;
[SerializeField]
private string m_SerializedTexture;
[SerializeField]
private TextureType m_TextureType;
[Serializable]
private class TextureHelper
{
public Texture2D texture;
}
public override bool hasPreview { get { return true; } }
#if UNITY_EDITOR
public Texture2D defaultTexture
{
get
{
if (string.IsNullOrEmpty(m_SerializedTexture))
return null;
var tex = new TextureHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, tex);
return tex.texture;
}
set
{
if (defaultTexture == value)
return;
var tex = new TextureHelper();
tex.texture = value;
m_SerializedTexture = EditorJsonUtility.ToJson(tex, true);
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
}
}
#else
public Texture2D defaultTexture {get; set; }
#endif
public TextureType textureType
{
get { return m_TextureType; }
set
{
if (m_TextureType == value)
return;
m_TextureType = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public TextureSamplerNode()
{
name = "TextureSamplerNode";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(TextureAssetSlotId, kTextureAssetName, kTextureAssetName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero, false));
AddSlot(new MaterialSlot(UVSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero, false));
AddSlot(new MaterialSlot(SamplerSlotId, kSamplerName, kSamplerName, SlotType.Input, SlotValueType.SamplerState, Vector4.zero, false));
AddSlot(new MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { OutputSlotRGBAId, SamplerSlotId, UVSlotId, TextureAssetSlotId }; }
}
// Node generations
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
//Texture input slot
var textureSlot = FindInputSlot<MaterialSlot>(TextureAssetSlotId);
var textureAssetName = "";
var edgesTexture = owner.GetEdges(textureSlot.slotReference).ToList();
if (edgesTexture.Count > 0)
{
var edge = edgesTexture[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
textureAssetName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Texture2D, true);
}
//UV input slot
var uvSlot = FindInputSlot<MaterialSlot>(UVSlotId);
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName());
if (uvSlot == null)
return;
var edgesUV = owner.GetEdges(uvSlot.slotReference).ToList();
if (edgesUV.Count > 0)
{
var edge = edgesUV[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
uvName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Vector2, true);
}
//Sampler input slot
var samplerSlot = FindInputSlot<MaterialSlot>(SamplerSlotId);
var samplerName = "my_linear_repeat_sampler";
if (samplerSlot == null)
return;
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList();
if (edgesSampler.Count > 0)
{
var edge = edgesSampler[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true);
}
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + "_Uniform = " + precision + "4(0,0,0,0);", true);
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", true);
string body = textureAssetName + ".Sample(" + samplerName + ", " + uvName + ");";
if (m_TextureType == TextureType.Bump)
body = precision + "4(UnpackNormal(" + body + "), 0)";
visitor.AddShaderChunk(GetVariableNameForNode() + "_Uniform" + " = " + body, true);
visitor.AddShaderChunk("#endif", true);
}
// Properties
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{ /*
visitor.AddShaderProperty(
new TexturePropertyChunk(
propertyName,
description,
defaultTexture, m_TextureType,
PropertyChunk.HideState.Visible,
exposedState == ExposedState.Exposed ?
TexturePropertyChunk.ModifiableState.Modifiable
: TexturePropertyChunk.ModifiableState.NonModifiable));
*/
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
//Sampler input slot
var samplerSlot = FindInputSlot<MaterialSlot>(SamplerSlotId);
var samplerName = "my_linear_repeat_sampler";
if (samplerSlot == null)
return;
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList();
if (edgesSampler.Count > 0)
{
var edge = edgesSampler[0];
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true);
}
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false);
visitor.AddShaderChunk(samplerSlot.valueType + " " + samplerName + ";", true);
visitor.AddShaderChunk("#endif", false);
}
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture,
m_Texture = defaultTexture
};
}
public override PropertyType propertyType { get { return PropertyType.Texture; } }
public bool RequiresMeshUV(UVChannel channel)
{
if (channel != UVChannel.uv0)
{
return false;
}
var uvSlot = FindInputSlot<MaterialSlot>(UVSlotId);
if (uvSlot == null)
return true;
var edges = owner.GetEdges(uvSlot.slotReference).ToList();
return edges.Count == 0;
}
//prevent validation errors when a sampler2D input is missing
//use on any input requiring a TextureAssetNode
public override void ValidateNode()
{
base.ValidateNode();
var slot = FindInputSlot<MaterialSlot>(TextureAssetSlotId);
if (slot == null)
return;
var edges = owner.GetEdges(slot.slotReference).ToList();
hasError |= edges.Count == 0;
}
}
}

12
MaterialGraphProject/Assets/Vlad/TextureSamplerNode.cs.meta


fileFormatVersion: 2
guid: 5ca9d434229e11f44888abcbf66062a5
timeCreated: 1495637741
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:

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

正在加载...
取消
保存