Leaves.shader 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "Leaves"
  4. {
  5. Properties
  6. {
  7. _Texture("Texture", 2D) = "white" {}
  8. _Cutoff( "Mask Clip Value", Float ) = 0.5
  9. _Color("Color ", Color) = (0,0,0,0)
  10. _Smoothness("Smoothness", Range( 0 , 1)) = 0
  11. _OveralTrasslucensy("Overal Trasslucensy", Range( 0 , 1)) = 0
  12. [Header(Translucency)]
  13. _Translucency("Strength", Range( 0 , 50)) = 1
  14. _TransNormalDistortion("Normal Distortion", Range( 0 , 1)) = 0.1
  15. _TransScattering("Scaterring Falloff", Range( 1 , 50)) = 2
  16. _TransDirect("Direct", Range( 0 , 1)) = 1
  17. _TransAmbient("Ambient", Range( 0 , 1)) = 0.2
  18. _TransShadow("Shadow", Range( 0 , 1)) = 0.9
  19. [Header(Wind)]
  20. _TimeScale("Time Scale", Float) = 1
  21. _NoiseScale("Noise Scale", Float) = 0
  22. _Intensity("Intensity", Range( 0 , 1)) = 0.56
  23. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  24. [HideInInspector] __dirty( "", Int ) = 1
  25. }
  26. SubShader
  27. {
  28. Tags{ "RenderType" = "TransparentCutout" "Queue" = "AlphaTest+0" }
  29. Cull Off
  30. CGPROGRAM
  31. #include "UnityShaderVariables.cginc"
  32. #include "UnityPBSLighting.cginc"
  33. #pragma target 3.0
  34. #pragma surface surf StandardCustom keepalpha addshadow fullforwardshadows exclude_path:deferred vertex:vertexDataFunc
  35. struct Input
  36. {
  37. float3 worldPos;
  38. float2 uv_texcoord;
  39. };
  40. struct SurfaceOutputStandardCustom
  41. {
  42. half3 Albedo;
  43. half3 Normal;
  44. half3 Emission;
  45. half Metallic;
  46. half Smoothness;
  47. half Occlusion;
  48. half Alpha;
  49. half3 Translucency;
  50. };
  51. uniform float _TimeScale;
  52. uniform float _NoiseScale;
  53. uniform float _Intensity;
  54. uniform sampler2D _Texture;
  55. uniform float4 _Texture_ST;
  56. uniform float4 _Color;
  57. uniform float _Smoothness;
  58. uniform half _Translucency;
  59. uniform half _TransNormalDistortion;
  60. uniform half _TransScattering;
  61. uniform half _TransDirect;
  62. uniform half _TransAmbient;
  63. uniform half _TransShadow;
  64. uniform float _OveralTrasslucensy;
  65. uniform float _Cutoff = 0.5;
  66. float3 mod2D289( float3 x ) { return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0; }
  67. float2 mod2D289( float2 x ) { return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0; }
  68. float3 permute( float3 x ) { return mod2D289( ( ( x * 34.0 ) + 1.0 ) * x ); }
  69. float snoise( float2 v )
  70. {
  71. const float4 C = float4( 0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439 );
  72. float2 i = floor( v + dot( v, C.yy ) );
  73. float2 x0 = v - i + dot( i, C.xx );
  74. float2 i1;
  75. i1 = ( x0.x > x0.y ) ? float2( 1.0, 0.0 ) : float2( 0.0, 1.0 );
  76. float4 x12 = x0.xyxy + C.xxzz;
  77. x12.xy -= i1;
  78. i = mod2D289( i );
  79. float3 p = permute( permute( i.y + float3( 0.0, i1.y, 1.0 ) ) + i.x + float3( 0.0, i1.x, 1.0 ) );
  80. float3 m = max( 0.5 - float3( dot( x0, x0 ), dot( x12.xy, x12.xy ), dot( x12.zw, x12.zw ) ), 0.0 );
  81. m = m * m;
  82. m = m * m;
  83. float3 x = 2.0 * frac( p * C.www ) - 1.0;
  84. float3 h = abs( x ) - 0.5;
  85. float3 ox = floor( x + 0.5 );
  86. float3 a0 = x - ox;
  87. m *= 1.79284291400159 - 0.85373472095314 * ( a0 * a0 + h * h );
  88. float3 g;
  89. g.x = a0.x * x0.x + h.x * x0.y;
  90. g.yz = a0.yz * x12.xz + h.yz * x12.yw;
  91. return 130.0 * dot( m, g );
  92. }
  93. void vertexDataFunc( inout appdata_full v, out Input o )
  94. {
  95. UNITY_INITIALIZE_OUTPUT( Input, o );
  96. float3 ase_worldPos = mul( unity_ObjectToWorld, v.vertex );
  97. float2 appendResult7 = (float2(ase_worldPos.x , ase_worldPos.z));
  98. float mulTime10 = _Time.y * _TimeScale;
  99. float simplePerlin2D8 = snoise( ( appendResult7 + mulTime10 )*_NoiseScale );
  100. simplePerlin2D8 = simplePerlin2D8*0.5 + 0.5;
  101. float3 break13 = float3( 0,0,0 );
  102. float3 appendResult14 = (float3(( ( ( ( simplePerlin2D8 - 0.5 ) * _Intensity ) * v.texcoord.xy.y ) + break13.x ) , break13.y , break13.z));
  103. v.vertex.xyz += appendResult14;
  104. }
  105. inline half4 LightingStandardCustom(SurfaceOutputStandardCustom s, half3 viewDir, UnityGI gi )
  106. {
  107. #if !DIRECTIONAL
  108. float3 lightAtten = gi.light.color;
  109. #else
  110. float3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, _TransShadow );
  111. #endif
  112. half3 lightDir = gi.light.dir + s.Normal * _TransNormalDistortion;
  113. half transVdotL = pow( saturate( dot( viewDir, -lightDir ) ), _TransScattering );
  114. half3 translucency = lightAtten * (transVdotL * _TransDirect + gi.indirect.diffuse * _TransAmbient) * s.Translucency;
  115. half4 c = half4( s.Albedo * translucency * _Translucency, 0 );
  116. SurfaceOutputStandard r;
  117. r.Albedo = s.Albedo;
  118. r.Normal = s.Normal;
  119. r.Emission = s.Emission;
  120. r.Metallic = s.Metallic;
  121. r.Smoothness = s.Smoothness;
  122. r.Occlusion = s.Occlusion;
  123. r.Alpha = s.Alpha;
  124. return LightingStandard (r, viewDir, gi) + c;
  125. }
  126. inline void LightingStandardCustom_GI(SurfaceOutputStandardCustom s, UnityGIInput data, inout UnityGI gi )
  127. {
  128. #if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
  129. gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal);
  130. #else
  131. UNITY_GLOSSY_ENV_FROM_SURFACE( g, s, data );
  132. gi = UnityGlobalIllumination( data, s.Occlusion, s.Normal, g );
  133. #endif
  134. }
  135. void surf( Input i , inout SurfaceOutputStandardCustom o )
  136. {
  137. float2 uv_Texture = i.uv_texcoord * _Texture_ST.xy + _Texture_ST.zw;
  138. float4 tex2DNode1 = tex2D( _Texture, uv_Texture );
  139. o.Albedo = ( tex2DNode1 * _Color ).rgb;
  140. o.Smoothness = _Smoothness;
  141. float3 temp_cast_1 = (_OveralTrasslucensy).xxx;
  142. o.Translucency = temp_cast_1;
  143. o.Alpha = 1;
  144. clip( tex2DNode1.r - _Cutoff );
  145. }
  146. ENDCG
  147. }
  148. Fallback "Diffuse"
  149. CustomEditor "ASEMaterialInspector"
  150. }
  151. /*ASEBEGIN
  152. Version=17800
  153. 365.6;107.2;998;555;1470.285;-211.4571;1.926908;True;False
  154. Node;AmplifyShaderEditor.WorldPosInputsNode;6;-1258.837,453.7143;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  155. Node;AmplifyShaderEditor.RangedFloatNode;11;-1249.917,632.6704;Inherit;False;Property;_TimeScale;Time Scale;12;0;Create;True;0;0;False;0;1;0;0;0;0;1;FLOAT;0
  156. Node;AmplifyShaderEditor.SimpleTimeNode;10;-1105.77,614.7917;Inherit;False;1;0;FLOAT;1;False;1;FLOAT;0
  157. Node;AmplifyShaderEditor.DynamicAppendNode;7;-1061.648,507.3891;Inherit;False;FLOAT2;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT2;0
  158. Node;AmplifyShaderEditor.SimpleAddOpNode;9;-916.9277,549.9821;Inherit;False;2;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0
  159. Node;AmplifyShaderEditor.RangedFloatNode;12;-983.2989,699.1873;Inherit;False;Property;_NoiseScale;Noise Scale;13;0;Create;True;0;0;False;0;0;0;0;0;0;1;FLOAT;0
  160. Node;AmplifyShaderEditor.NoiseGeneratorNode;8;-774.7252,600.2847;Inherit;False;Simplex2D;True;False;2;0;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT;0
  161. Node;AmplifyShaderEditor.RangedFloatNode;18;-702.8166,748.0563;Inherit;False;Property;_Intensity;Intensity;14;0;Create;True;0;0;False;0;0.56;0.56;0;1;0;1;FLOAT;0
  162. Node;AmplifyShaderEditor.SimpleSubtractOpNode;16;-573.7995,619.0392;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0.5;False;1;FLOAT;0
  163. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;17;-420.8221,661.4305;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  164. Node;AmplifyShaderEditor.TextureCoordinatesNode;22;-559.4156,840.6301;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
  165. Node;AmplifyShaderEditor.BreakToComponentsNode;13;-594.2363,460.3222;Inherit;False;FLOAT3;1;0;FLOAT3;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
  166. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;26;-302.6714,803.9523;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  167. Node;AmplifyShaderEditor.ColorNode;3;-457.7523,-121.2623;Inherit;False;Property;_Color;Color ;2;0;Create;True;0;0;False;0;0,0,0,0;0,0,0,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  168. Node;AmplifyShaderEditor.SamplerNode;1;-521.421,64.43827;Inherit;True;Property;_Texture;Texture;0;0;Create;True;0;0;False;0;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;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;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  169. Node;AmplifyShaderEditor.SimpleAddOpNode;21;-136.5932,643.4832;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  170. Node;AmplifyShaderEditor.RangedFloatNode;5;-328.6462,333.262;Inherit;False;Property;_OveralTrasslucensy;Overal Trasslucensy;4;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
  171. Node;AmplifyShaderEditor.RangedFloatNode;4;-332.1833,257.2131;Inherit;False;Property;_Smoothness;Smoothness;3;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
  172. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;2;-157.0942,-8.073392;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
  173. Node;AmplifyShaderEditor.DynamicAppendNode;14;-227.8748,459.9063;Inherit;False;FLOAT3;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT3;0
  174. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;188.9836,95.82609;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;Leaves;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Off;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Masked;0.5;True;True;0;False;TransparentCutout;;AlphaTest;ForwardOnly;14;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;Relative;0;;1;5;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;16;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;5;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
  175. WireConnection;10;0;11;0
  176. WireConnection;7;0;6;1
  177. WireConnection;7;1;6;3
  178. WireConnection;9;0;7;0
  179. WireConnection;9;1;10;0
  180. WireConnection;8;0;9;0
  181. WireConnection;8;1;12;0
  182. WireConnection;16;0;8;0
  183. WireConnection;17;0;16;0
  184. WireConnection;17;1;18;0
  185. WireConnection;26;0;17;0
  186. WireConnection;26;1;22;2
  187. WireConnection;21;0;26;0
  188. WireConnection;21;1;13;0
  189. WireConnection;2;0;1;0
  190. WireConnection;2;1;3;0
  191. WireConnection;14;0;21;0
  192. WireConnection;14;1;13;1
  193. WireConnection;14;2;13;2
  194. WireConnection;0;0;2;0
  195. WireConnection;0;4;4;0
  196. WireConnection;0;7;5;0
  197. WireConnection;0;10;1;0
  198. WireConnection;0;11;14;0
  199. ASEEND*/
  200. //CHKSM=A89C06103A671A9A3E932329DA63386DA6F54924