浏览代码

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

/main
Matt Dean 7 年前
当前提交
eed9ee0e
共有 15 个文件被更改,包括 383 次插入155 次删除
  1. 2
      MaterialGraphProject/Assets/Brandon/Cellular/Cellular.ShaderGraph
  2. 292
      MaterialGraphProject/Assets/Brandon/Cellular/Cellular.shader
  3. 4
      MaterialGraphProject/Assets/Brandon/Cellular/Cellular_Material.mat
  4. 2
      MaterialGraphProject/Assets/Florent/2Pass_Edited.ShaderGraph
  5. 2
      MaterialGraphProject/Assets/Florent/UnityEngine.MaterialGraph.ExportTextureMasterNode8e1be5fc-7506-4529-879d-f1ce8c5aab04.mat
  6. 1
      MaterialGraphProject/Assets/NewNodes/WIP/AACheckerBoardNode.cs
  7. 138
      MaterialGraphProject/Assets/NewNodes/WIP/AnyNode.cs
  8. 1
      MaterialGraphProject/Assets/NewNodes/WIP/RadialShearNode.cs
  9. 2
      MaterialGraphProject/Assets/NewNodes/WIP/ScaleOffsetNode.cs
  10. 2
      MaterialGraphProject/Assets/NewNodes/WIP/SphereWarpNode.cs
  11. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  12. 69
      MaterialGraphProject/Assets/NewNodes/WIP/SphericalIndentationNode.cs
  13. 12
      MaterialGraphProject/Assets/NewNodes/WIP/SphericalIndentationNode.cs.meta
  14. 1
      MaterialGraphProject/Assets/SphereDent.ShaderGraph
  15. 9
      MaterialGraphProject/Assets/SphereDent.ShaderGraph.meta

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

292
MaterialGraphProject/Assets/Brandon/Cellular/Cellular.shader


Shader "Brandon/Cellular"
Shader "Brandon/Cellular"
Properties
{
Properties
{
Texture_b86ff54c_bbe9_4694_8531_326cc9640f0b_Uniform("Texture", 2D) = "white" {}
}
}
SubShader
{
Tags
{
"RenderType"="Opaque"
"Queue"="Geometry"
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"Queue" = "Geometry"
}
Blend One Zero
Blend One Zero
Cull Back
Cull Back
ZTest LEqual
ZTest LEqual
ZWrite On
ZWrite On
LOD 200
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard vertex:vert
#pragma glsl
#pragma debug
LOD 200
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard vertex:vert
#pragma glsl
#pragma debug
inline float4 unity_remap_float(float4 arg1, float2 arg2, float2 arg3)
{
return arg3.x + (arg1 - arg2.x) * (arg3.y - arg3.x) / (arg2.y - arg2.x);
}
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 void unity_voronoinoise_float(float2 uv, float angleOffset, out float n1, out float n2, out float n3)
{
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);
n1 = res.x;
n2 = res.y;
n3 = 1.0 - res.x;
}
}
}
}
inline float unity_particle_float(float2 uv, float scaleFactor)
{
uv = uv * 2.0 - 1.0;
return abs(1.0 / length(uv * scaleFactor));
}
inline float unity_oneminus_float(float arg1)
{
return arg1 * -1 + 1;
}
inline float unity_multiply_float(float arg1, float arg2)
{
return arg1 * arg2;
}
inline float3 unity_multiply_float(float3 arg1, float3 arg2)
{
return arg1 * arg2;
}
inline float2 unity_uvpanner_float(float2 UV, float HorizontalOffset, float VerticalOffset)
{
return float2(UV.x + HorizontalOffset, UV.y + VerticalOffset);
}
inline float3 unity_add_float(float3 arg1, float3 arg2)
{
return arg1 + arg2;
}
inline float3 unity_rgbtolinear_float(float3 arg1)
{
float3 linearRGBLo = arg1 / 12.92;
float3 linearRGBHi = pow(max(abs((arg1 + 0.055) / 1.055), 1.192092896e-07), float3(2.4, 2.4, 2.4));
return float3(arg1 <= 0.04045) ? linearRGBLo : linearRGBHi;
}
sampler2D Texture_b86ff54c_bbe9_4694_8531_326cc9640f0b_Uniform;
inline float4 unity_remap_float (float4 arg1, float2 arg2, float2 arg3)
{
return arg3.x + (arg1 - arg2.x) * (arg3.y - arg3.x) / (arg2.y - arg2.x);
}
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 void unity_voronoinoise_float (float2 uv, float angleOffset, out float n1, out float n2, out float n3)
{
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);
n1 = res.x;
n2 = res.y;
n3 = 1.0 - res.x;
}
}
}
}
inline float unity_particle_float (float2 uv, float scaleFactor)
{
uv = uv * 2.0 - 1.0;
return abs(1.0/length(uv * scaleFactor));
}
inline float unity_oneminus_float (float arg1)
{
return arg1 * -1 + 1;
}
inline float unity_multiply_float (float arg1, float arg2)
{
return arg1 * arg2;
}
inline float3 unity_multiply_float (float3 arg1, float3 arg2)
{
return arg1 * arg2;
}
inline float2 unity_uvpanner_float (float2 UV, float HorizontalOffset, float VerticalOffset)
{
return float2(UV.x + HorizontalOffset, UV.y + VerticalOffset);
}
inline float3 unity_add_float (float3 arg1, float3 arg2)
{
return arg1 + arg2;
}
inline float3 unity_rgbtolinear_float (float3 arg1)
{
float3 linearRGBLo = arg1 / 12.92;
float3 linearRGBHi = pow(max(abs((arg1 + 0.055) / 1.055), 1.192092896e-07), float3(2.4, 2.4, 2.4));
return float3(arg1 <= 0.04045) ? linearRGBLo : linearRGBHi;
}
inline float4 unity_oneminus_float (float4 arg1)
{
return arg1 * -1 + 1;
}
inline void unity_CustomCode_test (float d, float dp, out float c)
{
c = step(dp, d);
}
struct Input
{
float4 color : COLOR;
half4 meshUV0;
};
struct Input
{
float4 color : COLOR;
half4 meshUV0;
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.meshUV0 = v.texcoord;
};
}
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.meshUV0 = v.texcoord;
void surf(Input IN, inout SurfaceOutputStandard o)
{
half4 uv0 = IN.meshUV0;
float3 Vector3_ff318061_3405_4489_b0c0_004f3556b379_Uniform = float3 (3, 2.5, 5);
float4 UV_257dbdde_fb0e_45d2_b1d5_3245a77a7446_UV = uv0;
float4 Remap_e2de5e87_5108_4e55_91d0_202c89bfdc77_Output = unity_remap_float(UV_257dbdde_fb0e_45d2_b1d5_3245a77a7446_UV, float2 (0,1), float2 (-10,10));
float VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n1;
float VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n2;
float VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n3;
unity_voronoinoise_float(Remap_e2de5e87_5108_4e55_91d0_202c89bfdc77_Output, _Time.y, VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n1, VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n2, VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n3);
float4 UV_b1e148d9_f64d_4409_bc93_047246acb763_UV = uv0;
float Particle_bc661883_3410_41aa_9c40_9841d35071d1_Output = unity_particle_float(UV_b1e148d9_f64d_4409_bc93_047246acb763_UV, 2.44);
float OneMinus_ed098cd5_7e1f_43c8_aa71_e28f93649eb3_Output = unity_oneminus_float(Particle_bc661883_3410_41aa_9c40_9841d35071d1_Output);
float Multiply_f23a464e_ad77_4844_96be_5f17a4ee2ad5_Output = unity_multiply_float(VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n1, OneMinus_ed098cd5_7e1f_43c8_aa71_e28f93649eb3_Output);
float Saturate_4f751b04_b16e_426b_8661_93bba25e78ea_Output = saturate(Multiply_f23a464e_ad77_4844_96be_5f17a4ee2ad5_Output);
float3 Multiply_51e47dbb_3a27_43fb_85f3_075820b6f397_Output = unity_multiply_float(Vector3_ff318061_3405_4489_b0c0_004f3556b379_Uniform, Saturate_4f751b04_b16e_426b_8661_93bba25e78ea_Output);
float4 UV_f53721a3_b62f_474c_8348_cd27dce64004_UV = uv0;
float4 Remap_fc254320_74c6_4929_9c55_12b74013aa50_Output = unity_remap_float(UV_f53721a3_b62f_474c_8348_cd27dce64004_UV, float2 (0,1), float2 (-10,10));
float VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n1;
float VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n2;
float VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n3;
unity_voronoinoise_float(Remap_fc254320_74c6_4929_9c55_12b74013aa50_Output, _Time.z, VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n1, VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n2, VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n3);
float2 UVPanner_a7d52543_81f8_4b8f_9f48_a83f6390465f_Output = unity_uvpanner_float(Remap_fc254320_74c6_4929_9c55_12b74013aa50_Output, 0.45, 0.45);
float Particle_ff7ecb20_7b31_4549_a468_0da4421a2b0e_Output = unity_particle_float(UVPanner_a7d52543_81f8_4b8f_9f48_a83f6390465f_Output, -0.78);
float SmoothStep_d93b46f2_249b_4b3a_93a9_70e542a367ea_Output = smoothstep(0.15, 0.4, Particle_ff7ecb20_7b31_4549_a468_0da4421a2b0e_Output);
float Multiply_3002b60e_2a73_4b04_9567_798629fb7fb7_Output = unity_multiply_float(VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n3, SmoothStep_d93b46f2_249b_4b3a_93a9_70e542a367ea_Output);
float Saturate_848599e3_7853_4ad1_9dc9_d854e0c98884_Output = saturate(Multiply_3002b60e_2a73_4b04_9567_798629fb7fb7_Output);
float3 Vector3_ed4329c2_0a82_4467_816a_99ed1694361d_Uniform = float3 (2, 4, 8);
float3 Multiply_196a897c_4a8f_4c02_87f1_4818aeec305d_Output = unity_multiply_float(Saturate_848599e3_7853_4ad1_9dc9_d854e0c98884_Output, Vector3_ed4329c2_0a82_4467_816a_99ed1694361d_Uniform);
float3 Add_371d52ad_c3e8_484a_8546_7079c5df37df_Output = unity_add_float(Multiply_51e47dbb_3a27_43fb_85f3_075820b6f397_Output, Multiply_196a897c_4a8f_4c02_87f1_4818aeec305d_Output);
float3 RGBtoLinear_b45ced7c_417b_406b_9524_9699354a5af9_Output = unity_rgbtolinear_float(Add_371d52ad_c3e8_484a_8546_7079c5df37df_Output);
float Vector1_514d9c2d_f80f_4ffd_824e_58e3f2d8a162_Uniform = 1;
o.Emission = RGBtoLinear_b45ced7c_417b_406b_9524_9699354a5af9_Output;
o.Alpha = Vector1_514d9c2d_f80f_4ffd_824e_58e3f2d8a162_Uniform;
}
void surf (Input IN, inout SurfaceOutputStandard o)
{
half4 uv0 = IN.meshUV0;
float3 Vector3_ff318061_3405_4489_b0c0_004f3556b379_Uniform = float3 (3, 2.5, 5);
float4 UV_257dbdde_fb0e_45d2_b1d5_3245a77a7446_UV = uv0;
float4 Remap_e2de5e87_5108_4e55_91d0_202c89bfdc77_Output = unity_remap_float (UV_257dbdde_fb0e_45d2_b1d5_3245a77a7446_UV, float2 (0,1), float2 (-10,10));
float VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n1;
float VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n2;
float VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n3;
unity_voronoinoise_float (Remap_e2de5e87_5108_4e55_91d0_202c89bfdc77_Output, _Time.y, VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n1, VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n2, VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n3);
float4 UV_b1e148d9_f64d_4409_bc93_047246acb763_UV = uv0;
float Particle_bc661883_3410_41aa_9c40_9841d35071d1_Output = unity_particle_float (UV_b1e148d9_f64d_4409_bc93_047246acb763_UV, 2.44);
float OneMinus_ed098cd5_7e1f_43c8_aa71_e28f93649eb3_Output = unity_oneminus_float (Particle_bc661883_3410_41aa_9c40_9841d35071d1_Output);
float Multiply_f23a464e_ad77_4844_96be_5f17a4ee2ad5_Output = unity_multiply_float (VoronoiNoise_6363f48c_fb0a_4d4a_b0a0_e9c095b25f14_n1, OneMinus_ed098cd5_7e1f_43c8_aa71_e28f93649eb3_Output);
float Saturate_4f751b04_b16e_426b_8661_93bba25e78ea_Output = saturate (Multiply_f23a464e_ad77_4844_96be_5f17a4ee2ad5_Output);
float3 Multiply_51e47dbb_3a27_43fb_85f3_075820b6f397_Output = unity_multiply_float (Vector3_ff318061_3405_4489_b0c0_004f3556b379_Uniform, Saturate_4f751b04_b16e_426b_8661_93bba25e78ea_Output);
float4 UV_f53721a3_b62f_474c_8348_cd27dce64004_UV = uv0;
float4 Remap_fc254320_74c6_4929_9c55_12b74013aa50_Output = unity_remap_float (UV_f53721a3_b62f_474c_8348_cd27dce64004_UV, float2 (0,1), float2 (-10,10));
float VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n1;
float VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n2;
float VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n3;
unity_voronoinoise_float (Remap_fc254320_74c6_4929_9c55_12b74013aa50_Output, _Time.z, VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n1, VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n2, VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n3);
float2 UVPanner_a7d52543_81f8_4b8f_9f48_a83f6390465f_Output = unity_uvpanner_float (Remap_fc254320_74c6_4929_9c55_12b74013aa50_Output, 0.45, 0.45);
float Particle_ff7ecb20_7b31_4549_a468_0da4421a2b0e_Output = unity_particle_float (UVPanner_a7d52543_81f8_4b8f_9f48_a83f6390465f_Output, -0.78);
float SmoothStep_d93b46f2_249b_4b3a_93a9_70e542a367ea_Output = smoothstep (0.15, 0.4, Particle_ff7ecb20_7b31_4549_a468_0da4421a2b0e_Output);
float Multiply_3002b60e_2a73_4b04_9567_798629fb7fb7_Output = unity_multiply_float (VoronoiNoise_5d4bee83_6fb2_48e2_b332_76a7ce558de7_n3, SmoothStep_d93b46f2_249b_4b3a_93a9_70e542a367ea_Output);
float Saturate_848599e3_7853_4ad1_9dc9_d854e0c98884_Output = saturate (Multiply_3002b60e_2a73_4b04_9567_798629fb7fb7_Output);
float3 Vector3_ed4329c2_0a82_4467_816a_99ed1694361d_Uniform = float3 (2, 4, 8);
float3 Multiply_196a897c_4a8f_4c02_87f1_4818aeec305d_Output = unity_multiply_float (Saturate_848599e3_7853_4ad1_9dc9_d854e0c98884_Output, Vector3_ed4329c2_0a82_4467_816a_99ed1694361d_Uniform);
float3 Add_371d52ad_c3e8_484a_8546_7079c5df37df_Output = unity_add_float (Multiply_51e47dbb_3a27_43fb_85f3_075820b6f397_Output, Multiply_196a897c_4a8f_4c02_87f1_4818aeec305d_Output);
float3 RGBtoLinear_b45ced7c_417b_406b_9524_9699354a5af9_Output = unity_rgbtolinear_float (Add_371d52ad_c3e8_484a_8546_7079c5df37df_Output);
float4 UV_f07867b1_de17_49e3_8e83_602340969ed4_UV = uv0;
float4 Texture_b86ff54c_bbe9_4694_8531_326cc9640f0b = tex2D (Texture_b86ff54c_bbe9_4694_8531_326cc9640f0b_Uniform, (UV_f07867b1_de17_49e3_8e83_602340969ed4_UV.xy));
float4 OneMinus_4ee34df0_3179_41cf_b2d7_f7a3a8a7795e_Output = unity_oneminus_float (Texture_b86ff54c_bbe9_4694_8531_326cc9640f0b);
float3 Multiply_a8ff6c5c_5b0d_413a_b22d_7a95b12dadbc_Output = unity_multiply_float (RGBtoLinear_b45ced7c_417b_406b_9524_9699354a5af9_Output, OneMinus_4ee34df0_3179_41cf_b2d7_f7a3a8a7795e_Output);
float CustomCode_de9dc268_2bcc_4906_804c_bd10b50ad4f4_c;
unity_CustomCode_test (OneMinus_4ee34df0_3179_41cf_b2d7_f7a3a8a7795e_Output, 0.57, CustomCode_de9dc268_2bcc_4906_804c_bd10b50ad4f4_c);
float Multiply_2f548bb2_d578_4b2b_b00c_20897ee877b3_Output = unity_multiply_float (CustomCode_de9dc268_2bcc_4906_804c_bd10b50ad4f4_c, 0.75);
float3 Add_e67d33e0_c8c9_451a_9962_408b4fa9f2e9_Output = unity_add_float (Multiply_a8ff6c5c_5b0d_413a_b22d_7a95b12dadbc_Output, Multiply_2f548bb2_d578_4b2b_b00c_20897ee877b3_Output);
float Vector1_514d9c2d_f80f_4ffd_824e_58e3f2d8a162_Uniform = 1;
o.Emission = Add_e67d33e0_c8c9_451a_9962_408b4fa9f2e9_Output;
o.Alpha = Vector1_514d9c2d_f80f_4ffd_824e_58e3f2d8a162_Uniform;
}
ENDCG
}
}
ENDCG
}
FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
}

4
MaterialGraphProject/Assets/Brandon/Cellular/Cellular_Material.mat


m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- Texture_b86ff54c_bbe9_4694_8531_326cc9640f0b_Uniform:
m_Texture: {fileID: 2800000, guid: ad78029cb3832214ca442896e68ae18f, 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}

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

2
MaterialGraphProject/Assets/Florent/UnityEngine.MaterialGraph.ExportTextureMasterNode8e1be5fc-7506-4529-879d-f1ce8c5aab04.mat


serializedVersion: 3
m_TexEnvs:
- Texture_52494c62_81e0_463e_aa3f_fadca56482fa_Uniform:
m_Texture: {fileID: 2800000, guid: 1113532d825090c49a910c0c7832a690, type: 3}
m_Texture: {fileID: 2800000, guid: 153d265862621434696692a6c4c4400c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_bcbba8c3_42d3_4afd_970e_817d00cd2f76_Uniform:

1
MaterialGraphProject/Assets/NewNodes/WIP/AACheckerBoardNode.cs


};
}
}
public ShaderGlobal[] globals { get { return new ShaderGlobal[] { }; } }
public string hlsl
{

138
MaterialGraphProject/Assets/NewNodes/WIP/AnyNode.cs


namespace UnityEngine.MaterialGraph
{
public enum ShaderGlobal
{
UV0,
UV1,
UV2,
UV3,
WorldSpaceNormal,
WorldSpaceBitangent,
WorldSpaceTangent,
WorldSpacePosition,
WorldSpaceViewDirection,
TangentSpaceViewDirection,
ScreenPosition,
VertexColor,
}
[Serializable]
public class AnyNodeSlot
{

string name { get; }
AnyNodeProperty[] properties { get; }
AnyNodeSlot[] outputs { get; }
ShaderGlobal[] globals { get; }
string hlsl { get; }
}

[SerializeField]
protected AnyNodeSlot[] m_outputSlots;
[SerializeField]
protected ShaderGlobal[] m_globals;
public IEnumerable<AnyNodeProperty> properties
{

AnyNodeBase
, IGeneratesBodyCode
, IGeneratesFunction
// , IMayRequireMeshUV
// , IMayRequireNormal // TODO
// , IMayRequireTangent
// , IMayRequireBitangent
// , IMayRequireScreenPosition
// , IMayRequireViewDirection
// , IMayRequireWorldPosition
// , IMayRequireVertexColor
, IMayRequireViewDirectionTangentSpace
/* , IMayRequireMeshUV
, IOnAssetEnabled // TODO
, IMayRequireNormal // TODO
, IMayRequireTangent
, IMayRequireBitangent
, IMayRequireScreenPosition
, IMayRequireViewDirection
, IMayRequireWorldPosition
, IMayRequireVertexColor
, IMayRequireViewDirectionTangentSpace
*/
where DEFINITION : IAnyNodeDefinition, new()
{
private DEFINITION m_definition;

m_outputSlots = m_definition.outputs;
m_globals = m_definition.globals;
UpdateNodeAfterDeserialization();
}

// now that we've copied the old data into the new properties, start using the new properties
m_properties = new_properties;
m_outputSlots = new_outputs;
m_globals = m_definition.globals;
List<int> validSlotIds = new List<int>();

}
}
public bool RequiresViewDirectionTangentSpace()
{
return (Array.FindIndex(m_globals, x => x == ShaderGlobal.TangentSpaceViewDirection) >= 0);
}
// properties.AddRange(subGraph.GetPreviewProperties()); // ???
switch (p.propertyType)
{
case PropertyType.Float:

return "unity_any_" + node_name + "_" + precision;
}
private string GetShaderGlobalName(ShaderGlobal g)
{
string globalname = null;
switch (g)
{
case ShaderGlobal.UV0:
globalname = ShaderGeneratorNames.GetUVName(UVChannel.uv0);
break;
case ShaderGlobal.UV1:
globalname = ShaderGeneratorNames.GetUVName(UVChannel.uv1);
break;
case ShaderGlobal.UV2:
globalname = ShaderGeneratorNames.GetUVName(UVChannel.uv2);
break;
case ShaderGlobal.UV3:
globalname = ShaderGeneratorNames.GetUVName(UVChannel.uv3);
break;
case ShaderGlobal.WorldSpaceNormal:
globalname = ShaderGeneratorNames.WorldSpaceNormal;
break;
case ShaderGlobal.WorldSpaceBitangent:
globalname = ShaderGeneratorNames.WorldSpaceBitangent;
break;
case ShaderGlobal.WorldSpaceTangent:
globalname = ShaderGeneratorNames.WorldSpaceTangent;
break;
case ShaderGlobal.WorldSpacePosition:
globalname = ShaderGeneratorNames.WorldSpacePosition;
break;
case ShaderGlobal.WorldSpaceViewDirection:
globalname = ShaderGeneratorNames.WorldSpaceViewDirection;
break;
case ShaderGlobal.TangentSpaceViewDirection:
globalname = ShaderGeneratorNames.TangentSpaceViewDirection;
break;
case ShaderGlobal.ScreenPosition:
globalname = ShaderGeneratorNames.ScreenPosition;
break;
case ShaderGlobal.VertexColor:
globalname = ShaderGeneratorNames.VertexColor;
break;
}
return globalname;
}
private string GetShaderGlobalTypeDecl(ShaderGlobal g)
{
string typeDecl = null;
switch (g)
{
case ShaderGlobal.UV0:
case ShaderGlobal.UV1:
case ShaderGlobal.UV2:
case ShaderGlobal.UV3:
typeDecl = "float4";
break;
case ShaderGlobal.WorldSpaceNormal:
case ShaderGlobal.WorldSpaceBitangent:
case ShaderGlobal.WorldSpaceTangent:
case ShaderGlobal.WorldSpacePosition:
case ShaderGlobal.WorldSpaceViewDirection:
case ShaderGlobal.TangentSpaceViewDirection:
typeDecl = "float3";
break;
case ShaderGlobal.ScreenPosition:
typeDecl = "float2";
break;
case ShaderGlobal.VertexColor:
typeDecl = "float4";
break;
}
return typeDecl;
}
protected virtual string GetFunctionPrototype()
{
string result = "inline void " + GetFunctionName() + "(";

}
// then 'globals'
// TODO
foreach (ShaderGlobal g in m_globals)
{
result += "in " + GetShaderGlobalTypeDecl(g) + " " + GetShaderGlobalName(g) + ", ";
}
// then outputs
foreach (AnyNodeSlot s in m_outputSlots)

inputVariableName = p.name;
}
outputString.AddShaderChunk((first ? "" : ",") + inputVariableName, false);
first = false;
}
outputString.AddShaderChunk("// global parameters", false);
foreach (ShaderGlobal g in m_globals)
{
outputString.AddShaderChunk((first ? "" : ",") + GetShaderGlobalName(g), false);
first = false;
}

1
MaterialGraphProject/Assets/NewNodes/WIP/RadialShearNode.cs


};
}
}
public ShaderGlobal[] globals { get { return new ShaderGlobal[] { }; } }
public string hlsl
{

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


}
}
public ShaderGlobal[] globals { get { return new ShaderGlobal[] { }; } }
public string hlsl
{
get

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


}
}
public ShaderGlobal[] globals { get { return new ShaderGlobal[]{ }; } }
public string hlsl
{
get

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


typeMapper[typeof(ScaleOffsetNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(RadialShearNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphereWarpNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SphericalIndentationNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(AACheckerboardNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter
typeMapper[typeof(SubGraphNode)] = typeof(SubgraphNodePresenter);
typeMapper[typeof(RemapMasterNode)] = typeof(RemapMasterNodePresenter);

69
MaterialGraphProject/Assets/NewNodes/WIP/SphericalIndentationNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("UV/SphericalIndentation")]
public class SphericalIndentationNode : AnyNode<SphericalIndentationNode.Definition>
{
public class Definition : IAnyNodeDefinition
{
public string name { get { return "SphericalIndentation"; } }
public AnyNodeProperty[] properties
{
get
{
return new AnyNodeProperty[]
{
// slotId is the 'immutable' value we used to connect things
new AnyNodeProperty { slotId= 0, name = "inUVs", description = "Input UV coords", propertyType = PropertyType.Vector2, value = Vector4.zero, state = AnyNodePropertyState.Slot },
new AnyNodeProperty { slotId= 1, name = "center", description = "UV center point", propertyType = PropertyType.Vector2, value= new Vector4(0.5f, 0.5f, 0.5f, 0.5f), state = AnyNodePropertyState.Constant },
new AnyNodeProperty { slotId= 2, name = "height", description = "Height off surface", propertyType = PropertyType.Float, value= Vector4.zero, state = AnyNodePropertyState.Constant },
new AnyNodeProperty { slotId= 3, name = "radius", description = "Radius", propertyType = PropertyType.Float, value= Vector4.one, state = AnyNodePropertyState.Constant },
};
}
}
public AnyNodeSlot[] outputs
{
get
{
return new AnyNodeSlot[]
{
new AnyNodeSlot { slotId= 4, name = "outUVs", description = "Output UV texture coordinates", slotValueType = SlotValueType.Vector2, value = Vector4.zero },
new AnyNodeSlot { slotId= 5, name = "outNormal", description = "Output Normal in tangent space", slotValueType = SlotValueType.Vector3, value = Vector4.zero }
};
}
}
public ShaderGlobal[] globals { get { return new ShaderGlobal[] { ShaderGlobal.TangentSpaceViewDirection }; } }
public string hlsl
{
get
{
return
"float radius2= radius*radius;\n" +
"float3 cur= float3(inUVs.xy, 0.0f);\n" +
"float3 sphereCenter = float3(center, height);\n" +
"float3 edgeA = sphereCenter - cur;\n" +
"float a2 = dot(edgeA, edgeA);\n" +
"outUVs= inUVs;\n" +
"outNormal= float3(0.0f, 0.0f, 1.0f);\n" +
"if (a2 < radius2)\n" +
"{\n" +
" float a = sqrt(a2);\n" +
" edgeA = edgeA / a;\n" +
" float cosineR = dot(edgeA, tangentSpaceViewDirection.xyz);\n" +
" float x = cosineR * a - sqrt(-a2 + radius2 + a2 * cosineR * cosineR);\n" +
" float3 intersectedEdge = cur + tangentSpaceViewDirection * x;\n" +
" outNormal= normalize(sphereCenter - intersectedEdge);\n" +
" outUVs = intersectedEdge.xy;\n" +
"}\n";
}
}
}
}
}

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


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

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

9
MaterialGraphProject/Assets/SphereDent.ShaderGraph.meta


fileFormatVersion: 2
guid: b63da350811f7ba48914e852a299204c
timeCreated: 1495747830
licenseType: Pro
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
正在加载...
取消
保存