Lambert.shader 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "MTE/Surface/TextureArray/Lambert"
  4. {
  5. Properties
  6. {
  7. _Control0("Control0", 2D) = "white" {}
  8. _Control1("Control1", 2D) = "white" {}
  9. _Control2("Control2", 2D) = "white" {}
  10. [NoScaleOffset]_TextureArray0("TextureArray0", 2DArray) = "white" {}
  11. _UVScaleOffset("UVScaleOffset", Vector) = (0,0,0,0)
  12. [Toggle(_HasWeightMap2)] _HasWeightMap2("HasWeightMap2", Float) = 1
  13. [Toggle(_HasWeightMap1)] _HasWeightMap1("HasWeightMap1", Float) = 1
  14. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  15. [HideInInspector] __dirty( "", Int ) = 1
  16. }
  17. SubShader
  18. {
  19. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
  20. Cull Back
  21. CGPROGRAM
  22. #pragma target 3.0
  23. #pragma shader_feature_local _HasWeightMap1
  24. #pragma shader_feature_local _HasWeightMap2
  25. #include "../../../MTECommonPBR.hlsl"
  26. #if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))//ASE Sampler Macros
  27. #define SAMPLE_TEXTURE2D_ARRAY(tex,samplerTex,coord) tex.Sample(samplerTex,coord)
  28. #else//ASE Sampling Macros
  29. #define SAMPLE_TEXTURE2D_ARRAY(tex,samplertex,coord) tex2DArray(tex,coord)
  30. #endif//ASE Sampling Macros
  31. #pragma surface surf Lambert keepalpha addshadow fullforwardshadows
  32. struct Input
  33. {
  34. float2 uv_texcoord;
  35. };
  36. uniform sampler2D _Control0;
  37. uniform float4 _Control0_ST;
  38. uniform sampler2D _Control1;
  39. uniform float4 _Control1_ST;
  40. uniform sampler2D _Control2;
  41. uniform float4 _Control2_ST;
  42. UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_TextureArray0);
  43. uniform half4 _UVScaleOffset;
  44. SamplerState sampler_TextureArray0;
  45. float4 WeightedBlend4254( half4 Weight, float4 Layer1, float4 Layer2, float4 Layer3, float4 Layer4 )
  46. {
  47. return Layer1 * Weight.r + Layer2 * Weight.g + Layer3 * Weight.b + Layer4 * Weight.a;
  48. }
  49. void surf( Input i , inout SurfaceOutput o )
  50. {
  51. half4 localGetMax4WeightLayers245 = ( float4( 0,0,0,0 ) );
  52. float2 uv_Control0 = i.uv_texcoord * _Control0_ST.xy + _Control0_ST.zw;
  53. half4 Control0245 = tex2D( _Control0, uv_Control0 );
  54. half4 _Vector0 = half4(0,0,0,0);
  55. float2 uv_Control1 = i.uv_texcoord * _Control1_ST.xy + _Control1_ST.zw;
  56. #ifdef _HasWeightMap1
  57. half4 staticSwitch241 = tex2D( _Control1, uv_Control1 );
  58. #else
  59. half4 staticSwitch241 = _Vector0;
  60. #endif
  61. half4 Control1245 = staticSwitch241;
  62. float2 uv_Control2 = i.uv_texcoord * _Control2_ST.xy + _Control2_ST.zw;
  63. #ifdef _HasWeightMap2
  64. half4 staticSwitch242 = tex2D( _Control2, uv_Control2 );
  65. #else
  66. half4 staticSwitch242 = _Vector0;
  67. #endif
  68. half4 Control2245 = staticSwitch242;
  69. half4 Weights245 = float4( 1,0,0,0 );
  70. half4 Indices245 = float4( 1,0,0,0 );
  71. {
  72. Max4WeightLayer(Control0245, Control1245, Control2245, Weights245, Indices245);
  73. }
  74. float4 Weight254 = Weights245;
  75. half4 appendResult234 = (half4(_UVScaleOffset.x , _UVScaleOffset.y , 0.0 , 0.0));
  76. half4 appendResult237 = (half4(_UVScaleOffset.z , _UVScaleOffset.w , 0.0 , 0.0));
  77. float2 uv_TexCoord243 = i.uv_texcoord * appendResult234.xy + appendResult237.xy;
  78. half4 break248 = Indices245;
  79. float4 Layer1254 = SAMPLE_TEXTURE2D_ARRAY( _TextureArray0, sampler_TextureArray0, float3(uv_TexCoord243,break248.x) );
  80. float4 Layer2254 = SAMPLE_TEXTURE2D_ARRAY( _TextureArray0, sampler_TextureArray0, float3(uv_TexCoord243,break248.y) );
  81. float4 Layer3254 = SAMPLE_TEXTURE2D_ARRAY( _TextureArray0, sampler_TextureArray0, float3(uv_TexCoord243,break248.z) );
  82. float4 Layer4254 = SAMPLE_TEXTURE2D_ARRAY( _TextureArray0, sampler_TextureArray0, float3(uv_TexCoord243,break248.w) );
  83. float4 localWeightedBlend4254 = WeightedBlend4254( Weight254 , Layer1254 , Layer2254 , Layer3254 , Layer4254 );
  84. o.Albedo = localWeightedBlend4254.xyz;
  85. o.Alpha = 1;
  86. }
  87. ENDCG
  88. }
  89. Fallback "Nature/Terrain/Diffuse"
  90. CustomEditor "ASEMaterialInspector"
  91. }
  92. /*ASEBEGIN
  93. Version=18927
  94. -7;36;1920;983;948.3203;1063.585;2.120107;True;False
  95. Node;AmplifyShaderEditor.CommentaryNode;227;-821.3513,-713.6486;Inherit;False;1549.657;668.5775;;13;245;242;241;240;239;238;236;235;233;232;231;229;228;Fetch max 4 weighted layers;1,1,1,1;0;0
  96. Node;AmplifyShaderEditor.TexturePropertyNode;229;-799.3513,-469.1873;Float;True;Property;_Control1;Control1;1;0;Create;True;0;0;0;False;0;False;None;3894e48e39432304a84d7e32938932d8;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
  97. Node;AmplifyShaderEditor.TexturePropertyNode;228;-794.0494,-264.8109;Float;True;Property;_Control2;Control2;2;0;Create;True;0;0;0;False;0;False;None;119bde9018dae1944850c9f5f73b4d6a;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
  98. Node;AmplifyShaderEditor.TexturePropertyNode;231;-797.0493,-653.6486;Float;True;Property;_Control0;Control0;0;0;Create;True;0;0;0;False;0;False;None;c1288408ae4d8f546a6cdb65ac755646;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
  99. Node;AmplifyShaderEditor.TextureCoordinatesNode;232;-548.1508,-403.6502;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  100. Node;AmplifyShaderEditor.TextureCoordinatesNode;233;-542.8482,-199.2738;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  101. Node;AmplifyShaderEditor.SamplerNode;239;-288.6776,-466.4474;Inherit;True;Property;_ControlEx;ControlEx;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  102. Node;AmplifyShaderEditor.SamplerNode;238;-283.3751,-262.071;Inherit;True;Property;_TextureSample0;Texture Sample 0;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  103. Node;AmplifyShaderEditor.Vector4Node;236;-2.410011,-424.2649;Inherit;False;Constant;_Vector0;Vector 0;7;0;Create;True;0;0;0;False;0;False;0,0,0,0;0,0,0,0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  104. Node;AmplifyShaderEditor.TextureCoordinatesNode;235;-542.8488,-586.1115;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  105. Node;AmplifyShaderEditor.CommentaryNode;244;802.7973,-385.0916;Inherit;False;1034.99;911.0148;By default, RGB is Albedo.;10;252;253;250;251;248;247;243;237;234;230;Sample from first TextureArray2D;1,1,1,1;0;0
  106. Node;AmplifyShaderEditor.Vector4Node;230;840.1151,251.7337;Inherit;False;Property;_UVScaleOffset;UVScaleOffset;4;0;Create;True;0;0;0;False;0;False;0,0,0,0;5,5,0,0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  107. Node;AmplifyShaderEditor.SamplerNode;240;-295.4816,-651.1327;Inherit;True;Property;_TextureSample1;Texture Sample 1;1;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  108. Node;AmplifyShaderEditor.StaticSwitch;241;192.1346,-494.4469;Inherit;False;Property;_HasWeightMap1;HasWeightMap1;6;0;Create;False;0;0;0;False;0;False;0;1;1;True;_HasWeightMap1;Toggle;2;Key0;Key1;Create;True;False;9;1;FLOAT4;0,0,0,0;False;0;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;3;FLOAT4;0,0,0,0;False;4;FLOAT4;0,0,0,0;False;5;FLOAT4;0,0,0,0;False;6;FLOAT4;0,0,0,0;False;7;FLOAT4;0,0,0,0;False;8;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  109. Node;AmplifyShaderEditor.StaticSwitch;242;193.7366,-387.4635;Inherit;False;Property;_HasWeightMap2;HasWeightMap2;5;0;Create;False;0;0;0;False;0;False;0;1;1;True;_HasWeightMap2;Toggle;2;Key0;Key1;Create;True;False;9;1;FLOAT4;0,0,0,0;False;0;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;3;FLOAT4;0,0,0,0;False;4;FLOAT4;0,0,0,0;False;5;FLOAT4;0,0,0,0;False;6;FLOAT4;0,0,0,0;False;7;FLOAT4;0,0,0,0;False;8;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  110. Node;AmplifyShaderEditor.DynamicAppendNode;237;1062.854,364.9227;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
  111. Node;AmplifyShaderEditor.CustomExpressionNode;245;507.1738,-530.3986;Inherit;False;Max4WeightLayer(Control0, Control1, Control2, Weights, Indices)@;7;Create;5;True;Control0;FLOAT4;1,0,0,0;In;;Inherit;False;True;Control1;FLOAT4;0,0,0,0;In;;Inherit;False;True;Control2;FLOAT4;0,0,0,0;In;;Inherit;False;True;Weights;FLOAT4;1,0,0,0;Out;;Inherit;False;True;Indices;FLOAT4;1,0,0,0;Out;;Half;False;GetMax4WeightLayers;False;False;0;;False;6;0;FLOAT4;0,0,0,0;False;1;FLOAT4;1,0,0,0;False;2;FLOAT4;0,0,0,0;False;3;FLOAT4;0,0,0,0;False;4;FLOAT4;1,0,0,0;False;5;FLOAT4;1,0,0,0;False;3;FLOAT4;0;FLOAT4;5;FLOAT4;6
  112. Node;AmplifyShaderEditor.DynamicAppendNode;234;1062.287,223.1026;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
  113. Node;AmplifyShaderEditor.TextureCoordinatesNode;243;1252.632,277.9955;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  114. Node;AmplifyShaderEditor.TexturePropertyNode;247;845.0573,-262.2738;Inherit;True;Property;_TextureArray0;TextureArray0;3;1;[NoScaleOffset];Create;True;0;0;0;False;0;False;None;83bf8c0c79dd17741ba3ecafc0843724;False;white;LockedToTexture2DArray;Texture2DArray;-1;0;2;SAMPLER2DARRAY;0;SAMPLERSTATE;1
  115. Node;AmplifyShaderEditor.BreakToComponentsNode;248;846.257,-68.26346;Inherit;False;FLOAT4;1;0;FLOAT4;0,0,0,0;False;16;FLOAT;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT;5;FLOAT;6;FLOAT;7;FLOAT;8;FLOAT;9;FLOAT;10;FLOAT;11;FLOAT;12;FLOAT;13;FLOAT;14;FLOAT;15
  116. Node;AmplifyShaderEditor.SamplerNode;251;1504.983,254.1083;Inherit;True;Property;_TextureSample4;Texture Sample 4;6;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2DArray;8;0;SAMPLER2DARRAY;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  117. Node;AmplifyShaderEditor.SamplerNode;250;1500.404,-337.2257;Inherit;True;Property;_Layer0;Layer0;3;0;Fetch;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2DArray;8;0;SAMPLER2DARRAY;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  118. Node;AmplifyShaderEditor.SamplerNode;253;1502.258,-140.0546;Inherit;True;Property;_TextureSample2;Texture Sample 2;4;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2DArray;8;0;SAMPLER2DARRAY;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  119. Node;AmplifyShaderEditor.SamplerNode;252;1503.683,59.10812;Inherit;True;Property;_TextureSample3;Texture Sample 3;5;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2DArray;8;0;SAMPLER2DARRAY;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  120. Node;AmplifyShaderEditor.CustomExpressionNode;254;2010.555,-501.1415;Float;False;return Layer1 * Weight.r + Layer2 * Weight.g + Layer3 * Weight.b + Layer4 * Weight.a@;4;Create;5;True;Weight;FLOAT4;0,0,0,0;In;float[5];Half;False;True;Layer1;FLOAT4;0,0,0,0;In;;Float;False;True;Layer2;FLOAT4;0,0,0,0;In;;Float;False;True;Layer3;FLOAT4;0,0,0,0;In;;Float;False;True;Layer4;FLOAT4;0,0,0,0;In;;Float;False;Weighted Blend 4;True;False;0;;False;5;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;3;FLOAT4;0,0,0,0;False;4;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  121. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;216;2276.232,-502.9881;Half;False;True;-1;2;ASEMaterialInspector;0;0;Lambert;MTE/Surface/TextureArray/Lambert;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;All;18;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;True;Relative;0;Nature/Terrain/Diffuse;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;1;Include;../../../MTECommonPBR.hlsl;False;fa510ed2a5a3b2d4a9ef902d0fbdd6e2;Custom;0;0;False;0.1;False;-1;0;False;-1;False;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
  122. WireConnection;232;2;229;0
  123. WireConnection;233;2;228;0
  124. WireConnection;239;0;229;0
  125. WireConnection;239;1;232;0
  126. WireConnection;238;0;228;0
  127. WireConnection;238;1;233;0
  128. WireConnection;235;2;231;0
  129. WireConnection;240;0;231;0
  130. WireConnection;240;1;235;0
  131. WireConnection;241;1;236;0
  132. WireConnection;241;0;239;0
  133. WireConnection;242;1;236;0
  134. WireConnection;242;0;238;0
  135. WireConnection;237;0;230;3
  136. WireConnection;237;1;230;4
  137. WireConnection;245;1;240;0
  138. WireConnection;245;2;241;0
  139. WireConnection;245;3;242;0
  140. WireConnection;234;0;230;1
  141. WireConnection;234;1;230;2
  142. WireConnection;243;0;234;0
  143. WireConnection;243;1;237;0
  144. WireConnection;248;0;245;6
  145. WireConnection;251;0;247;0
  146. WireConnection;251;1;243;0
  147. WireConnection;251;6;248;3
  148. WireConnection;250;0;247;0
  149. WireConnection;250;1;243;0
  150. WireConnection;250;6;248;0
  151. WireConnection;253;0;247;0
  152. WireConnection;253;1;243;0
  153. WireConnection;253;6;248;1
  154. WireConnection;252;0;247;0
  155. WireConnection;252;1;243;0
  156. WireConnection;252;6;248;2
  157. WireConnection;254;0;245;5
  158. WireConnection;254;1;250;0
  159. WireConnection;254;2;253;0
  160. WireConnection;254;3;252;0
  161. WireConnection;254;4;251;0
  162. WireConnection;216;0;254;0
  163. ASEEND*/
  164. //CHKSM=59111EBCAF5E7C095A54FFE42802FE61D303CBE5