FoliageWind.shader 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "Custom/Lordenfel/FoliageWind"
  4. {
  5. Properties
  6. {
  7. _Albedo("Albedo", 2D) = "white" {}
  8. _ColorOverlay("Color Overlay", Color) = (0.7075472,0.7075472,0.7075472,1)
  9. _Desaturation("Desaturation", Float) = 0
  10. _Cutoff( "Mask Clip Value", Float ) = 0.25
  11. _Normal("Normal", 2D) = "bump" {}
  12. _Specular("Specular", Float) = 0.1
  13. _SmoothnessMin("Smoothness Min", Float) = 0.2
  14. _SmoothnessMax("Smoothness Max", Float) = 0.8
  15. _Transmission("Transmission", Float) = 3.6
  16. _WindNormal("Wind Normal", 2D) = "white" {}
  17. _WindOverallIntensity("Wind Overall Intensity", Float) = 0.025
  18. _WindScalePrimary("Wind Scale Primary", Float) = 55
  19. _WindScaleSecondary("Wind Scale Secondary", Float) = 20
  20. _WindSecondaryIntensity("Wind Secondary Intensity", Float) = 0.5
  21. _TimeScale("Time Scale", Float) = 1
  22. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  23. [HideInInspector] __dirty( "", Int ) = 1
  24. }
  25. SubShader
  26. {
  27. Tags{ "RenderType" = "Opaque" "Queue" = "AlphaTest+0" }
  28. Cull Off
  29. CGPROGRAM
  30. #include "UnityShaderVariables.cginc"
  31. #include "UnityPBSLighting.cginc"
  32. #pragma target 3.0
  33. #pragma surface surf StandardSpecularCustom keepalpha addshadow fullforwardshadows exclude_path:deferred vertex:vertexDataFunc
  34. struct Input
  35. {
  36. float3 worldPos;
  37. float2 uv_texcoord;
  38. };
  39. struct SurfaceOutputStandardSpecularCustom
  40. {
  41. half3 Albedo;
  42. half3 Normal;
  43. half3 Emission;
  44. half3 Specular;
  45. half Smoothness;
  46. half Occlusion;
  47. half Alpha;
  48. half3 Transmission;
  49. };
  50. uniform sampler2D _WindNormal;
  51. uniform float _TimeScale;
  52. uniform float _WindScalePrimary;
  53. uniform float _WindScaleSecondary;
  54. uniform float _WindSecondaryIntensity;
  55. uniform float _WindOverallIntensity;
  56. uniform sampler2D _Normal;
  57. uniform float4 _Normal_ST;
  58. uniform sampler2D _Albedo;
  59. uniform float4 _Albedo_ST;
  60. uniform float4 _ColorOverlay;
  61. uniform float _Desaturation;
  62. uniform float _Specular;
  63. uniform float _SmoothnessMin;
  64. uniform float _SmoothnessMax;
  65. uniform float _Transmission;
  66. uniform float _Cutoff = 0.25;
  67. void vertexDataFunc( inout appdata_full v, out Input o )
  68. {
  69. UNITY_INITIALIZE_OUTPUT( Input, o );
  70. float mulTime10 = _Time.y * _TimeScale;
  71. float3 ase_worldPos = mul( unity_ObjectToWorld, v.vertex );
  72. float2 temp_output_3_0 = (ase_worldPos).xz;
  73. float2 panner1 = ( mulTime10 * float2( 0.05,0.05 ) + ( temp_output_3_0 / _WindScalePrimary ));
  74. float3 tex2DNode13 = UnpackNormal( tex2Dlod( _WindNormal, float4( panner1, 0, 0.0) ) );
  75. float4 appendResult15 = (float4(tex2DNode13.r , tex2DNode13.g , 0.0 , 0.0));
  76. float2 panner11 = ( mulTime10 * float2( 0.05,0.05 ) + ( temp_output_3_0 / _WindScaleSecondary ));
  77. float3 tex2DNode14 = UnpackNormal( tex2Dlod( _WindNormal, float4( panner11, 0, 0.0) ) );
  78. float4 appendResult16 = (float4(tex2DNode14.r , tex2DNode14.g , 0.0 , 0.0));
  79. v.vertex.xyz += ( v.color.r * ( ( appendResult15 + ( appendResult16 * _WindSecondaryIntensity ) ) * _WindOverallIntensity ) ).xyz;
  80. }
  81. inline half4 LightingStandardSpecularCustom(SurfaceOutputStandardSpecularCustom s, half3 viewDir, UnityGI gi )
  82. {
  83. half3 transmission = max(0 , -dot(s.Normal, gi.light.dir)) * gi.light.color * s.Transmission;
  84. half4 d = half4(s.Albedo * transmission , 0);
  85. SurfaceOutputStandardSpecular r;
  86. r.Albedo = s.Albedo;
  87. r.Normal = s.Normal;
  88. r.Emission = s.Emission;
  89. r.Specular = s.Specular;
  90. r.Smoothness = s.Smoothness;
  91. r.Occlusion = s.Occlusion;
  92. r.Alpha = s.Alpha;
  93. return LightingStandardSpecular (r, viewDir, gi) + d;
  94. }
  95. inline void LightingStandardSpecularCustom_GI(SurfaceOutputStandardSpecularCustom s, UnityGIInput data, inout UnityGI gi )
  96. {
  97. #if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
  98. gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal);
  99. #else
  100. UNITY_GLOSSY_ENV_FROM_SURFACE( g, s, data );
  101. gi = UnityGlobalIllumination( data, s.Occlusion, s.Normal, g );
  102. #endif
  103. }
  104. void surf( Input i , inout SurfaceOutputStandardSpecularCustom o )
  105. {
  106. float2 uv_Normal = i.uv_texcoord * _Normal_ST.xy + _Normal_ST.zw;
  107. o.Normal = UnpackNormal( tex2D( _Normal, uv_Normal ) );
  108. float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
  109. float4 tex2DNode26 = tex2D( _Albedo, uv_Albedo );
  110. float4 blendOpSrc27 = tex2DNode26;
  111. float4 blendOpDest27 = _ColorOverlay;
  112. float3 desaturateInitialColor29 = ( saturate( (( blendOpDest27 > 0.5 ) ? ( 1.0 - 2.0 * ( 1.0 - blendOpDest27 ) * ( 1.0 - blendOpSrc27 ) ) : ( 2.0 * blendOpDest27 * blendOpSrc27 ) ) )).rgb;
  113. float desaturateDot29 = dot( desaturateInitialColor29, float3( 0.299, 0.587, 0.114 ));
  114. float3 desaturateVar29 = lerp( desaturateInitialColor29, desaturateDot29.xxx, _Desaturation );
  115. o.Albedo = desaturateVar29;
  116. float3 temp_cast_1 = (_Specular).xxx;
  117. o.Specular = temp_cast_1;
  118. float lerpResult32 = lerp( _SmoothnessMin , _SmoothnessMax , tex2DNode26.r);
  119. o.Smoothness = lerpResult32;
  120. o.Transmission = ( desaturateVar29 * _Transmission );
  121. o.Alpha = 1;
  122. clip( tex2DNode26.a - _Cutoff );
  123. }
  124. ENDCG
  125. }
  126. Fallback "Standard (Specular setup)"
  127. CustomEditor "ASEMaterialInspector"
  128. }
  129. /*ASEBEGIN
  130. Version=18100
  131. 531;149;1779;1215;3331.939;449.3379;1.3;True;False
  132. Node;AmplifyShaderEditor.WorldPosInputsNode;2;-2535.652,172.8645;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  133. Node;AmplifyShaderEditor.RangedFloatNode;9;-1991.652,236.8645;Inherit;False;Property;_TimeScale;Time Scale;14;0;Create;True;0;0;False;0;False;1;1;0;0;0;1;FLOAT;0
  134. Node;AmplifyShaderEditor.RangedFloatNode;7;-2279.652,477.8646;Inherit;False;Property;_WindScaleSecondary;Wind Scale Secondary;12;0;Create;True;0;0;False;0;False;20;20;0;0;0;1;FLOAT;0
  135. Node;AmplifyShaderEditor.ComponentMaskNode;3;-2343.652,172.8645;Inherit;False;True;False;True;True;1;0;FLOAT3;0,0,0;False;1;FLOAT2;0
  136. Node;AmplifyShaderEditor.SimpleDivideOpNode;6;-1927.652,460.8646;Inherit;False;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0
  137. Node;AmplifyShaderEditor.RangedFloatNode;5;-2279.652,-19.13544;Inherit;False;Property;_WindScalePrimary;Wind Scale Primary;11;0;Create;True;0;0;False;0;False;55;55;0;0;0;1;FLOAT;0
  138. Node;AmplifyShaderEditor.SimpleTimeNode;10;-1831.652,252.8645;Inherit;False;1;0;FLOAT;1;False;1;FLOAT;0
  139. Node;AmplifyShaderEditor.SimpleDivideOpNode;4;-1911.651,-35.13544;Inherit;False;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0
  140. Node;AmplifyShaderEditor.TexturePropertyNode;12;-1559.652,140.8645;Inherit;True;Property;_WindNormal;Wind Normal;9;0;Create;True;0;0;False;0;False;0bb17834cc720194f89841cadc732585;0bb17834cc720194f89841cadc732585;True;white;Auto;Texture2D;-1;0;1;SAMPLER2D;0
  141. Node;AmplifyShaderEditor.PannerNode;11;-1607.652,460.8646;Inherit;False;3;0;FLOAT2;0,0;False;2;FLOAT2;0.05,0.05;False;1;FLOAT;1;False;1;FLOAT2;0
  142. Node;AmplifyShaderEditor.SamplerNode;14;-1223.652,428.8646;Inherit;True;Property;_TextureSample1;Texture Sample 1;4;0;Create;True;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;True;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;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  143. Node;AmplifyShaderEditor.PannerNode;1;-1607.652,-35.13544;Inherit;False;3;0;FLOAT2;0,0;False;2;FLOAT2;0.05,0.05;False;1;FLOAT;1;False;1;FLOAT2;0
  144. Node;AmplifyShaderEditor.RangedFloatNode;18;-983.6519,668.8646;Inherit;False;Property;_WindSecondaryIntensity;Wind Secondary Intensity;13;0;Create;True;0;0;False;0;False;0.5;0.5;0;0;0;1;FLOAT;0
  145. Node;AmplifyShaderEditor.SamplerNode;13;-1223.652,-67.13544;Inherit;True;Property;_TextureSample0;Texture Sample 0;7;0;Create;True;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;True;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;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  146. Node;AmplifyShaderEditor.DynamicAppendNode;16;-871.6518,460.8646;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
  147. Node;AmplifyShaderEditor.DynamicAppendNode;15;-871.6518,-40.96073;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
  148. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;17;-642.4935,455.8276;Inherit;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT;0;False;1;FLOAT4;0
  149. Node;AmplifyShaderEditor.ColorNode;28;-601.2238,-467.2599;Inherit;False;Property;_ColorOverlay;Color Overlay;1;0;Create;True;0;0;False;0;False;0.7075472,0.7075472,0.7075472,1;0.593,0.593,0.593,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  150. Node;AmplifyShaderEditor.SamplerNode;26;-691.1865,-665.7307;Inherit;True;Property;_Albedo;Albedo;0;0;Create;True;0;0;False;0;False;-1;None;145e501f8d46f0d47a959cfb77f03f10;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
  151. Node;AmplifyShaderEditor.BlendOpsNode;27;-174.1867,-665.7307;Inherit;False;Overlay;True;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;1;False;1;COLOR;0
  152. Node;AmplifyShaderEditor.RangedFloatNode;30;-106.9867,-539.3307;Inherit;False;Property;_Desaturation;Desaturation;2;0;Create;True;0;0;False;0;False;0;0;0;0;0;1;FLOAT;0
  153. Node;AmplifyShaderEditor.SimpleAddOpNode;20;-484.8837,131.3649;Inherit;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  154. Node;AmplifyShaderEditor.RangedFloatNode;19;-415.6374,266.6115;Inherit;False;Property;_WindOverallIntensity;Wind Overall Intensity;10;0;Create;True;0;0;False;0;False;0.025;0.05;0;0;0;1;FLOAT;0
  155. Node;AmplifyShaderEditor.DesaturateOpNode;29;123.8133,-660.7307;Inherit;False;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
  156. Node;AmplifyShaderEditor.RangedFloatNode;35;180.6829,-97.20806;Inherit;False;Property;_Transmission;Transmission;8;0;Create;True;0;0;False;0;False;3.6;10;0;0;0;1;FLOAT;0
  157. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;21;-137.5703,133.5289;Inherit;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT;0;False;1;FLOAT4;0
  158. Node;AmplifyShaderEditor.RangedFloatNode;34;-618.3838,-124.4315;Inherit;False;Property;_SmoothnessMax;Smoothness Max;7;0;Create;True;0;0;False;0;False;0.8;1;0;0;0;1;FLOAT;0
  159. Node;AmplifyShaderEditor.RangedFloatNode;33;-614.3838,-207.4315;Inherit;False;Property;_SmoothnessMin;Smoothness Min;6;0;Create;True;0;0;False;0;False;0.2;0.2;0;0;0;1;FLOAT;0
  160. Node;AmplifyShaderEditor.VertexColorNode;22;-65.07824,-88.27535;Inherit;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  161. Node;AmplifyShaderEditor.LerpOp;32;-345.3837,-186.4315;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0
  162. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;23;155.644,111.8895;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  163. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;36;385.7829,-129.9081;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
  164. Node;AmplifyShaderEditor.RangedFloatNode;31;442.0779,-217.3011;Inherit;False;Property;_Specular;Specular;5;0;Create;True;0;0;False;0;False;0.1;0.05;0;0;0;1;FLOAT;0
  165. Node;AmplifyShaderEditor.SamplerNode;37;128.9473,-437.8199;Inherit;True;Property;_Normal;Normal;4;0;Create;True;0;0;False;0;False;-1;None;a720937d2ba0ace42a0881ddef30c8e6;True;0;True;bump;Auto;True;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;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  166. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;636.5704,-281.199;Float;False;True;-1;2;ASEMaterialInspector;0;0;StandardSpecular;Custom/Lordenfel/FoliageWind;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;Custom;0.25;True;True;0;True;Opaque;;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;Standard (Specular setup);3;-1;-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;FLOAT3;0,0,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
  167. WireConnection;3;0;2;0
  168. WireConnection;6;0;3;0
  169. WireConnection;6;1;7;0
  170. WireConnection;10;0;9;0
  171. WireConnection;4;0;3;0
  172. WireConnection;4;1;5;0
  173. WireConnection;11;0;6;0
  174. WireConnection;11;1;10;0
  175. WireConnection;14;0;12;0
  176. WireConnection;14;1;11;0
  177. WireConnection;1;0;4;0
  178. WireConnection;1;1;10;0
  179. WireConnection;13;0;12;0
  180. WireConnection;13;1;1;0
  181. WireConnection;16;0;14;1
  182. WireConnection;16;1;14;2
  183. WireConnection;15;0;13;1
  184. WireConnection;15;1;13;2
  185. WireConnection;17;0;16;0
  186. WireConnection;17;1;18;0
  187. WireConnection;27;0;26;0
  188. WireConnection;27;1;28;0
  189. WireConnection;20;0;15;0
  190. WireConnection;20;1;17;0
  191. WireConnection;29;0;27;0
  192. WireConnection;29;1;30;0
  193. WireConnection;21;0;20;0
  194. WireConnection;21;1;19;0
  195. WireConnection;32;0;33;0
  196. WireConnection;32;1;34;0
  197. WireConnection;32;2;26;1
  198. WireConnection;23;0;22;1
  199. WireConnection;23;1;21;0
  200. WireConnection;36;0;29;0
  201. WireConnection;36;1;35;0
  202. WireConnection;0;0;29;0
  203. WireConnection;0;1;37;0
  204. WireConnection;0;3;31;0
  205. WireConnection;0;4;32;0
  206. WireConnection;0;6;36;0
  207. WireConnection;0;10;26;4
  208. WireConnection;0;11;23;0
  209. ASEEND*/
  210. //CHKSM=9C7FC4E58645A0AD1813D22B31070ADB783D7E37