浏览代码

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

/main
Jennifer Nordwall 7 年前
当前提交
475f5e3b
共有 282 个文件被更改,包括 2305 次插入1838 次删除
  1. 2
      MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs
  2. 1
      MaterialGraphProject/Assets/Eduardo/ConstantsNode.cs
  3. 2
      MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
  4. 931
      MaterialGraphProject/Assets/GeneratedShader.shader
  5. 22
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs
  6. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs
  7. 4
      MaterialGraphProject/Assets/GraphView/Editor.meta
  8. 40
      MaterialGraphProject/Assets/Matt/AbstractAdvancedMasterNode.cs
  9. 2
      MaterialGraphProject/Assets/Matt/AnisotropicMaster.ShaderGraph
  10. 14
      MaterialGraphProject/Assets/Matt/AnisotropicMetallicMasterNode.cs
  11. 2
      MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph
  12. 10
      MaterialGraphProject/Assets/Matt/SubsurfaceMetallicMasterNode.cs
  13. 14
      MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs
  14. 2
      MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs
  15. 2
      MaterialGraphProject/Assets/Rinaldo/Editor/BlendModeNodePresenter.cs
  16. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs
  17. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ColorNodePresenter.cs
  18. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  19. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs
  20. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureAssetPresenter.cs
  21. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureLODNodePresenter.cs
  22. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureNodePresenter.cs
  23. 49
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Vector1NodePresenter.cs
  24. 104
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
  25. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
  26. 32
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/ExportTexture.template
  27. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/PropertyNodeTests.cs
  28. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyChunkTests.cs
  29. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs
  30. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  31. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
  32. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/DepthTextureNode.cs
  33. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/MotionVectorTextureNode.cs
  34. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/CubemapNode.cs
  35. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureLODNode.cs
  36. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureNode.cs
  37. 54
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs
  38. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
  39. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
  40. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PreviewProperty.cs
  41. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs
  42. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
  43. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs
  44. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SlotValue.cs
  45. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/CartesianToPolarNode.cs
  46. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVTileNode.cs
  47. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MaterialSubGraphAsset.cs
  48. 110
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
  49. 61
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/ExportTextureMasterNode.cs
  50. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/MetallicMasterNode.cs
  51. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/SpecularMasterNode.cs
  52. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs
  53. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs
  54. 10
      MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs
  55. 62
      MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs
  56. 180
      MaterialGraphProject/ProjectSettings/ProjectSettings.asset
  57. 8
      MaterialGraphProject/Assets/Andre/Scenes/Andre_scene.unity
  58. 23
      MaterialGraphProject/Assets/Andre/Materials/Mat.mat
  59. 9
      MaterialGraphProject/Assets/Andre/Materials/Sky.mat
  60. 7
      MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs
  61. 102
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs
  62. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs
  63. 998
      MaterialGraphProject/Assets/Andre/Scenes/EmissionTest/LightingData.asset
  64. 4
      MaterialGraphProject/Assets/Andre/Scenes/LightProbeTesting/ReflectionProbe-0.exr.meta
  65. 9
      MaterialGraphProject/Assets/Andre/Materials.meta
  66. 9
      MaterialGraphProject/Assets/Andre/Nodes.meta
  67. 9
      MaterialGraphProject/Assets/Andre/Scenes.meta
  68. 9
      MaterialGraphProject/Assets/Andre/Scripts.meta
  69. 9
      MaterialGraphProject/Assets/Andre/Shaders.meta
  70. 1
      MaterialGraphProject/Assets/Brandon/Electricity.ShaderGraph
  71. 9
      MaterialGraphProject/Assets/Brandon/Electricity.ShaderGraph.meta
  72. 1
      MaterialGraphProject/Assets/Brandon/Flame.ShaderGraph
  73. 9
      MaterialGraphProject/Assets/Brandon/Flame.ShaderGraph.meta
  74. 1
      MaterialGraphProject/Assets/Code Graph.ShaderGraph
  75. 9
      MaterialGraphProject/Assets/Code Graph.ShaderGraph.meta
  76. 83
      MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat
  77. 9
      MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat.meta
  78. 20
      MaterialGraphProject/Assets/Eduardo/ReciprocalSqrtNode.cs
  79. 12
      MaterialGraphProject/Assets/Eduardo/ReciprocalSqrtNode.cs.meta
  80. 64
      MaterialGraphProject/Assets/Eduardo/VertexNormalNode.cs
  81. 12
      MaterialGraphProject/Assets/Eduardo/VertexNormalNode.cs.meta
  82. 64
      MaterialGraphProject/Assets/Eduardo/VertexPositionNode.cs
  83. 12
      MaterialGraphProject/Assets/Eduardo/VertexPositionNode.cs.meta
  84. 363
      MaterialGraphProject/Assets/Eduardo/eduardoScene.unity
  85. 8
      MaterialGraphProject/Assets/Eduardo/eduardoScene.unity.meta
  86. 1
      MaterialGraphProject/Assets/Matt/ClothMaster.ShaderGraph
  87. 9
      MaterialGraphProject/Assets/Matt/ClothMaster.ShaderGraph.meta
  88. 101
      MaterialGraphProject/Assets/Matt/ClothMasterNode.cs
  89. 12
      MaterialGraphProject/Assets/Matt/ClothMasterNode.cs.meta
  90. 14
      MaterialGraphProject/Assets/Matt/CommonMatrixType.cs
  91. 12
      MaterialGraphProject/Assets/Matt/CommonMatrixType.cs.meta
  92. 9
      MaterialGraphProject/Assets/Matt/Examples.meta
  93. 9
      MaterialGraphProject/Assets/Matt/Eye.meta

2
MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("ChannelBlend")]
[Title("Art/ChannelBlend")]
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction
{

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

931
MaterialGraphProject/Assets/GeneratedShader.shader


Shader "Graph/Generated.AnisotropicMetallicMasterNoded3249a79-099e-4f35-8185-c418a23965c8"
{
Properties
{
Shader "Hidden/PreviewShader/Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output" {
Properties {
Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform("", Float) = 0.1
SubShader
{
SubShader {
// inside SubShader
"Queue"="Geometry"
"Queue"="Geometry"
"IgnoreProjector"="True"
Blend One Zero
Cull Back
ZTest LEqual
// inside Pass
LOD 200
CGPROGRAM
#include "UnityCG.cginc"
//#include "AdvancedBRDF.cginc"
//#include "AdvancedShading.cginc"
//#include "AdvancedLighting.cginc"
#define SHADINGMODELID_STANDARD
// ------------------------------------------------------------------
// Diffuse
// From UE4 - Used for Cloth (Deprecated)
float3 Diffuse_Lambert(float3 DiffuseColor)
{
return DiffuseColor * (1 / UNITY_PI);
}
// ------------------------------------------------------------------
// Fresnel
// From UE4 - Used for Cloth
// [Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering"]
float3 F_Schlick(float3 SpecularColor, float VoH)
{
float Fc = Pow5(1 - VoH); // 1 sub, 3 mul
//return Fc + (1 - Fc) * SpecularColor; // 1 add, 3 mad
// Anything less than 2% is physically impossible and is instead considered to be shadowing
return saturate(50.0 * SpecularColor.g) * Fc + (1 - Fc) * SpecularColor;
}
// ------------------------------------------------------------------
// Distribution
// From UE4 - USed for Cloth
// GGX / Trowbridge-Reitz
// [Walter et al. 2007, "Microfacet models for refraction through rough surfaces"]
float D_GGX(float roughness, float NdotH)
{
float a = roughness * roughness;
float a2 = a * a;
float d = (NdotH * a2 - NdotH) * NdotH + 1; // 2 mad
return a2 / (UNITY_PI*d*d); // 4 mul, 1 rcp
}
// Anisotropic GGX
// Taken from HDRenderPipeline
float D_GGXAnisotropic(float TdotH, float BdotH, float NdotH, float roughnessT, float roughnessB)
{
float f = TdotH * TdotH / (roughnessT * roughnessT) + BdotH * BdotH / (roughnessB * roughnessB) + NdotH * NdotH;
return 1.0 / (roughnessT * roughnessB * f * f);
}
// From UE4 - Used for Cloth
float D_InvGGX(float roughness, float NdotH)
{
float a = roughness * roughness;
float a2 = a * a;
float A = 4;
float d = (NdotH - a2 * NdotH) * NdotH + a2;
return 1/(UNITY_PI * (1 + A*a2)) * (1 + 4 * a2*a2 / (d*d)); //RCP
}
// ------------------------------------------------------------------
// Visibility
// From UE4 - Used for Cloth
// Appoximation of joint Smith term for GGX
// [Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"]
float Vis_SmithJointApprox(float Roughness, float NoV, float NoL)
{
float a = (Roughness*Roughness);
float Vis_SmithV = NoL * (NoV * (1 - a) + a);
float Vis_SmithL = NoV * (NoL * (1 - a) + a);
// Note: will generate NaNs with Roughness = 0. MinRoughness is used to prevent this
return 0.5 * 1/(Vis_SmithV + Vis_SmithL); //RCP
}
// From UE4 - Used for Cloth
float Vis_Cloth(float NoV, float NoL)
{
return 1/(4 * (NoL + NoV - NoL * NoV)); //RCP
}
// ------------------------------------------------------------------
// SORT THESE
// Smith Joint GGX Anisotropic Visibility
// Taken from https://cedec.cesa.or.jp/2015/session/ENG/14698.html
float SmithJointGGXAnisotropic(float TdotV, float BdotV, float NdotV, float TdotL, float BdotL, float NdotL, float roughnessT, float roughnessB)
{
float aT = roughnessT;
float aT2 = aT * aT;
float aB = roughnessB;
float aB2 = aB * aB;
float lambdaV = NdotL * sqrt(aT2 * TdotV * TdotV + aB2 * BdotV * BdotV + NdotV * NdotV);
float lambdaL = NdotV * sqrt(aT2 * TdotL * TdotL + aB2 * BdotL * BdotL + NdotL * NdotL);
return 0.5 / (lambdaV + lambdaL);
}
// Convert Anistropy to roughness
void ConvertAnisotropyToRoughness(float roughness, float anisotropy, out float roughnessT, out float roughnessB)
{
// (0 <= anisotropy <= 1), therefore (0 <= anisoAspect <= 1)
// The 0.9 factor limits the aspect ratio to 10:1.
float anisoAspect = sqrt(1.0 - 0.9 * anisotropy);
roughnessT = roughness / anisoAspect; // Distort along tangent (rougher)
roughnessB = roughness * anisoAspect; // Straighten along bitangent (smoother)
}
// Schlick Fresnel
float FresnelSchlick(float f0, float f90, float u)
{
float x = 1.0 - u;
float x5 = x * x;
x5 = x5 * x5 * x;
return (f90 - f0) * x5 + f0; // sub mul mul mul sub mad
}
//Clamp roughness
float ClampRoughnessForAnalyticalLights(float roughness)
{
return max(roughness, 0.000001);
}
//Calculate tangent warp for IBL (Reference Version - not used)
float3 SpecularGGXIBLRef(float3 viewDir, float3 normalDir, float3 tangentDir, float3 bitangentDir, float roughnessT, float roughnessB)
{
return float3(1, 1, 1);
//Hidden in UnityAnisotropicLighting.cginc
}
// Sample Anisotropic Direction for IBL (Reference Version - not used)
void SampleAnisoGGXDir(float2 u, float3 viewDir, float3 normalDir, float3 tangent, float3 bitangent, float roughnessT, float roughnessB, out float3 halfDir, out float3 lightDir)
{
// AnisoGGX NDF sampling
halfDir = sqrt(u.x / (1.0 - u.x)) * (roughnessT * cos((UNITY_PI * 2) * u.y) * tangent + roughnessB * sin((UNITY_PI * 2) * u.y) * bitangent) + normalDir;
halfDir = normalize(halfDir);
// Convert sample from half angle to incident angle
lightDir = 2.0 * saturate(dot(viewDir, halfDir)) * halfDir - viewDir;
}
// Ref: Donald Revie - Implementing Fur Using Deferred Shading (GPU Pro 2)
// The grain direction (e.g. hair or brush direction) is assumed to be orthogonal to the normal.
// The returned normal is NOT normalized.
float3 ComputeGrainNormal(float3 grainDir, float3 V)
{
float3 B = cross(-V, grainDir);
return cross(B, grainDir);
}
//Modify Normal for Anisotropic IBL (Realtime version)
// Fake anisotropic by distorting the normal.
// The grain direction (e.g. hair or brush direction) is assumed to be orthogonal to N.
// Anisotropic ratio (0->no isotropic; 1->full anisotropy in tangent direction)
float3 GetAnisotropicModifiedNormal(float3 grainDir, float3 N, float3 V, float anisotropy)
{
float3 grainNormal = ComputeGrainNormal(grainDir, V);
// TODO: test whether normalizing 'grainNormal' is worth it.
return normalize(lerp(N, grainNormal, anisotropy));
}
/// REGION END - ANISOTROPY
/// REGION START - SUBSURFACE SCATTERING
half Fresnel(half3 H, half3 V, half F0)
{
half base = 1.0 - dot(V, H);
half exponential = pow(base, 5.0);
return exponential + F0 * (1.0 - exponential);
}
/*
inline half3 KelemenSzirmayKalosSpecular(half3 normal, half3 lightDir, half3 viewDir, float roughness, float rho_s)
{
half3 result = half3(0, 0, 0);
half NdotL = dot(normal, lightDir);
if (NdotL > 0.0)
{
half3 h = lightDir + viewDir;
half3 H = normalize(h);
half NdotH = dot(normal, H);
half PH = pow(2.0 * tex2D(_BeckmannPrecomputedTex, half2(NdotH, roughness)).r, 10.0);
half F = Fresnel(H, viewDir, 0.028);
half frSpec = max(PH * F / dot(h, h), 0);
half term = NdotL * rho_s * frSpec;
result = half3(term, term, term);
}
return result;
}*/
/*
half3 SkinDiffuse(float curv, float3 NdotL)
{
float3 lookup = NdotL * 0.5 + 0.5;
float3 diffuse;
diffuse.r = tex2D(_DiffusionProfileTexture, float2(lookup.r, curv)).r;
diffuse.g = tex2D(_DiffusionProfileTexture, float2(lookup.g, curv)).g;
diffuse.b = tex2D(_DiffusionProfileTexture, float2(lookup.b, curv)).b;
return diffuse;
}*/
/// REGION END - SUBSURFACE SCATTERING
// Upgrade NOTE: replaced 'defined SHADINGMODELID_CLEARCOAT' with 'defined (SHADINGMODELID_CLEARCOAT)'
// Upgrade NOTE: replaced 'defined SHADINGMODELID_CLOTH' with 'defined (SHADINGMODELID_CLOTH)'
// Upgrade NOTE: replaced 'defined SHADINGMODELID_EYE' with 'defined (SHADINGMODELID_EYE)'
// Upgrade NOTE: replaced 'defined SHADINGMODELID_FOLIAGE' with 'defined (SHADINGMODELID_FOLIAGE)'
// Upgrade NOTE: replaced 'defined SHADINGMODELID_HAIR' with 'defined (SHADINGMODELID_HAIR)'
// Upgrade NOTE: replaced 'defined SHADINGMODELID_SKIN' with 'defined (SHADINGMODELID_SKIN)'
// Upgrade NOTE: replaced 'defined SHADINGMODELID_SUBSURFACE' with 'defined (SHADINGMODELID_SUBSURFACE)'
Blend One Zero
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
// ------------------------------------------------------------------
// Shading models
//#pragma multi_compile SHADINGMODELID_UNLIT SHADINGMODELID_STANDARD SHADINGMODELID_SUBSURFACE SHADINGMODELID_SKIN SHADINGMODELID_FOLIAGE SHADINGMODELID_CLEARCOAT SHADINGMODELID_CLOTH SHADINGMODELID_EYE
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25_normalDir;
float Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform;
// ------------------------------------------------------------------
// Input
half _ShadingModel;
struct v2f
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float3 worldNormal : TEXCOORD1;
sampler2D _AnisotropyMap;
half _Anisotropy;
sampler2D _TangentMap;
};
half4 _TranslucentColor;
sampler2D _TranslucencyMap;
sampler2D _FuzzTex;
half3 _FuzzColor;
half _Cloth;
inline float unity_posterize_float (float input, float stepsize)
{
return floor(input / stepsize) * stepsize;
}
sampler2D _IrisNormal;
sampler2D _IrisMask;
half _IrisDistance;
half _TDistortion;
half _TScale;
half _TAmbient;
half _TPower;
half _TAttenuation;
half _TransmissionOverallStrength;
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;
// ------------------------------------------------------------------
// Maths helpers
return o;
}
// Octahedron Normal Vectors
// [Cigolle 2014, "A Survey of Efficient Representations for Independent Unit Vectors"]
// Mean Max
// oct 8:8 0.33709 0.94424
// snorm 8:8:8 0.17015 0.38588
// oct 10:10 0.08380 0.23467
// snorm 10:10:10 0.04228 0.09598
// oct 12:12 0.02091 0.05874
float2 UnitVectorToOctahedron(float3 N)
{
N.xy /= dot(float3(1,1,1), abs(N));
if (N.z <= 0)
{
N.xy = (1 - abs(N.yx)) * (N.xy >= 0 ? float2(1, 1) : float2(-1, -1));
}
return N.xy;
}
float3 OctahedronToUnitVector(float2 Oct)
{
float3 N = float3(Oct, 1 - dot(float2(1,1), abs(Oct)));
if (N.z < 0)
{
N.xy = (1 - abs(N.yx)) * (N.xy >= 0 ? float2(1, 1) : float2(-1, -1));
}
return float3(1, 1, 1);
return normalize(N);
}
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);
// ------------------------------------------------------------------
// Surface helpers
half Anisotropy(float2 uv)
{
return tex2D(_AnisotropyMap, uv) * _Anisotropy;
}
half3 Fuzz(float2 uv)
{
return tex2D(_FuzzTex, uv) * _FuzzColor;
}
half Cloth()
{
return _Cloth;
}
half4 Iris(float2 uv)
{
float2 n = UnitVectorToOctahedron(normalize(UnpackNormal(tex2D(_IrisNormal, uv)).rgb)) * 0.5 + 0.5;
float m = saturate(tex2D(_IrisMask, uv).r); // Iris Mask
float d = saturate(_IrisDistance); // Iris Distance
return float4(n.x, n.y, m, d);
}
half3 Translucency(float2 uv)
{
return tex2D(_TranslucencyMap, uv).rgb * _TranslucentColor.rgb;
}
// ------------------------------------------------------------------
// Unlit Shading Function
float4 UnlitShading(float3 diffColor)
{
return half4(diffColor, 1);
}
// ------------------------------------------------------------------
// Standard Shading Function
float4 StandardShading(float3 diffColor, float3 specColor, float oneMinusReflectivity, float smoothness, float3 normal, float3x3 worldVectors,
float anisotropy, float metallic, float3 viewDir, UnityLight light, UnityIndirect gi)
{
//Unpack world vectors
float3 tangent = worldVectors[0];
float3 bitangent = worldVectors[1];
//Normal shift
float shiftAmount = dot(normal, viewDir);
normal = shiftAmount < 0.0f ? normal + viewDir * (-shiftAmount + 1e-5f) : normal;
//Regular vectors
float NdotL = saturate(dot(normal, light.dir)); //sat?
float NdotV = abs(dot(normal, viewDir)); //abs?
float LdotV = dot(light.dir, viewDir);
float3 H = Unity_SafeNormalize(light.dir + viewDir);
float invLenLV = rsqrt(abs(2 + 2 * normalize(LdotV)));
//float invLenLV = rsqrt(abs(2 + 2 * LdotV));
//float NdotH = (NdotL + normalize(NdotV)) * invLenLV;
float NdotH = saturate(dot(normal, H));
//float NdotH = saturate((NdotL + normalize(NdotV)) * invLenLV);
//float H = (light.dir + viewDir) * invLenLV;
float LdotH = saturate(dot(light.dir, H));
//Tangent vectors
float TdotH = dot(tangent, H);
float TdotL = dot(tangent, light.dir);
float BdotH = dot(bitangent, H);
float BdotL = dot(bitangent, light.dir);
float TdotV = dot(viewDir, tangent);
float BdotV = dot(viewDir, bitangent);
//Fresnels
half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
float3 F = FresnelLerp(specColor, grazingTerm, NdotV); //Original Schlick - Replace from SRP?
//float3 fresnel0 = lerp(specColor, diffColor, metallic);
//float3 F = FresnelSchlick(fresnel0, 1.0, LdotH);
//Calculate roughness
float roughnessT;
float roughnessB;
float perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
ConvertAnisotropyToRoughness(roughness, anisotropy, roughnessT, roughnessB);
//Clamp roughness
//roughness = ClampRoughnessForAnalyticalLights(roughness);
roughnessT = ClampRoughnessForAnalyticalLights(roughnessT);
roughnessB = ClampRoughnessForAnalyticalLights(roughnessB);
//Visibility & Distribution terms
float V = SmithJointGGXAnisotropic(TdotV, BdotV, NdotV, TdotL, BdotL, NdotL, roughnessT, roughnessB);
float D = D_GGXAnisotropic(TdotH, BdotH, NdotH, roughnessT, roughnessB);
//Specular term
float3 specularTerm = V * D; //*UNITY_PI;
# ifdef UNITY_COLORSPACE_GAMMA
specularTerm = sqrt(max(1e-4h, specularTerm));
# endif
// specularTerm * nl can be NaN on Metal in some cases, use max() to make sure it's a sane value
specularTerm = max(0, specularTerm * NdotL);
#if defined(_SPECULARHIGHLIGHTS_OFF)
specularTerm = 0.0;
#endif
//Diffuse term
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotH, perceptualRoughness) * NdotL;// - Need this NdotL multiply?
//Reduction
half surfaceReduction;
# ifdef UNITY_COLORSPACE_GAMMA
surfaceReduction = 1.0 - 0.28*roughness*perceptualRoughness; // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]
# else
surfaceReduction = 1.0 / (roughness*roughness + 1.0); // fade \in [0.5;1]
# endif
//Final
half3 color = (diffColor * (gi.diffuse + light.color * diffuseTerm))
+ specularTerm * light.color * FresnelTerm(specColor, LdotH)
+ surfaceReduction * gi.specular * FresnelLerp(specColor, grazingTerm, NdotV);
return half4(color, 1);
}
// ------------------------------------------------------------------
// Cloth Shading Function
//float3 ClothShading(FGBufferData GBuffer, float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N)
float4 ClothShading(float3 diffColor, float3 specColor, float3 fuzzColor, float cloth, float oneMinusReflectivity, float smoothness, float3 normal, float3 viewDir, UnityLight light, UnityIndirect gi, float3x3 worldVectors, float anisotropy)
{
const float3 FuzzColor = saturate(fuzzColor);
const float Cloth = saturate(cloth);
//Regular vectors
float NdotL = saturate(dot(normal, light.dir)); //sat?
float NdotV = abs(dot(normal, viewDir)); //abs?
float LdotV = dot(light.dir, viewDir);
//float invLenLV = rsqrt(abs(2 + 2 * normalize(LdotV)));
////float invLenLV = rsqrt(abs(2 + 2 * LdotV));
//float NdotH = (NdotL + normalize(NdotV)) * invLenLV;
//float NdotH = saturate((NdotL + normalize(NdotV)) * invLenLV);
float3 H = Unity_SafeNormalize(light.dir + viewDir);
//float H = (light.dir + viewDir) * invLenLV;
float LdotH = saturate(dot(light.dir, H));
//float3 H = normalize(viewDir + light.dir);
//float NdotL = saturate(dot(normal, light.dir));
//float NdotV = saturate(abs(dot(normal, viewDir)) + 1e-5);
float NdotH = saturate(dot(normal, H));
float VdotH = saturate(dot(viewDir, H));
//float LdotH = saturate(dot(light.dir, H));
half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
// Diffuse
float perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotH, perceptualRoughness) * NdotL;// - Need this NdotL multiply?
// Cloth - Asperity Scattering - Inverse Beckmann Layer
float3 F1 = FresnelTerm(fuzzColor, LdotH);// FresnelLerp(fuzzColor, grazingTerm, NdotV);// FresnelTerm(FuzzColor, LdotH);// F_Schlick(FuzzColor, VdotH);
float D1 = D_InvGGX(roughness, NdotH);
float V1 = Vis_Cloth(NdotV, NdotL);
//Specular term
float3 specularTerm1 = V1 * D1; //*UNITY_PI;
# ifdef UNITY_COLORSPACE_GAMMA
specularTerm1 = sqrt(max(1e-4h, specularTerm1));
# endif
// specularTerm * nl can be NaN on Metal in some cases, use max() to make sure it's a sane value
// specularTerm1 = max(0, specularTerm1 * NdotL);
#if defined(_SPECULARHIGHLIGHTS_OFF)
specularTerm1 = 0.0;
#endif
float3 Spec1 = specularTerm1 * light.color * FresnelTerm(fuzzColor, LdotH);
// Generalized microfacet specular
/*float3 F2 = F_Schlick(specColor, VdotH);
float D2 = D_GGX(roughness, NdotH);
float V2 = Vis_SmithJointApprox(roughness, NdotV, NdotL);
float3 Spec2 = D2 * V2 * F2 * light.color;*/
//Unpack world vectors
float3 tangent = worldVectors[0];
float3 bitangent = worldVectors[1];
//Tangent vectors
float TdotH = dot(tangent, H);
float TdotL = dot(tangent, light.dir);
float BdotH = dot(bitangent, H);
float BdotL = dot(bitangent, light.dir);
float TdotV = dot(viewDir, tangent);
float BdotV = dot(viewDir, bitangent);
//Fresnels
float3 F2 = FresnelLerp(specColor, grazingTerm, NdotV);// FresnelTerm(specColor, LdotH);// FresnelLerp(specColor, grazingTerm, NdotV); //Original Schlick - Replace from SRP?
float roughnessT;
float roughnessB;
//float perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);
//float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
ConvertAnisotropyToRoughness(roughness, anisotropy, roughnessT, roughnessB);
//Clamp roughness
//roughness = ClampRoughnessForAnalyticalLights(roughness);
roughnessT = ClampRoughnessForAnalyticalLights(roughnessT);
roughnessB = ClampRoughnessForAnalyticalLights(roughnessB);
//Visibility & Distribution terms
float V2 = SmithJointGGXAnisotropic(TdotV, BdotV, NdotV, TdotL, BdotL, NdotL, roughnessT, roughnessB);
float D2 = D_GGXAnisotropic(TdotH, BdotH, NdotH, roughnessT, roughnessB);
//Specular term
float3 specularTerm2 = V2 * D2; //*UNITY_PI;
# ifdef UNITY_COLORSPACE_GAMMA
specularTerm2 = sqrt(max(1e-4h, specularTerm2));
# endif
// specularTerm * nl can be NaN on Metal in some cases, use max() to make sure it's a sane value
specularTerm2 = max(0, specularTerm2 * NdotL);
#if defined(_SPECULARHIGHLIGHTS_OFF)
specularTerm2 = 0.0;
#endif
float3 Spec2 = specularTerm2 * light.color * FresnelTerm(specColor, LdotH);
float3 Spec = lerp(Spec2, Spec1, Cloth);
//Reduction
half surfaceReduction;
# ifdef UNITY_COLORSPACE_GAMMA
surfaceReduction = 1.0 - 0.28*roughness*perceptualRoughness; // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]
# else
surfaceReduction = 1.0 / (roughness*roughness + 1.0); // fade \in [0.5;1]
# endif
//Final
//half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
half3 color = (diffColor * (gi.diffuse + light.color * diffuseTerm))
+ Spec
+ surfaceReduction * gi.specular * FresnelLerp(specColor, grazingTerm, NdotV);
return half4(color, 1);
}
// ------------------------------------------------------------------
// Eye Shading Function
//float3 EyeShading(FGBufferData GBuffer, float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N)
float4 EyeShading(float3 diffColor, float3 specColor, float3 viewDir, half3 normal, float smoothness, float oneMinusReflectivity, UnityLight light, UnityIndirect gi)
{
float3 H = normalize(viewDir + light.dir);
float NdotL = saturate(dot(normal, light.dir));
float NdotV = saturate(abs(dot(normal, viewDir)) + 1e-5);
float NdotH = saturate(dot(normal, H));
float VdotH = saturate(dot(viewDir, H));
float LdotH = saturate(dot(light.dir, H));
// Generalized microfacet specular
float perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
float D = D_GGX(roughness, NdotH);// *LobeEnergy[1];
float V = Vis_SmithJointApprox(roughness, NdotV, NdotL);
float3 F = F_Schlick(specColor, VdotH);
float3 specularTerm = V * D; //*UNITY_PI;
# ifdef UNITY_COLORSPACE_GAMMA
specularTerm = sqrt(max(1e-4h, specularTerm));
# endif
// specularTerm * nl can be NaN on Metal in some cases, use max() to make sure it's a sane value
specularTerm = max(0, specularTerm * NdotL);
#if defined(_SPECULARHIGHLIGHTS_OFF)
specularTerm = 0.0;
#endif
half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
half surfaceReduction;
# ifdef UNITY_COLORSPACE_GAMMA
surfaceReduction = 1.0 - 0.28*roughness*perceptualRoughness; // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]
# else
surfaceReduction = 1.0 / (roughness*roughness + 1.0); // fade \in [0.5;1]
# endif
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotH, perceptualRoughness) * NdotL; // TODO - Unreal does not apply diffuse in Shading function
//Final
half3 color = (diffColor * (gi.diffuse + light.color * diffuseTerm))
+ specularTerm * light.color * FresnelTerm(specColor, LdotH)
+ surfaceReduction * gi.specular * FresnelLerp(specColor, grazingTerm, NdotV);
return half4(color, 1);
}
// ------------------------------------------------------------------
// Subsurface Shading Function
float3 SubsurfaceShadingSimple(float3 diffColor, float3 normal, float3 viewDir, float3 thickness, UnityLight light)
{
half3 vLTLight = light.dir + normal * _TDistortion;
half fLTDot = pow(saturate(dot(viewDir, -vLTLight)), _TPower) * _TScale;
half3 fLT = _TAttenuation * (fLTDot + _TAmbient) * (thickness);
return diffColor * ((light.color * fLT) * _TransmissionOverallStrength);
}
// ------------------------------------------------------------------
// Eye Subsurface Shading Function
//float3 EyeSubsurfaceShading(FGBufferData GBuffer, float3 L, float3 V, half3 N)
float3 EyeSubsurfaceShading(float3 diffColor, float3 specColor, float3 viewDir, half3 normal, float smoothness, float4 iris, UnityLight light)
{
float2 irisNormal = iris.rg;
float irisMask = iris.z;
float irisDistance = iris.w;
float3 H = normalize(viewDir + light.dir);
float VdotH = saturate(dot(viewDir, H));
float NdotV = saturate(abs(dot(normal, viewDir)) + 1e-5);
float LdotH = saturate(dot(light.dir, H));
// F_Schlick
//float F0 = GBuffer.Specular * 0.08;
//float Fc = Pow5(1 - VoH);
//float F = Fc + (1 - Fc) * F0;
float3 fresnel0 = lerp(specColor, diffColor, smoothness);
float3 F = FresnelSchlick(fresnel0, 1.0, LdotH);
//float IrisDistance = GBuffer.CustomData.w;
//float IrisMask = GBuffer.CustomData.z;
float3 IrisNormal;
IrisNormal = OctahedronToUnitVector(irisNormal * 2 - 1);
// Blend in the negative intersection normal to create some concavity
// Not great as it ties the concavity to the convexity of the cornea surface
// No good justification for that. On the other hand, if we're just looking to
// introduce some concavity, this does the job.
float3 CausticNormal = normalize(lerp(IrisNormal, -normal, irisMask*irisDistance));
float NdotL = saturate(dot(IrisNormal, light.dir));
float Power = lerp(12, 1, NdotL);
float Caustic = 0.6 + 0.2 * (Power + 1) * pow(saturate(dot(CausticNormal, light.dir)), Power);
float Iris = NdotL * Caustic;
// http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/
float Wrap = 0.15;
float Sclera = saturate((dot(normal, light.dir) + Wrap) / (1 + Wrap) * (1 + Wrap));
return (1 - F) * lerp(Sclera, Iris, irisMask) * diffColor / UNITY_PI;
}
// ------------------------------------------------------------------
// Shading function selectors
//float3 SurfaceShading(/*FGBufferData GBuffer,*/ float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N, uint2 Random)
float4 SurfaceShading(float3 diffColor, float3 specColor, float oneMinusReflectivity, float smoothness, float3 normal,
float3x3 worldVectors, float anisotropy, float4 customData, float metallic, float3 viewDir, UnityLight light, UnityIndirect gi)
{
#if defined(SHADINGMODELID_UNLIT)
{
return UnlitShading(diffColor);
}
#elif defined(SHADINGMODELID_STANDARD) || defined(SHADINGMODELID_SUBSURFACE) || defined(SHADINGMODELID_SKIN) || defined(SHADINGMODELID_FOLIAGE)
{
return StandardShading(diffColor, specColor, oneMinusReflectivity, smoothness,
normal, worldVectors, anisotropy, metallic, viewDir, light, gi);
}
#elif defined (SHADINGMODELID_CLEARCOAT)
{
return float4(1, 1, 1, 1); //ClearCoatShading(GBuffer, LobeRoughness, LobeEnergy, L, V, N);
}
#elif defined (SHADINGMODELID_CLOTH)
{
return ClothShading(diffColor, specColor, customData.rgb, customData.a, oneMinusReflectivity, smoothness, normal, viewDir, light, gi, worldVectors, anisotropy);
}
#elif defined (SHADINGMODELID_EYE)
{
return EyeShading(diffColor, specColor, viewDir, normal, smoothness, oneMinusReflectivity, light, gi); //EyeShading(GBuffer, LobeRoughness, LobeEnergy, L, V, N);
}
#endif
return float4(0, 0, 0, 0);
}
//float3 SubsurfaceShading(/*FGBufferData GBuffer,*/ float3 L, float3 V, half3 N, float Shadow, uint2 Random)
float3 SubsurfaceShading(float3 diffColor, float3 specColor, float3 normal, float smoothness, float3 viewDir, float4 customData, UnityLight light)
{
#if defined (SHADINGMODELID_SUBSURFACE)
{
return SubsurfaceShadingSimple(diffColor, normal, viewDir, customData.rgb, light);
}
#elif defined (SHADINGMODELID_SKIN)
{
return float3(0, 0, 0); //SubsurfaceShadingPreintegratedSkin(GBuffer, L, V, N);
}
#elif defined (SHADINGMODELID_FOLIAGE)
{
return float3(0, 0, 0); //SubsurfaceShadingTwoSided(SubsurfaceColor, L, V, N);
}
#elif defined (SHADINGMODELID_HAIR)
{
return float3(0, 0, 0); //HairShading(GBuffer, L, V, N, Shadow, 1, 0, Random);
}
#elif defined (SHADINGMODELID_EYE)
{
return EyeSubsurfaceShading(diffColor, specColor, viewDir, normal, smoothness, customData, light); //EyeSubsurfaceShading(GBuffer, L, V, N);
}
#endif
return float3(0, 0, 0);
}
//#endif UNITY_ADVANCED_SHADINGMODELS_INCLUDED
//-------------------------------------------------------------------------------------
// Lighting Helpers
// Glossy Environment
half3 Unity_AnisotropicGlossyEnvironment(UNITY_ARGS_TEXCUBE(tex), half4 hdr, Unity_GlossyEnvironmentData glossIn, half anisotropy) //Reference IBL from HD Pipe (Add half3 L input and replace R)
{
half perceptualRoughness = glossIn.roughness /* perceptualRoughness */;
// TODO: CAUTION: remap from Morten may work only with offline convolution, see impact with runtime convolution!
// For now disabled
#if 0
float m = PerceptualRoughnessToRoughness(perceptualRoughness); // m is the real roughness parameter
const float fEps = 1.192092896e-07F; // smallest such that 1.0+FLT_EPSILON != 1.0 (+1e-4h is NOT good here. is visibly very wrong)
float n = (2.0 / max(fEps, m*m)) - 2.0; // remap to spec power. See eq. 21 in --> https://dl.dropboxusercontent.com/u/55891920/papers/mm_brdf.pdf
n /= 4; // remap from n_dot_h formulatino to n_dot_r. See section "Pre-convolved Cube Maps vs Path Tracers" --> https://s3.amazonaws.com/docs.knaldtech.com/knald/1.0.0/lys_power_drops.html
perceptualRoughness = pow(2 / (n + 2), 0.25); // remap back to square root of real roughness (0.25 include both the sqrt root of the conversion and sqrt for going from roughness to perceptualRoughness)
#else
// MM: came up with a surprisingly close approximation to what the #if 0'ed out code above does.
perceptualRoughness = perceptualRoughness*(1.7 - 0.7*perceptualRoughness);
#endif
half mip = perceptualRoughnessToMipmapLevel(perceptualRoughness);
half3 R = glossIn.reflUVW;// -half3(anisotropy, 0, 0);
half4 rgbm = UNITY_SAMPLE_TEXCUBE_LOD(tex, R, mip);
return DecodeHDR(rgbm, hdr);
}
// Indirect Specular
inline half3 UnityGI_AnisotropicIndirectSpecular(UnityGIInput data, half occlusion, Unity_GlossyEnvironmentData glossIn, half anisotropy, half3x3 worldVectors)
{
half3 specular;
float3 tangentX = worldVectors[0];
float3 tangentY = worldVectors[1];
float3 N = worldVectors[2];
float3 V = data.worldViewDir;
float3 iblNormalWS = GetAnisotropicModifiedNormal(tangentY, N, V, anisotropy);
float3 iblR = reflect(-V, iblNormalWS);
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
// we will tweak reflUVW in glossIn directly (as we pass it to Unity_GlossyEnvironment twice for probe0 and probe1), so keep original to pass into BoxProjectedCubemapDirection
half3 originalReflUVW = glossIn.reflUVW;
glossIn.reflUVW = BoxProjectedCubemapDirection(iblR, data.worldPos, data.probePosition[0], data.boxMin[0], data.boxMax[0]);
#endif
#ifdef _GLOSSYREFLECTIONS_OFF
specular = unity_IndirectSpecColor.rgb;
#else
half3 env0 = Unity_AnisotropicGlossyEnvironment(UNITY_PASS_TEXCUBE(unity_SpecCube0), data.probeHDR[0], glossIn, anisotropy);
//half3 env0 = Unity_AnisotropicGlossyEnvironment(UNITY_PASS_TEXCUBE(unity_SpecCube0), data.probeHDR[0], glossIn, anisotropy, L); //Reference IBL from HD Pipe
#ifdef UNITY_SPECCUBE_BLENDING
const float kBlendFactor = 0.99999;
float blendLerp = data.boxMin[0].w;
UNITY_BRANCH
if (blendLerp < kBlendFactor)
{
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
glossIn.reflUVW = BoxProjectedCubemapDirection(iblR, data.worldPos, data.probePosition[1], data.boxMin[1], data.boxMax[1]);
#endif
half3 env1 = Unity_AnisotropicGlossyEnvironment(UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1, unity_SpecCube0), data.probeHDR[1], glossIn, anisotropy);
//half3 env1 = Unity_AnisotropicGlossyEnvironment(UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1, unity_SpecCube0), data.probeHDR[1], glossIn, anisotropy, L); //Reference IBL from HD Pipe
specular = lerp(env1, env0, blendLerp);
}
ENDCG
else
{
specular = env0;
}
#else
specular = env0;
#endif
#endif
return specular * occlusion;// *weightOverPdf; //Reference IBL from HD Pipe
//return specular * occlusion * weightOverPdf; //Reference IBL from HD Pipe
}
// Global Illumination
inline UnityGI UnityAnisotropicGlobalIllumination(UnityGIInput data, half occlusion, half3 normalWorld, Unity_GlossyEnvironmentData glossIn, half anisotropy, half3x3 worldVectors)
{
UnityGI o_gi = UnityGI_Base(data, occlusion, normalWorld);
o_gi.indirect.specular = UnityGI_AnisotropicIndirectSpecular(data, occlusion, glossIn, anisotropy, worldVectors);
return o_gi;
}
//-------------------------------------------------------------------------------------
// Lighting Functions
//Surface Description
struct SurfaceOutputAdvanced
{
fixed3 Albedo; // base (diffuse or specular) color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Metallic; // 0=non-metal, 1=metal
// Smoothness is the user facing name, it should be perceptual smoothness but user should not have to deal with it.
// Everywhere in the code you meet smoothness it is perceptual smoothness
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
half3 Tangent;
half Anisotropy;
half4 CustomData;
float3x3 WorldVectors;
//half ShadingModel;
};
inline half4 LightingAdvanced(SurfaceOutputAdvanced s, half3 viewDir, UnityGI gi)
{
s.Normal = normalize(s.Normal);
half oneMinusReflectivity;
half3 specColor;
s.Albedo = DiffuseAndSpecularFromMetallic(s.Albedo, s.Metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
// shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
// this is necessary to handle transparency in physically correct way - only diffuse component gets affected by alpha
half outputAlpha;
s.Albedo = PreMultiplyAlpha(s.Albedo, s.Alpha, oneMinusReflectivity, /*out*/ outputAlpha);
half4 c = SurfaceShading(s.Albedo, specColor, oneMinusReflectivity, s.Smoothness, s.Normal, s.WorldVectors, s.Anisotropy, s.CustomData, s.Metallic, viewDir, gi.light, gi.indirect);
c.rgb += SubsurfaceShading(s.Albedo, specColor, s.Normal, s.Smoothness, viewDir, s.CustomData, gi.light);
//c.rgb += UNITY_BRDF_GI(s.Albedo, specColor, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, s.Occlusion, gi);
c.a = outputAlpha;
return c;
}
//This is pointless as always forward?
inline half4 LightingAdvanced_Deferred(SurfaceOutputAdvanced s, half3 viewDir, UnityGI gi, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2)
{
half oneMinusReflectivity;
half3 specColor;
s.Albedo = DiffuseAndSpecularFromMetallic(s.Albedo, s.Metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
half4 c = SurfaceShading(s.Albedo, specColor, oneMinusReflectivity, s.Smoothness, s.Normal, s.WorldVectors, s.Anisotropy, s.CustomData, s.Metallic, viewDir, gi.light, gi.indirect);
c.rgb += SubsurfaceShading(s.Albedo, specColor, s.Normal, s.Smoothness, viewDir, s.CustomData, gi.light);
UnityStandardData data;
data.diffuseColor = s.Albedo;
data.occlusion = s.Occlusion;
data.specularColor = specColor;
data.smoothness = s.Smoothness;
data.normalWorld = s.Normal;
UnityStandardDataToGbuffer(data, outGBuffer0, outGBuffer1, outGBuffer2);
half4 emission = half4(s.Emission + c.rgb, 1);
return emission;
}
inline void LightingAdvanced_GI(SurfaceOutputAdvanced s, UnityGIInput data, inout UnityGI gi)
{
#if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal);
#else
Unity_GlossyEnvironmentData g = UnityGlossyEnvironmentSetup(s.Smoothness, data.worldViewDir, s.Normal, lerp(unity_ColorSpaceDielectricSpec.rgb, s.Albedo, s.Metallic));
gi = UnityAnisotropicGlobalIllumination(data, s.Occlusion, s.Normal, g, s.Anisotropy, s.WorldVectors);
#endif
}
///END
#pragma target 5.0
#pragma surface surf Advanced vertex:vert
#pragma glsl
#pragma debug
float4 Color_eb55295a_2a33_4a48_b612_9d279e2cf480_Uniform;
float Vector1_58a74627_6519_4fc6_ac27_ff4e37beadf7_Uniform;
struct Input
{
float4 color : COLOR;
float4 worldTangent;
float3 worldNormal;
};
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.worldTangent = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
void surf (Input IN, inout SurfaceOutputAdvanced o)
{
float3 worldSpaceTangent = normalize(IN.worldTangent.xyz);
float3 worldSpaceNormal = normalize(IN.worldNormal);
float3 worldSpaceBitangent = cross(worldSpaceNormal, worldSpaceTangent) * IN.worldTangent.w;
o.Albedo = Color_eb55295a_2a33_4a48_b612_9d279e2cf480_Uniform;
o.Metallic = Vector1_58a74627_6519_4fc6_ac27_ff4e37beadf7_Uniform;
o.Smoothness = Vector1_58a74627_6519_4fc6_ac27_ff4e37beadf7_Uniform;
o.Anisotropy = Vector1_58a74627_6519_4fc6_ac27_ff4e37beadf7_Uniform;
o.WorldVectors = float3x3(worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);
}
ENDCG
}
FallBack "Diffuse"
}
Fallback Off
}

22
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs


class CallbackData
{
public MaterialGraphAsset asset;
public IGraphAsset asset;
public static List<MaterialGraphAsset> FindAssets()
public static List<IGraphAsset> FindAssets()
var assets = new List<MaterialGraphAsset>();
string[] guids = AssetDatabase.FindAssets(string.Format("t:MaterialGraphAsset", typeof(MaterialGraphAsset)));
for( int i = 0; i < guids.Length; i++ )
var assets = new List<IGraphAsset>();
List<string> guids = AssetDatabase.FindAssets(string.Format("t:MaterialGraphAsset", typeof(MaterialGraphAsset))).ToList();
guids.AddRange( AssetDatabase.FindAssets(string.Format("t:MaterialSubGraphAsset", typeof(MaterialSubGraphAsset))));
for( int i = 0; i < guids.Count; i++ )
MaterialGraphAsset asset = AssetDatabase.LoadAssetAtPath<MaterialGraphAsset>( assetPath );
if( asset != null )
ScriptableObject asset = AssetDatabase.LoadAssetAtPath<ScriptableObject>( assetPath );
if( asset != null && EditorUtility.IsPersistent(asset) && asset is IGraphAsset)
assets.Add(asset);
assets.Add((IGraphAsset)asset);
}
}
return assets;

{
var options = FindAssets().Where (x => EditorUtility.IsPersistent (x)).ToList ();
var options = FindAssets();
gm.AddItem (new GUIContent (AssetDatabase.GetAssetPath (option)), false, Callback, new CallbackData(){asset = option, owner = m_Owner});
gm.AddItem (new GUIContent (AssetDatabase.GetAssetPath (option.GetScriptableObject())), false, Callback, new CallbackData(){asset = option, owner = m_Owner});
}
gm.ShowAsContext ();

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


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

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

4
MaterialGraphProject/Assets/GraphView/Editor.meta


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

40
MaterialGraphProject/Assets/Matt/AbstractAdvancedMasterNode.cs


public const int OcclusionSlotId = 5;
public const int AlphaSlotId = 6;
public const string AnisotropySlotName = "Anisotropy";
public const int AnisotropySlotId = 7;
public const int TangentSlotId = 8;
public const int TangentSlotId = 7;
[SerializeField]
private SurfaceMaterialOptions m_MaterialOptions = new SurfaceMaterialOptions();

public abstract string GetSurfaceOutputName();
public abstract string GetLightFunction();
//Deal with custom data packing
// Check for whether tangents are needed in the BRDF
public virtual bool RequireTangentCalculation()
{
return false;
}
public override string GetSubShader(GenerationMode mode, PropertyGenerator shaderPropertiesVisitor)
{

shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
}
// If tangents are needed for the BRDF
var edges = owner.GetEdges(slot.slotReference);
if (edges.Any())
{
shaderBody.AddShaderChunk("float3x3 worldToTangent;", false);
shaderBody.AddShaderChunk("worldToTangent[0] = float3(1, 0, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[1] = float3(0, 1, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[2] = float3(0, 0, 1);", false);
shaderBody.AddShaderChunk("float3 tangentTWS = mul(o." + slot.shaderOutputName + ", worldToTangent);", false);
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(tangentTWS, " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
}
else
if (RequireTangentCalculation())
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(" + ShaderGeneratorNames.WorldSpaceTangent + ", " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
var edges = owner.GetEdges(slot.slotReference);
if (edges.Any())
{
shaderBody.AddShaderChunk("float3x3 worldToTangent;", false);
shaderBody.AddShaderChunk("worldToTangent[0] = float3(1, 0, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[1] = float3(0, 1, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[2] = float3(0, 0, 1);", false);
shaderBody.AddShaderChunk("float3 tangentTWS = mul(o." + slot.shaderOutputName + ", worldToTangent);", false);
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(tangentTWS, " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
}
else
{
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(" + ShaderGeneratorNames.WorldSpaceTangent + ", " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
}
}
}
}

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

14
MaterialGraphProject/Assets/Matt/AnisotropicMetallicMasterNode.cs


public const string MetallicSlotName = "Metallic";
public const int MetallicSlotId = 2;
public const string AnisotropySlotName = "Anisotropy";
public const int AnisotropySlotId = 8;
public const string LightFunctionName = "Advanced";
public const string SurfaceOutputStructureName = "SurfaceOutputAdvanced";

return "SHADINGMODELID_STANDARD";
}
public override bool RequireTangentCalculation()
{
return true;
}
public override int[] GetCustomDataSlots()
{
return new int[] { };

AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots

SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
AnisotropySlotId,
TangentSlotId
TangentSlotId,
AnisotropySlotId
});
}

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

10
MaterialGraphProject/Assets/Matt/SubsurfaceMetallicMasterNode.cs


public const string MetallicSlotName = "Metallic";
public const int MetallicSlotId = 2;
public const string AnisotropySlotName = "Anisotropy";
public const int AnisotropySlotId = 8;
public const string TranslucencySlotName = "Translucency";
public const int TranslucencySlotId = 9;

return "SHADINGMODELID_SUBSURFACE";
}
public override bool RequireTangentCalculation()
{
return true;
}
public override int[] GetCustomDataSlots()
{
return new int[] { 9 };

AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TangentSlotId, TangentSlotName, TangentSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TranslucencySlotId, TranslucencySlotName, TranslucencySlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));

SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
AnisotropySlotId,
AnisotropySlotId,
TranslucencySlotId
});
}

14
MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs


}
}
}
/*This is to overide input to be vector 3, not really necessary anymore*/
/*This is to overide input to be vector 3, not really necessary */
/*
protected override MaterialSlot GetInputSlot1()
{

var outputString = new ShaderGenerator();
switch (m_BlendMode)
{
/* case BlendModesEnum.AddSub:
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return 2.0 * arg1 + arg2 - 1.0;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
break;
*/
case BlendModesEnum.Burn:
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false);
outputString.AddShaderChunk("{", false);

outputString.Deindent();
outputString.AddShaderChunk("}", false);
break;
case BlendModesEnum.LinearLight:
case BlendModesEnum.LinearLight_AddSub:
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();

outputString.AddShaderChunk("}", false);
break;
}
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}

2
MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs


Lighten,
LinearBurn,
LinearDodge,
LinearLight,
LinearLight_AddSub,
Multiply,
Negation,
Overlay,

2
MaterialGraphProject/Assets/Rinaldo/Editor/BlendModeNodePresenter.cs


*/
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.standardVerticalSpacing;
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs


{
get
{
yield return new TypeMapping(typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeInspector));
yield return new TypeMapping(typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeInspector));
yield return new TypeMapping(typeof(PropertyNode), typeof(PropertyNodeInspector));
yield return new TypeMapping(typeof(SubGraphInputNode), typeof(SubgraphInputNodeInspector));
yield return new TypeMapping(typeof(SubGraphOutputNode), typeof(SubgraphOutputNodeInspector));
}

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


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

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

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


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

typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodePresenter);
typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
typeMapper[typeof(IfNode)] = typeof(IfNodePresenter);
typeMapper[typeof(CustomCodeNode)] = typeof(CustomCodePresenter);
typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodePresenter);
typeMapper[typeof(Matrix3Node)] = typeof(Matrix3NodePresenter);
typeMapper[typeof(Matrix4Node)] = typeof(Matrix4NodePresenter);
typeMapper[typeof(MatrixCommonNode)] = typeof(MatrixCommonNodePresenter);
typeMapper[typeof(TransformNode)] = typeof(TransformNodePresenter);
}
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs


{
switch (previewProperty.m_PropType)
{
case PropertyType.Texture2D:
case PropertyType.Texture:
mat.SetTexture(previewProperty.m_Name, previewProperty.m_Texture);
break;
case PropertyType.Cubemap:

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureAssetPresenter.cs


return;
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture2D), null) as Texture2D;
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);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureLODNodePresenter.cs


return;
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture2D), null) as Texture2D;
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);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureNodePresenter.cs


return;
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState);
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture2D), null) as Texture2D;
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);
}

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


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

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

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


Shader "Graph/UnityEngine.MaterialGraph.MetallicMasterNode56fdded2-bae1-4a2c-b2db-6e9c206bf8ff"
Shader "Graph/UnityEngine.MaterialGraph.MetallicMasterNode0dd415f6-2593-4617-b37c-c9d9dd315a4c"
Vector1_681e693a_7812_42ab_a37b_8a1edc00d63e_Uniform("", Float) = 0.005
Vector1_bc1392c9_f4d7_47a8_8add_f4f4b00fdfe5_Uniform("", Float) = 0
Vector1_36d8f7c7_3ada_4604_9149_df2ba1745b80_Uniform("", Float) = 8
Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform("", Float) = 0.1
}

#pragma glsl
#pragma debug
inline float4 unity_add_float (float4 arg1, float4 arg2)
{
return arg1 + arg2;
}
inline float2 unity_multiply_float (float2 arg1, float2 arg2)
{
return arg1 * arg2;
}
inline float2 unity_voronoi_noise_randomVector (float2 uv, float offset)
{
float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
uv = frac(sin(mul(uv, m)) * 46839.32);
return float2(sin(uv.y*+offset)*0.5+0.5, cos(uv.x*offset)*0.5+0.5);
}
inline float unity_voronoinoise_float (float2 uv, float angleOffset)
{
float2 g = floor(uv);
float2 f = frac(uv);
float t = 8.0;
float3 res = float3(8.0, 0.0, 0.0);
for(int y=-1; y<=1; y++)
{
for(int x=-1; x<=1; x++)
{
float2 lattice = float2(x,y);
float2 offset = unity_voronoi_noise_randomVector(lattice + g, angleOffset);
float d = distance(lattice + offset, f);
if(d < res.x)
{
res = float3(d, offset.x, offset.y);
}
}
}
return res.x;
}
inline float unity_oneminus_float (float arg1)
{
return arg1 * -1 + 1;
}
inline float4 unity_multiply_float (float4 arg1, float4 arg2)
{
return arg1 * arg2;
}
inline float unity_subtract_float (float arg1, float arg2)
{
return arg1 - arg2;
}
inline float unity_multiply_float (float arg1, float arg2)
inline float unity_posterize_float (float input, float stepsize)
return arg1 * arg2;
return floor(input / stepsize) * stepsize;
float Vector1_681e693a_7812_42ab_a37b_8a1edc00d63e_Uniform;
float Vector1_bc1392c9_f4d7_47a8_8add_f4f4b00fdfe5_Uniform;
float Vector1_36d8f7c7_3ada_4604_9149_df2ba1745b80_Uniform;
float Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform;
half4 meshUV0;
float3 worldNormal;
};

o.meshUV0 = v.texcoord;
half4 uv0 = IN.meshUV0;
float4 Color_a5c79f09_af3c_413d_a03a_0fbcda1f305f_Uniform = float4 (0.5588235, 0.5588235, 0.5588235, 0);
float Vector1_b212d213_1dc1_491d_8dbf_0add4ab24246_Uniform = 1;
float Vector1_c753024a_f95d_4487_bcb7_13a86e18dd68_Uniform = 0;
float4 Combine_523239ba_f790_4fca_a9e2_babb69c74568_Output = float4(Vector1_681e693a_7812_42ab_a37b_8a1edc00d63e_Uniform,Vector1_bc1392c9_f4d7_47a8_8add_f4f4b00fdfe5_Uniform,0.0, 0.0);
float4 UV_2eb2b635_fc17_44ea_90c4_c1188f10857b_UV = uv0;
float4 Add_2c8c5705_3762_4ed4_b2de_b611d458bd65_Output = unity_add_float (Combine_523239ba_f790_4fca_a9e2_babb69c74568_Output, UV_2eb2b635_fc17_44ea_90c4_c1188f10857b_UV);
float4 Split_0c1c11c9_9ee2_40d8_9cb0_b913d2f3e22a = float4(Add_2c8c5705_3762_4ed4_b2de_b611d458bd65_Output);
float2 Multiply_f3f41634_3594_48d4_b7b6_3104b523e7dd_Output = unity_multiply_float (Split_0c1c11c9_9ee2_40d8_9cb0_b913d2f3e22a.rg, float2 (20,20));
float VoronoiNoise_175ef02c_a94e_44e5_9668_dff18e2112fe_Output = unity_voronoinoise_float (Multiply_f3f41634_3594_48d4_b7b6_3104b523e7dd_Output, _Time.w);
float OneMinus_0b02f4c6_d95f_4305_9d7c_5e720ad0d2c4_Output = unity_oneminus_float (VoronoiNoise_175ef02c_a94e_44e5_9668_dff18e2112fe_Output);
float4 Multiply_766862d4_1f32_4bdc_93ba_e17532ee9f8b_Output = unity_multiply_float (UV_2eb2b635_fc17_44ea_90c4_c1188f10857b_UV, float4 (20,20,0,0));
float VoronoiNoise_b5d8acbb_4b86_4780_8ba2_9b79cdf9b0ba_Output = unity_voronoinoise_float (Multiply_766862d4_1f32_4bdc_93ba_e17532ee9f8b_Output, _Time.w);
float OneMinus_95c0d854_a598_4448_b1ec_19f0ae2e3207_Output = unity_oneminus_float (VoronoiNoise_b5d8acbb_4b86_4780_8ba2_9b79cdf9b0ba_Output);
float Subtract_d442f4ab_3183_4dba_88bb_12b82b1e4b22_Output = unity_subtract_float (OneMinus_0b02f4c6_d95f_4305_9d7c_5e720ad0d2c4_Output, OneMinus_95c0d854_a598_4448_b1ec_19f0ae2e3207_Output);
float Multiply_223da849_596f_4a92_ac44_065f9082e924_Output = unity_multiply_float (Subtract_d442f4ab_3183_4dba_88bb_12b82b1e4b22_Output, Vector1_36d8f7c7_3ada_4604_9149_df2ba1745b80_Uniform);
float4 Combine_261925f9_60e1_402b_9b71_69912cd8c284_Output = float4(Vector1_b212d213_1dc1_491d_8dbf_0add4ab24246_Uniform,Vector1_c753024a_f95d_4487_bcb7_13a86e18dd68_Uniform,Multiply_223da849_596f_4a92_ac44_065f9082e924_Output,0.0);
float4 Split_637f528c_802b_4b35_abbe_e94b103a0f9a = float4(Combine_261925f9_60e1_402b_9b71_69912cd8c284_Output);
float4 Combine_1399c2cd_55f2_48bf_a413_58c773e76556_Output = float4(Vector1_bc1392c9_f4d7_47a8_8add_f4f4b00fdfe5_Uniform,Vector1_681e693a_7812_42ab_a37b_8a1edc00d63e_Uniform,0.0, 0.0);
float4 Add_3698bc9c_3a9c_4f77_86ad_50ac01252625_Output = unity_add_float (UV_2eb2b635_fc17_44ea_90c4_c1188f10857b_UV, Combine_1399c2cd_55f2_48bf_a413_58c773e76556_Output);
float4 Multiply_94a1c8a0_7a01_42a5_baf8_3460cc52ccce_Output = unity_multiply_float (Add_3698bc9c_3a9c_4f77_86ad_50ac01252625_Output, float4 (20,20,0,0));
float VoronoiNoise_041c0818_8a7a_490c_ae6b_362b2e498fa6_Output = unity_voronoinoise_float (Multiply_94a1c8a0_7a01_42a5_baf8_3460cc52ccce_Output, _Time.w);
float OneMinus_b7c5d2e2_90e6_4cb2_be5c_3aa34ea18363_Output = unity_oneminus_float (VoronoiNoise_041c0818_8a7a_490c_ae6b_362b2e498fa6_Output);
float Subtract_c4f59a4e_29c0_4f5e_92c7_52ab56cc6a23_Output = unity_subtract_float (OneMinus_b7c5d2e2_90e6_4cb2_be5c_3aa34ea18363_Output, OneMinus_95c0d854_a598_4448_b1ec_19f0ae2e3207_Output);
float Multiply_f3bd2e5b_f8c4_486a_83c8_df44e04bc77a_Output = unity_multiply_float (Vector1_36d8f7c7_3ada_4604_9149_df2ba1745b80_Uniform, Subtract_c4f59a4e_29c0_4f5e_92c7_52ab56cc6a23_Output);
float4 Combine_d1411122_6465_494a_88e6_98e96eba037a_Output = float4(Vector1_c753024a_f95d_4487_bcb7_13a86e18dd68_Uniform,Vector1_b212d213_1dc1_491d_8dbf_0add4ab24246_Uniform,Multiply_f3bd2e5b_f8c4_486a_83c8_df44e04bc77a_Output,0.0);
float4 Split_bdd63fad_c244_45a4_ae4c_ed756a69ac03 = float4(Combine_d1411122_6465_494a_88e6_98e96eba037a_Output);
float3 CrossProduct_0955bdd9_9b65_4141_b394_1b86aa4c7d3f_Output = cross (Split_637f528c_802b_4b35_abbe_e94b103a0f9a.rgb, Split_bdd63fad_c244_45a4_ae4c_ed756a69ac03.rgb);
o.Albedo = Color_a5c79f09_af3c_413d_a03a_0fbcda1f305f_Uniform;
o.Normal = CrossProduct_0955bdd9_9b65_4141_b394_1b86aa4c7d3f_Output;
o.Normal += 1e-6;
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

FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
}

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


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

32
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/ExportTexture.template


Pass
{
CGPROGRAM
#pragma vertex vert
#include "UnityCustomRenderTexture.cginc"
#pragma vertex CustomRenderTextureVertexShader${ShaderIsUsingPreview}
#include "UnityCG.cginc"
#pragma target 4.0
v2f_customrendertexture CustomRenderTextureVertexShader_Preview(appdata_base IN)
{
v2f_customrendertexture OUT;
OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.primitiveID = 0;//TODO
OUT.localTexcoord = IN.texcoord;
OUT.globalTexcoord = IN.texcoord;
OUT.direction = CustomRenderTextureComputeCubeDirection(OUT.globalTexcoord.xy);
return OUT;
}
struct v2f
{
float4 pos : SV_POSITION;
${ShaderInputs}
};
v2f vert (appdata_full v)
{
v2f o = (v2f)0;
o.pos = UnityObjectToClipPos(v.vertex);
${VertexShaderBody}
return o;
}
half4 frag (v2f IN) : COLOR
float4 frag(v2f_customrendertexture IN) : COLOR
{
${PixelShaderBody}
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/PropertyNodeTests.cs


"MudDiffuse.tif"
};
private static Texture2D FindTestTexture()
private static Texture FindTestTexture()
return AssetDatabase.LoadAssetAtPath<Texture2D>(texturePath);
return AssetDatabase.LoadAssetAtPath<Texture>(texturePath);
}
[SetUp]

[Test]
public void TestTextureNodeTypeIsCorrect()
{
Assert.AreEqual(PropertyType.Texture2D, m_TextureNode.propertyType);
Assert.AreEqual(PropertyType.Texture, m_TextureNode.propertyType);
}
[Test]

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


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

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs


m_Graph.AddNode(m_PropertyNode);
}
[Test]
/* [Test]
public void TestExposedPropertyReturnsRawName()
{
m_PropertyNode.exposedState = PropertyNode.ExposedState.Exposed;

m_Vector2Node.ValidateNode();
Assert.IsFalse(m_Vector1Node.hasError);
Assert.IsFalse(m_Vector2Node.hasError);
}
}*/
[Test]
public void TestPropertyExposedOnSubgraphReturnsFalse()

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


if (inputSlot == null)
return string.Empty;
string sufix = "";
var edges = owner.GetEdges(inputSlot.slotReference).ToArray();
if (edges.Any())

if (slot == null)
return string.Empty;
if (slot.concreteValueType == ConcreteSlotValueType.sampler2D)
sufix += "_Uniform";
return ShaderGenerator.AdaptNodeOutput(fromNode, slot.id, slot.concreteValueType) + sufix;
return ShaderGenerator.AdaptNodeOutput(fromNode, slot.id, slot.concreteValueType);
if (inputSlot.concreteValueType == ConcreteSlotValueType.sampler2D)
sufix += "_Uniform";
return inputSlot.GetDefaultValue(generationMode) + sufix;
return inputSlot.GetDefaultValue(generationMode);
}
private ConcreteSlotValueType FindCommonChannelType(ConcreteSlotValueType from, ConcreteSlotValueType to)

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

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

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

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

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


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

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

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


public override bool hasPreview { get { return true; } }
public Texture2D defaultTexture { get; set; }
public Texture defaultTexture { get; set; }
public DepthTextureNode()
{

return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_PropType = PropertyType.Texture,
m_Texture = defaultTexture
};
}

return GetVariableNameForNode();
}
public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public override PropertyType propertyType { get { return PropertyType.Texture; } }
public bool RequiresMeshUV(UVChannel channel)
{

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


public override bool hasPreview { get { return true; } }
public Texture2D defaultTexture { get; set; }
public Texture defaultTexture { get; set; }
public MotionVectorTextureNode()
{

return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_PropType = PropertyType.Texture,
m_Texture = defaultTexture
};
}

return GetVariableNameForNode();
}
public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public override PropertyType propertyType { get { return PropertyType.Texture; } }
public bool RequiresMeshUV(UVChannel channel)
{

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


protected const string kOutputSlotAName = "A";
protected const string kInputSlotLodName = "MipLevel";
public const int UvSlotId = 0;
public const int RefDirSlot = 0;
public const int InputSlotLod = 6;
public const int OutputSlotRgbaId = 1;
public const int OutputSlotRId = 2;

AddSlot(new MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero, false));
AddSlot(new MaterialSlot(RefDirSlot, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero, false));
AddSlot (new MaterialSlot(InputSlotLod, kInputSlotLodName, kInputSlotLodName, SlotType.Input, SlotValueType.Vector1, Vector2.zero));
RemoveSlotsNameNotMatching(validSlots);
}

protected int[] validSlots
{
get { return new[] {OutputSlotRgbaId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, UvSlotId, InputSlotLod}; }
get { return new[] {OutputSlotRgbaId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, RefDirSlot, InputSlotLod}; }
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId);
var uvSlot = FindInputSlot<MaterialSlot>(RefDirSlot);
if (uvSlot == null)
return;

{
case OutputSlotRId:
slotOutput = ".r";
break;
case InputSlotLod:
slotOutput = "_lod";
break;
case RefDirSlot:
slotOutput = "_RefDir";
break;
case OutputSlotGId:
slotOutput = ".g";

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


[Serializable]
private class TextureHelper
{
public Texture2D texture;
public Texture texture;
public Texture2D defaultTexture
public Texture defaultTexture
{
get
{

}
}
#else
public Texture2D defaultTexture { get; set; }
public Texture defaultTexture { get; set; }
#endif
public TextureType textureType

return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_PropType = PropertyType.Texture,
public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public override PropertyType propertyType { get { return PropertyType.Texture; } }
public bool RequiresMeshUV(UVChannel channel)
{

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


[Serializable]
private class TextureHelper
{
public Texture2D texture;
public Texture texture;
public Texture2D defaultTexture
public Texture defaultTexture
{
get
{

}
}
#else
public Texture2D defaultTexture {get; set; }
public Texture defaultTexture {get; set; }
#endif
public TextureType textureType

return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_PropType = PropertyType.Texture,
public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public override PropertyType propertyType { get { return PropertyType.Texture; } }
public bool RequiresMeshUV(UVChannel channel)
{

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


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

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

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


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

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


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

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

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

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PreviewProperty.cs


public PropertyType m_PropType;
public Color m_Color;
public Texture2D m_Texture;
public Texture m_Texture;
public Cubemap m_Cubemap;
public Vector4 m_Vector4;
public float m_Float;

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


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

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

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

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

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

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

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs


}
[SerializeField]
private string m_PropertyName = string.Empty;
[SerializeField]
private string m_Description = string.Empty;
[SerializeField]

{
get
{
if (string.IsNullOrEmpty(m_Description))
return m_PropertyName;
return m_Description;
return string.IsNullOrEmpty(m_Description) ? name : m_Description;
}
set { m_Description = value; }
}

get
{
if (exposedState == ExposedState.NotExposed || string.IsNullOrEmpty(m_PropertyName))
return m_PropertyName + "_Uniform";
set { m_PropertyName = value; }
}
public abstract PropertyType propertyType { get; }

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


public enum PropertyType
{
Color,
Texture2D,
Texture,
Vector4
Vector4,
Matrix2,
Matrix3,
Matrix4
}
}

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


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

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

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


namespace UnityEngine.MaterialGraph
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("UV/Cartesian To Polar")]
public class CartesianToPolarNode : Function1Input, IGeneratesFunction

protected override MaterialSlot GetInputSlot()
{
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector2, 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)

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

3
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MaterialSubGraphAsset.cs


public SubGraph subGraph
{
get { return m_MaterialSubGraph; }
get { return m_MaterialSubGraph; }
set { m_MaterialSubGraph = value; }
}
public void PostCreate()

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


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

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

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

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

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

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

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

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

61
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/ExportTextureMasterNode.cs


namespace UnityEngine.MaterialGraph
{
[Serializable]
[Title("Master/Export Texture")]
[Title("Master/Custom Texture")]
public class ExportTextureMasterNode : AbstractMasterNode
{
public const string ColorSlotName = "Color";

return false;
}
public override string GetFullShader(GenerationMode mode, out List<PropertyGenerator.TextureInfo> configuredTextures)
public override string GetFullShader(GenerationMode generationMode, out List<PropertyGenerator.TextureInfo> configuredTextures)
{
// figure out what kind of preview we want!

var shaderPropertiesVisitor = new PropertyGenerator();
var shaderPropertyUsagesVisitor = new ShaderGenerator();
var shaderInputVisitor = new ShaderGenerator();
var vertexShaderBlock = new ShaderGenerator();
vertexShaderBlock.AddShaderChunk("float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;", true);
vertexShaderBlock.AddShaderChunk("float3 viewDir = UnityWorldSpaceViewDir(worldPos);", true);
vertexShaderBlock.AddShaderChunk("float4 screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));", true);
vertexShaderBlock.AddShaderChunk("float3 worldNormal = UnityObjectToWorldNormal(v.normal);", true);
shaderInputVisitor.AddShaderChunk("float3 worldPos : TEXCOORD0;", true);
vertexShaderBlock.AddShaderChunk("o.worldPos = worldPos;", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpacePosition + " = IN.worldPos;", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpacePosition + " = float3(0.0, 0.0, 0.0);", true);
shaderInputVisitor.AddShaderChunk("float3 worldNormal : TEXCOORD1;", true);
vertexShaderBlock.AddShaderChunk("o.worldNormal = worldNormal;", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceNormal + " = normalize(IN.worldNormal);", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceNormal + " = float3(0.0, 0.0, 1.0);", true);
}
for (int uvIndex = 0; uvIndex < ShaderGeneratorNames.UVCount; ++uvIndex)

{
shaderInputVisitor.AddShaderChunk(string.Format("half4 meshUV{0} : TEXCOORD{1};", uvIndex, (uvIndex + 5)), true);
vertexShaderBlock.AddShaderChunk(string.Format("o.meshUV{0} = v.texcoord{1};", uvIndex, uvIndex == 0 ? "" : uvIndex.ToString()), true);
shaderBodyVisitor.AddShaderChunk(string.Format("half4 {0} = IN.meshUV{1};", channel.GetUVName(), uvIndex), true);
shaderBodyVisitor.AddShaderChunk("half4 " + channel.GetUVName() + " = float4(IN.localTexcoord.xyz,1.0);", true);
shaderBodyVisitor.AddShaderChunk(
"float3 "
+ ShaderGeneratorNames.WorldSpaceViewDirection
+ " = normalize(UnityWorldSpaceViewDir("
+ ShaderGeneratorNames.WorldSpacePosition
+ "));", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceViewDirection + " = float3(0.0, 0.0, -1.0);", true);
shaderInputVisitor.AddShaderChunk("float4 screenPos : TEXCOORD3;", true);
vertexShaderBlock.AddShaderChunk("o.screenPos = screenPos;", true);
shaderBodyVisitor.AddShaderChunk("half4 " + ShaderGeneratorNames.ScreenPosition + " = IN.screenPos;", true);
shaderBodyVisitor.AddShaderChunk("half4 " + ShaderGeneratorNames.ScreenPosition + " = float4(IN.globalTexcoord.xyz, 1.0);", true);
shaderInputVisitor.AddShaderChunk("float4 worldTangent : TEXCOORD4;", true);
vertexShaderBlock.AddShaderChunk("o.worldTangent = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceTangent + " = normalize(IN.worldTangent.xyz);", true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceTangent + " = float3(1.0,0.0,0.0);", true);
shaderBodyVisitor.AddShaderChunk(string.Format("float3 {0} = cross({1}, {2}) * IN.worldTangent.w;", ShaderGeneratorNames.WorldSpaceBitangent, ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.WorldSpaceTangent), true);
shaderBodyVisitor.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceBitangent + " = float3(0.0,1.0,0.0);", true);
vertexShaderBlock.AddShaderChunk("o.color = v.color;", true);
shaderBodyVisitor.AddShaderChunk("float4 " + ShaderGeneratorNames.VertexColor + " = IN.color;", true);
shaderBodyVisitor.AddShaderChunk("float4 " + ShaderGeneratorNames.VertexColor + " = float4(1.0,1.0,1.0,1.0);", true);
var generationMode = GenerationMode.Preview;
foreach (var activeNode in activeNodeList.OfType<AbstractMaterialNode>())
{
if (activeNode is IGeneratesFunction)

template = template.Replace("${ShaderName}", GetType() + guid.ToString());
template = template.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
template = template.Replace("${ShaderPropertyUsages}", shaderPropertyUsagesVisitor.GetShaderString(3));
template = template.Replace("${ShaderInputs}", shaderInputVisitor.GetShaderString(4));
template = template.Replace("${VertexShaderBody}", vertexShaderBlock.GetShaderString(4));
string vertexShaderBody = vertexShaderBlock.GetShaderString(4);
if (vertexShaderBody.Length > 0)
{
template = template.Replace("${VertexShaderDecl}", "vertex:vert");
template = template.Replace("${VertexShaderBody}", vertexShaderBody);
}
else
{
template = template.Replace("${VertexShaderDecl}", "");
template = template.Replace("${VertexShaderBody}", vertexShaderBody);
}
//In preview mode we use a different vertex shader, as the custom texture shaders are customized and not preview compatible.
template = template.Replace("${ShaderIsUsingPreview}", generationMode == GenerationMode.Preview?"_Preview":"");
configuredTextures = shaderPropertiesVisitor.GetConfiguredTexutres();
return Regex.Replace(template, @"\r\n|\n\r|\n|\r", Environment.NewLine);

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


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

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

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


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

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


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

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

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


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

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

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

10
MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs


[Serializable]
private class TextureHelper
{
public Texture2D texture;
public Texture texture;
public Texture2D defaultTexture
public Texture defaultTexture
{
get
{

}
}
#else
public Texture2D defaultTexture {get; set; }
public Texture defaultTexture {get; set; }
#endif
public TextureType textureType

return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Texture2D,
m_PropType = PropertyType.Texture,
m_Texture = defaultTexture
};
}

public override PropertyType propertyType { get { return PropertyType.Texture2D; } }
public override PropertyType propertyType { get { return PropertyType.Texture; } }
}
}

62
MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs


namespace UnityEngine.MaterialGraph
{
[Title("UV/Tri-Planar Mapping")]
public class UVTriPlanar : Function1Input, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
public class UVTriPlanar : Function3Input, IGeneratesFunction, IMayRequireNormal, IMayRequireWorldPosition
private const string kTileSlotName = "Tile";
private const string kBlendSlotName = "Blend";
protected override string GetFunctionName()
{

protected override MaterialSlot GetInputSlot()
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, kTextureSlotName, kTextureSlotName, SlotType.Input, SlotValueType.sampler2D, Vector4.zero, false);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, kTileSlotName, kTileSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.one);
}
protected override MaterialSlot GetInputSlot3()
return new MaterialSlot(InputSlotId, kTextureSlotName, kTextureSlotName, SlotType.Input, SlotValueType.sampler2D, Vector4.zero, false);
return new MaterialSlot(InputSlot3Id, kBlendSlotName, kBlendSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.one);
}
protected override MaterialSlot GetOutputSlot()

}
}
protected override string GetFunctionPrototype(string argName)
protected override string GetFunctionPrototype(string arg1Name, string arg2Name, string arg3Name)
+ "sampler2D " + argName + ", float3 normal, float3 pos)";
+ "sampler2D " + arg1Name + ", "
+ precision + " " + arg2Name + ", "
+ precision + " " + arg3Name +
", float3 normal, float3 pos)";
protected override string GetFunctionCallBody(string inputValue)
protected override string GetFunctionCallBody(string input1Value, string input2Value, string input3Value)
return GetFunctionName() + " (" + inputValue + "_Uniform" + ", IN.worldNormal, IN.worldPos)";
return GetFunctionName() + " (" + input1Value + ", " + input2Value + ", " + input3Value + ", IN.worldNormal, IN.worldPos)";
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

{
var outputString = new ShaderGenerator();
var textureSlot = FindInputSlot<MaterialSlot>(InputSlotId);
var textureSlot = FindInputSlot<MaterialSlot>(InputSlot1Id);
if (textureSlot == null)
return;

}
////////////////////////////////QQQ: Any better way of getting "_Uniform" at the end? //////////////////////////////////
// outputString.AddShaderChunk("sampler2D " + textureName + "_Uniform;", false);
// outputString.AddShaderChunk("", false);
outputString.AddShaderChunk(GetFunctionPrototype("arg"), false);
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2", "arg3"), false);
// create UVs from position
outputString.AddShaderChunk("fixed3 uvs = pos * arg2;", false);
outputString.AddShaderChunk("half3 blend = abs(normal);", false);
outputString.AddShaderChunk("half3 blend = pow(abs(normal), arg3);", false);
outputString.AddShaderChunk("fixed4 cx = tex2D(arg, pos.yz);", false);
outputString.AddShaderChunk("fixed4 cy = tex2D(arg, pos.xz);", false);
outputString.AddShaderChunk("fixed4 cz = tex2D(arg, pos.xy);", 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);
// blend the textures based on weights

outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
//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>(InputSlot1Id);
if (slot == null)
return;
var edges = owner.GetEdges(slot.slotReference).ToList();
hasError |= edges.Count == 0;
}
public bool RequiresNormal()

180
MaterialGraphProject/ProjectSettings/ProjectSettings.asset


--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 10
serializedVersion: 11
productGUID: 4a61ffcca1e65d342aac47392d65ac32
AndroidProfiler: 0
defaultScreenOrientation: 0

captureSingleScreen: 0
muteOtherAudioSources: 0
Prepare IOS For Recording: 0
Force IOS Speakers When Recording: 0
submitAnalytics: 1
usePlayerLog: 1
bakeCollisionMeshes: 0

macAppStoreCategory: public.app-category.games
gpuSkinning: 0
graphicsJobs: 0
xboxPIXTextureCapture: 0

xboxEnableFitness: 0
visibleInBackground: 0
allowFullscreenSwitch: 1
graphicsJobMode: 0
macFullscreenMode: 2
d3d9FullscreenMode: 1
d3d11FullscreenMode: 1

n3dsDisableStereoscopicView: 0
n3dsEnableSharedListOpt: 1
n3dsEnableVSync: 0
uiUse16BitDepthBuffer: 0
xboxOneDisableEsram: 0
xboxOnePresentImmediateThreshold: 0
videoMemoryForVertexBuffers: 0
psp2PowerMode: 0
psp2AcquireBGM: 1

16:10: 1
16:9: 1
Others: 1
bundleIdentifier: com.Company.ProductName
vrSettings: {}
xboxOneEnable7thCore: 0
vrSettings:
cardboard:
depthFormat: 0
enableTransitionView: 0
daydream:
depthFormat: 0
useSustainedPerformanceMode: 0
hololens:
depthFormat: 1
m_ColorGamuts: 00000000
targetPixelDensity: 0
resolutionScalingMode: 0
applicationIdentifier:
Android: com.Company.ProductName
Standalone: unity.DefaultCompany.Graphs
Tizen: com.Company.ProductName
iOS: com.Company.ProductName
tvOS: com.Company.ProductName
buildNumber:
iOS: 0
AndroidMinSdkVersion: 9
AndroidMinSdkVersion: 16
AndroidTargetSdkVersion: 0
iPhoneBuildNumber: 0
ForceInternetPermission: 0
ForceSDCardPermission: 0
CreateWallpaper: 0

iOSURLSchemes: []
iOSBackgroundModes: 0
iOSMetalForceHardShadows: 0
metalEditorSupport: 1
metalAPIValidation: 1
iOSRenderExtraFrameOnPause: 1
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:
appleEnableAutomaticSigning: 0
AndroidTargetDevice: 0
AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0}

m_BuildTargetBatching: []
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 01000000
m_APIs: 0200000001000000
m_Automatic: 0
- m_BuildTarget: AndroidPlayer
m_APIs: 08000000

wiiUGamePadStartupScreen: {fileID: 0}
wiiUDrcBufferDisabled: 0
wiiUProfilerLibPath:
playModeTestRunnerEnabled: 0
actionOnDotNetUnhandledException: 1
enableInternalProfiler: 0
logObjCUncaughtExceptions: 1

microphoneUsageDescription:
XboxTitleId:
XboxImageXexPath:
XboxSpaPath:
XboxGenerateSpa: 0
XboxDeployKinectResources: 0
XboxSplashScreen: {fileID: 0}
xboxEnableSpeech: 0
xboxAdditionalTitleMemorySize: 0
xboxDeployKinectHeadOrientation: 0
xboxDeployKinectHeadPosition: 0
switchNetLibKey:
switchSocketMemoryPoolSize: 6144
switchSocketAllocatorPoolSize: 128
switchSocketConcurrencyLimit: 14
switchScreenResolutionBehavior: 2
switchUseCPUProfiler: 0
switchApplicationID: 0x01004b9000490000
switchNSODependencies:
switchTitleNames_0:
switchTitleNames_1:
switchTitleNames_2:
switchTitleNames_3:
switchTitleNames_4:
switchTitleNames_5:
switchTitleNames_6:
switchTitleNames_7:
switchTitleNames_8:
switchTitleNames_9:
switchTitleNames_10:
switchTitleNames_11:
switchPublisherNames_0:
switchPublisherNames_1:
switchPublisherNames_2:
switchPublisherNames_3:
switchPublisherNames_4:
switchPublisherNames_5:
switchPublisherNames_6:
switchPublisherNames_7:
switchPublisherNames_8:
switchPublisherNames_9:
switchPublisherNames_10:
switchPublisherNames_11:
switchIcons_0: {fileID: 0}
switchIcons_1: {fileID: 0}
switchIcons_2: {fileID: 0}
switchIcons_3: {fileID: 0}
switchIcons_4: {fileID: 0}
switchIcons_5: {fileID: 0}
switchIcons_6: {fileID: 0}
switchIcons_7: {fileID: 0}
switchIcons_8: {fileID: 0}
switchIcons_9: {fileID: 0}
switchIcons_10: {fileID: 0}
switchIcons_11: {fileID: 0}
switchSmallIcons_0: {fileID: 0}
switchSmallIcons_1: {fileID: 0}
switchSmallIcons_2: {fileID: 0}
switchSmallIcons_3: {fileID: 0}
switchSmallIcons_4: {fileID: 0}
switchSmallIcons_5: {fileID: 0}
switchSmallIcons_6: {fileID: 0}
switchSmallIcons_7: {fileID: 0}
switchSmallIcons_8: {fileID: 0}
switchSmallIcons_9: {fileID: 0}
switchSmallIcons_10: {fileID: 0}
switchSmallIcons_11: {fileID: 0}
switchManualHTML:
switchAccessibleURLs:
switchLegalInformation:
switchMainThreadStackSize: 1048576
switchPresenceGroupId: 0x01004b9000490000
switchLogoHandling: 0
switchReleaseVersion: 0
switchDisplayVersion: 1.0.0
switchStartupUserAccount: 0
switchTouchScreenUsage: 0
switchSupportedLanguagesMask: 0
switchLogoType: 0
switchApplicationErrorCodeCategory:
switchUserAccountSaveDataSize: 0
switchUserAccountSaveDataJournalSize: 0
switchApplicationAttribute: 0
switchCardSpecSize: 4
switchCardSpecClock: 25
switchRatingsMask: 0
switchRatingsInt_0: 0
switchRatingsInt_1: 0
switchRatingsInt_2: 0
switchRatingsInt_3: 0
switchRatingsInt_4: 0
switchRatingsInt_5: 0
switchRatingsInt_6: 0
switchRatingsInt_7: 0
switchRatingsInt_8: 0
switchRatingsInt_9: 0
switchRatingsInt_10: 0
switchRatingsInt_11: 0
switchLocalCommunicationIds_0: 0x01004b9000490000
switchLocalCommunicationIds_1:
switchLocalCommunicationIds_2:
switchLocalCommunicationIds_3:
switchLocalCommunicationIds_4:
switchLocalCommunicationIds_5:
switchLocalCommunicationIds_6:
switchLocalCommunicationIds_7:
switchParentalControl: 0
switchAllowsScreenshot: 1
switchDataLossConfirmation: 0
switchSupportedNpadStyles: 3
switchSocketConfigEnabled: 0
switchTcpInitialSendBufferSize: 32
switchTcpInitialReceiveBufferSize: 64
switchTcpAutoSendBufferSizeMax: 256
switchTcpAutoReceiveBufferSizeMax: 256
switchUdpSendBufferSize: 9
switchUdpReceiveBufferSize: 42
switchSocketBufferEfficiency: 4
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:

ps4ParamSfxPath:
ps4VideoOutPixelFormat: 0
ps4VideoOutInitialWidth: 1920
ps4VideoOutBaseModeInitialWidth: 1920
ps4VideoOutReprojectionRate: 120
ps4PronunciationXMLPath:
ps4PronunciationSIGPath:

ps4ApplicationParam4: 0
ps4DownloadDataSize: 0
ps4GarlicHeapSize: 2048
ps4ProGarlicHeapSize: 2560
ps4UseDebugIl2cppLibs: 0
ps4pnSessions: 1
ps4pnPresence: 1
ps4pnFriends: 1

ps4attribShareSupport: 0
ps4attribExclusiveVR: 0
ps4disableAutoHideSplash: 0
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
monoEnv:
psp2Splashimage: {fileID: 0}

psp2UseLibLocation: 0
psp2InfoBarOnStartup: 0
psp2InfoBarColor: 0
psp2UseDebugIl2cppLibs: 0
psp2ScriptOptimizationLevel: 0
psmSplashimage: {fileID: 0}
splashScreenBackgroundSourceLandscape: {fileID: 0}
splashScreenBackgroundSourcePortrait: {fileID: 0}

Standalone: 0
incrementalIl2cppBuild: {}
additionalIl2CppArgs:
scriptingRuntimeVersion: 0
apiCompatibilityLevelPerPlatform: {}
m_RenderingPath: 1
m_MobileRenderingPath: 1

tizenMicrophonePermissions: 0
tizenDeploymentTarget:
tizenDeploymentTargetType: 0
tizenMinOSVersion: 0
tizenMinOSVersion: 1
n3dsUseExtSaveData: 0
n3dsCompressStaticMem: 1
n3dsExtSaveDataNumber: 0x12345

XboxOneSplashScreen: {fileID: 0}
XboxOneAllowedProductIds: []
XboxOnePersistentLocalStorageSize: 0
vrEditorSettings: {}
xboxOneScriptCompiler: 0
vrEditorSettings:
daydream:
daydreamIconForeground: {fileID: 0}
daydreamIconBackground: {fileID: 0}
cloudServicesEnabled:
Analytics: 0
Build: 0

projectName:
organizationId:
cloudEnabled: 0
enableNativePlatformBackendsForNewInputSystem: 0
disableOldInputManagerSupport: 0

8
MaterialGraphProject/Assets/Andre/Scenes/Andre_scene.unity


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1883063129}
m_LocalRotation: {x: 0.82629114, y: 0.24945803, z: -0.45485297, w: 0.21936849}
m_LocalRotation: {x: 0.826291, y: 0.249458, z: -0.4548529, w: 0.21936846}
m_LocalPosition: {x: -0.469, y: -0.431, z: -0.358}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2080471397}
m_LocalRotation: {x: -0.07791633, y: 0.13852377, z: -0.01431427, w: -0.98718554}
m_LocalRotation: {x: 0.039958883, y: -0.06547875, z: 0.8823947, w: -0.46421504}
m_LocalScale: {x: 0.42098072, y: 0.42098078, z: 0.42098078}
m_LocalScale: {x: 1.6328479, y: 1.6328486, z: 1.6328486}
m_LocalEulerAnglesHint: {x: -189.079, y: -195.945, z: -179.613}
m_LocalEulerAnglesHint: {x: -184.5, y: -172.431, z: -304.206}
--- !u!1 &2129034570
GameObject:
m_ObjectHideFlags: 0

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


m_Name: Mat
m_Shader: {fileID: 4800000, guid: 9ab5e16c2083a4fe689209a8c1ae425e, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}

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_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_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}
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_Floats:
- 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

9
MaterialGraphProject/Assets/Andre/Materials/Sky.mat


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Sky
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Shader: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Tex:
m_Texture: {fileID: 8900000, guid: f7111c407ddfe4109af9703cb740eaf9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Exposure: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1

- _Parallax: 0.02
- _Rotation: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}

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


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

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

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


using UnityEngine.Graphing;
[Title("Matrix/Multiply Node")]
public class MatrixMultiplyNode : Function2Input, IGeneratesFunction
[Title("Math/Matrix/MultiplyMatrix")]
public class MatrixMultiplyNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction
protected const string kInputSlot1ShaderName = "Input1";
protected const string kInputSlot2ShaderName = "Input2";
protected const string kOutputSlotShaderName = "Output";
public const int InputSlot1Id = 0;
public const int InputSlot2Id = 1;
public const int OutputSlotId = 2;
public override bool hasPreview
{
get { return false; }
}
name = "MatrixMultiplyNode";
name = "MultiplyMatrix";
UpdateNodeAfterDeserialization();
protected override string GetFunctionName()
protected string GetFunctionName()
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputSlot1());
AddSlot(GetInputSlot2());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { InputSlot1Id, InputSlot2Id, OutputSlotId }; }
}
protected MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
}
protected MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Matrix4, Vector4.zero);
}
protected MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero);
}
protected virtual string GetInputSlot1Name()
{
return "Input1";
}
protected virtual string GetInputSlot2Name()
{
return "Input2";
}
protected string GetOutputSlotName()
{
return "Output";
}
protected string GetFunctionPrototype(string arg1Name, string arg2Name)
{
return "inline " + precision + outputDimension + " " + GetFunctionName() + " ("
+ precision + input1Dimension + " " + arg1Name + ", "
+ precision + input2Dimension + " " + arg2Name + ")";
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlot1Id, InputSlot2Id }, new[] { OutputSlotId });
string input1Value = GetSlotValue(InputSlot1Id, generationMode);
string input2Value = GetSlotValue(InputSlot2Id, generationMode);
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + GetFunctionCallBody(input1Value, input2Value) + ";", true);
}
protected string GetFunctionCallBody(string input1Value, string input2Value)
{
return GetFunctionName() + " (" + input1Value + ", " + input2Value + ")";
}
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}
private string input1Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot1Id).concreteValueType); }
}
private string input2Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)

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


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

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

998
MaterialGraphProject/Assets/Andre/Scenes/EmissionTest/LightingData.asset
文件差异内容过多而无法显示
查看文件

4
MaterialGraphProject/Assets/Andre/Scenes/LightProbeTesting/ReflectionProbe-0.exr.meta


fileFormatVersion: 2
guid: 035e8eb0a74634d93a5fdf702b66c951
timeCreated: 1495567387
guid: 2d98e9d8df33a488f886cdd1eab0d9d6
timeCreated: 1495641031
licenseType: Pro
TextureImporter:
fileIDToRecycleName:

9
MaterialGraphProject/Assets/Andre/Materials.meta


fileFormatVersion: 2
guid: 7d10d324ed0f94cb09a5c4478eee9945
folderAsset: yes
timeCreated: 1495628966
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Andre/Nodes.meta


fileFormatVersion: 2
guid: 9d0a876dd165a46c6b30eac1bbbef3a7
folderAsset: yes
timeCreated: 1495628893
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Andre/Scenes.meta


fileFormatVersion: 2
guid: 788be86d1d83c4b5596351884aa015a9
folderAsset: yes
timeCreated: 1495628982
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Andre/Scripts.meta


fileFormatVersion: 2
guid: 1a53c91de66c7460fb9b67844e09076d
folderAsset: yes
timeCreated: 1495628928
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Andre/Shaders.meta


fileFormatVersion: 2
guid: 2eded065f6ee74c53a9261b91dc002ff
folderAsset: yes
timeCreated: 1495628909
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

9
MaterialGraphProject/Assets/Brandon/Electricity.ShaderGraph.meta


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

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

9
MaterialGraphProject/Assets/Brandon/Flame.ShaderGraph.meta


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

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

9
MaterialGraphProject/Assets/Code Graph.ShaderGraph.meta


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

83
MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat


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

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


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

20
MaterialGraphProject/Assets/Eduardo/ReciprocalSqrtNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Math/Advanced/Reciprocal Square Root")]
public class ReciprocalSqrtNode : Function1Input
{
public ReciprocalSqrtNode()
{
name = "ReciprocalSquareRoot";
}
public override bool hasPreview
{
get { return false; }
}
protected override string GetFunctionName() { return "rsqrt"; }
}
}

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


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

64
MaterialGraphProject/Assets/Eduardo/VertexNormalNode.cs


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

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


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

64
MaterialGraphProject/Assets/Eduardo/VertexPositionNode.cs


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

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


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

363
MaterialGraphProject/Assets/Eduardo/eduardoScene.unity


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

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


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

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

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


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

101
MaterialGraphProject/Assets/Matt/ClothMasterNode.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
[Title("Master/Cloth")]
public class ClothMasterNode : AbstractAdvancedMasterNode
{
//public const string MetallicSlotName = "Metallic";
//public const int MetallicSlotId = 2;
public const string AnisotropySlotName = "Anisotropy";
public const int AnisotropySlotId = 8;
public const string FuzzSlotName = "Fuzz";
public const int FuzzSlotId = 9;
public const string ClothFactorSlotName = "ClothFactor";
public const int ClothFactorSlotId = 10;
public const string LightFunctionName = "Advanced";
public const string SurfaceOutputStructureName = "SurfaceOutputAdvanced";
public ClothMasterNode()
{
name = "Cloth";
UpdateNodeAfterDeserialization();
}
public override string GetMaterialID()
{
return "SHADINGMODELID_CLOTH";
}
public override bool RequireTangentCalculation()
{
return true;
}
public override int[] GetCustomDataSlots()
{
return new int[] { 9, 10 };
}
public override string[] GetCustomData()
{
string fuzzInput = GetVariableNameForSlotAtId(9);
if (fuzzInput == "")
fuzzInput = "float3(0,0,0)";
else
fuzzInput = fuzzInput + ".rgb";
string clothFactorInput = GetVariableNameForSlotAtId(10);
if (clothFactorInput == "")
clothFactorInput = "0";
else
clothFactorInput = clothFactorInput + ".r";
return new string[] { "o.CustomData = float4(" + fuzzInput + ", "+ clothFactorInput + ");" };
}
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(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TangentSlotId, TangentSlotName, TangentSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(FuzzSlotId, FuzzSlotName, FuzzSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(ClothFactorSlotId, ClothFactorSlotName, ClothFactorSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
//MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
TangentSlotId,
AnisotropySlotId,
FuzzSlotId,
ClothFactorSlotId
});
}
public override string GetSurfaceOutputName()
{
return SurfaceOutputStructureName;
}
public override string GetLightFunction()
{
return LightFunctionName;
}
}
}

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


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

14
MaterialGraphProject/Assets/Matt/CommonMatrixType.cs


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

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:

9
MaterialGraphProject/Assets/Matt/Eye.meta


fileFormatVersion: 2
guid: 1150d4b56951dcb4ca61d22f832b4837
folderAsset: yes
timeCreated: 1495637066
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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

正在加载...
取消
保存