You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
10 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "GrassBlades"
  4. {
  5. Properties
  6. {
  7. _TessValue( "Max Tessellation", Range( 1, 32 ) ) = 15
  8. _TreeOffset("Tree Offset", Vector) = (0,5,0,0)
  9. _MainTex("MainTex", 2D) = "white" {}
  10. _TreeInstanceColor("TreeInstanceColor", Color) = (0,0,0,0)
  11. _TreeInstanceScale("_TreeInstanceScale", Vector) = (0,0,0,0)
  12. _SecondaryFactor("SecondaryFactor", Float) = 0
  13. _PrimaryFactor("PrimaryFactor", Float) = 0
  14. _EdgeFlutter("EdgeFlutter", Float) = 1
  15. _BranchPhase("BranchPhase", Float) = 0
  16. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  17. [HideInInspector] __dirty( "", Int ) = 1
  18. }
  19. SubShader
  20. {
  21. Tags{ "RenderType" = "TreeBillboard" "Queue" = "Transparent+0" "IgnoreProjector" = "True" }
  22. Cull Off
  23. ZWrite Off
  24. Blend SrcAlpha OneMinusSrcAlpha
  25. CGINCLUDE
  26. #include "UnityPBSLighting.cginc"
  27. #include "Lighting.cginc"
  28. #pragma target 4.6
  29. #include "TerrainEngine.cginc"
  30. struct Input
  31. {
  32. float3 worldPos;
  33. float2 uv_texcoord;
  34. };
  35. uniform float _BranchPhase;
  36. uniform float _EdgeFlutter;
  37. uniform float _PrimaryFactor;
  38. uniform float _SecondaryFactor;
  39. uniform float3 _TreeOffset;
  40. uniform sampler2D _MainTex;
  41. uniform float4 _MainTex_ST;
  42. uniform float _TessValue;
  43. float4 WindAnimateVertex1_g2( float4 Pos , float3 Normal , float4 AnimParams )
  44. {
  45. return AnimateVertex(Pos,Normal,AnimParams);
  46. }
  47. float4 tessFunction( )
  48. {
  49. return _TessValue;
  50. }
  51. void vertexDataFunc( inout appdata_full v )
  52. {
  53. float4 ase_vertex4Pos = v.vertex;
  54. float4 Pos1_g2 = ase_vertex4Pos;
  55. float3 ase_vertexNormal = v.normal.xyz;
  56. float3 Normal1_g2 = ase_vertexNormal;
  57. float3 ase_worldPos = mul( unity_ObjectToWorld, v.vertex );
  58. float3 normalizeResult52 = normalize( ase_worldPos );
  59. float4 appendResult15 = (float4(_BranchPhase , ( _EdgeFlutter * ( (normalizeResult52).x + (normalizeResult52).z ) ) , _PrimaryFactor , _SecondaryFactor));
  60. float4 AnimParams1_g2 = appendResult15;
  61. float4 localWindAnimateVertex1_g2 = WindAnimateVertex1_g2( Pos1_g2 , Normal1_g2 , AnimParams1_g2 );
  62. v.vertex.xyz = ( ( localWindAnimateVertex1_g2 * _TreeInstanceScale ) + float4( _TreeOffset , 0.0 ) ).xyz;
  63. }
  64. void surf( Input i , inout SurfaceOutputStandard o )
  65. {
  66. float2 uv_MainTex = i.uv_texcoord * _MainTex_ST.xy + _MainTex_ST.zw;
  67. float4 tex2DNode3 = tex2D( _MainTex, uv_MainTex );
  68. o.Albedo = ( _TreeInstanceColor * tex2DNode3 ).rgb;
  69. o.Alpha = tex2DNode3.a;
  70. }
  71. ENDCG
  72. CGPROGRAM
  73. #pragma surface surf Standard keepalpha fullforwardshadows vertex:vertexDataFunc tessellate:tessFunction
  74. ENDCG
  75. Pass
  76. {
  77. Name "ShadowCaster"
  78. Tags{ "LightMode" = "ShadowCaster" }
  79. ZWrite On
  80. CGPROGRAM
  81. #pragma vertex vert
  82. #pragma fragment frag
  83. #pragma target 4.6
  84. #pragma multi_compile_shadowcaster
  85. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  86. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  87. #include "HLSLSupport.cginc"
  88. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  89. #define CAN_SKIP_VPOS
  90. #endif
  91. #include "UnityCG.cginc"
  92. #include "Lighting.cginc"
  93. #include "UnityPBSLighting.cginc"
  94. sampler3D _DitherMaskLOD;
  95. struct v2f
  96. {
  97. V2F_SHADOW_CASTER;
  98. float2 customPack1 : TEXCOORD1;
  99. float3 worldPos : TEXCOORD2;
  100. UNITY_VERTEX_INPUT_INSTANCE_ID
  101. };
  102. v2f vert( appdata_full v )
  103. {
  104. v2f o;
  105. UNITY_SETUP_INSTANCE_ID( v );
  106. UNITY_INITIALIZE_OUTPUT( v2f, o );
  107. UNITY_TRANSFER_INSTANCE_ID( v, o );
  108. Input customInputData;
  109. vertexDataFunc( v );
  110. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  111. half3 worldNormal = UnityObjectToWorldNormal( v.normal );
  112. o.customPack1.xy = customInputData.uv_texcoord;
  113. o.customPack1.xy = v.texcoord;
  114. o.worldPos = worldPos;
  115. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  116. return o;
  117. }
  118. half4 frag( v2f IN
  119. #if !defined( CAN_SKIP_VPOS )
  120. , UNITY_VPOS_TYPE vpos : VPOS
  121. #endif
  122. ) : SV_Target
  123. {
  124. UNITY_SETUP_INSTANCE_ID( IN );
  125. Input surfIN;
  126. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  127. surfIN.uv_texcoord = IN.customPack1.xy;
  128. float3 worldPos = IN.worldPos;
  129. half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  130. surfIN.worldPos = worldPos;
  131. SurfaceOutputStandard o;
  132. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
  133. surf( surfIN, o );
  134. #if defined( CAN_SKIP_VPOS )
  135. float2 vpos = IN.pos;
  136. #endif
  137. half alphaRef = tex3D( _DitherMaskLOD, float3( vpos.xy * 0.25, o.Alpha * 0.9375 ) ).a;
  138. clip( alphaRef - 0.01 );
  139. SHADOW_CASTER_FRAGMENT( IN )
  140. }
  141. ENDCG
  142. }
  143. }
  144. Fallback "Diffuse"
  145. CustomEditor "ASEMaterialInspector"
  146. }
  147. /*ASEBEGIN
  148. Version=16103
  149. 480;92;951;705;388.167;249.3669;1;False;False
  150. Node;AmplifyShaderEditor.WorldPosInputsNode;47;-1613.94,374.7962;Float;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  151. Node;AmplifyShaderEditor.NormalizeNode;52;-1433.848,405.8031;Float;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0
  152. Node;AmplifyShaderEditor.SwizzleNode;53;-1276.848,359.8031;Float;False;FLOAT;0;1;2;3;1;0;FLOAT3;0,0,0;False;1;FLOAT;0
  153. Node;AmplifyShaderEditor.SwizzleNode;54;-1282.758,461.1884;Float;False;FLOAT;2;1;2;3;1;0;FLOAT3;0,0,0;False;1;FLOAT;0
  154. Node;AmplifyShaderEditor.RangedFloatNode;17;-940.1017,344.933;Float;False;Property;_EdgeFlutter;EdgeFlutter;12;0;Create;True;0;0;False;0;1;0.2;0;0;0;1;FLOAT;0
  155. Node;AmplifyShaderEditor.SimpleAddOpNode;48;-1107.126,391.6696;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  156. Node;AmplifyShaderEditor.RangedFloatNode;19;-855.2003,648.8994;Float;False;Property;_SecondaryFactor;SecondaryFactor;10;0;Create;True;0;0;False;0;0;0;0;0;0;1;FLOAT;0
  157. Node;AmplifyShaderEditor.RangedFloatNode;18;-863.3002,544.9996;Float;False;Property;_PrimaryFactor;PrimaryFactor;11;0;Create;True;0;0;False;0;0;0;0;0;0;1;FLOAT;0
  158. Node;AmplifyShaderEditor.RangedFloatNode;16;-873.9003,235.7;Float;False;Property;_BranchPhase;BranchPhase;13;0;Create;True;0;0;False;0;0;1;0;0;0;1;FLOAT;0
  159. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;56;-781.8696,411.4852;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  160. Node;AmplifyShaderEditor.DynamicAppendNode;15;-609.5466,421.1271;Float;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
  161. Node;AmplifyShaderEditor.Vector4Node;31;-349.7917,473.8345;Float;False;Property;_TreeInstanceScale;_TreeInstanceScale;9;0;Fetch;True;0;0;False;0;0,0,0,0;0,0,0,0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  162. Node;AmplifyShaderEditor.FunctionNode;6;-413.5,307;Float;False;Terrain Wind Animate Vertex;-1;;2;3bc81bd4568a7094daabf2ccd6a7e125;0;3;2;FLOAT4;0,0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  163. Node;AmplifyShaderEditor.SamplerNode;3;-422.5,-168;Float;True;Property;_MainTex;MainTex;7;0;Create;True;0;0;False;0;None;b3101af65b8fa814e8bbcda4070eef97;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
  164. Node;AmplifyShaderEditor.ColorNode;30;-210.4572,-369.9227;Float;False;Property;_TreeInstanceColor;TreeInstanceColor;8;0;Fetch;True;0;0;False;0;0,0,0,0;1,1,1,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  165. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;28;-87.62848,267.1468;Float;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;1;FLOAT4;0
  166. Node;AmplifyShaderEditor.Vector3Node;23;-46.3596,535.886;Float;False;Property;_TreeOffset;Tree Offset;6;0;Create;True;0;0;False;0;0,5,0;0,0.48,0;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  167. Node;AmplifyShaderEditor.TexCoordVertexDataNode;27;-1096.637,111.2048;Float;False;0;2;0;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  168. Node;AmplifyShaderEditor.CustomExpressionNode;24;-773.6367,-57.79521;Float;False;TerrainBillboardTree(Pos, Offset, OffsetZ)@$return@;7;False;3;True;Pos;FLOAT4;0,0,0,0;InOut;;Float;True;Offset;FLOAT2;0,0;In;;Float;True;OffsetZ;FLOAT;0;In;;Float;TerrainBillboardTree;True;False;0;4;0;FLOAT;0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT2;0,0;False;3;FLOAT;0;False;2;FLOAT;0;FLOAT4;2
  169. Node;AmplifyShaderEditor.TexCoordVertexDataNode;26;-1101.637,-46.79521;Float;False;1;2;0;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  170. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;29;24.54279,-228.9227;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
  171. Node;AmplifyShaderEditor.PosVertexDataNode;25;-1072.637,-223.7951;Float;False;1;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  172. Node;AmplifyShaderEditor.SimpleAddOpNode;22;89.28527,242.6021;Float;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT4;0
  173. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;7;222,-64;Float;False;True;6;Float;ASEMaterialInspector;0;0;Standard;GrassBlades;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;False;False;False;False;False;Off;2;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Custom;0.5;True;True;0;True;TreeBillboard;;Transparent;All;True;True;True;True;True;True;True;True;True;True;True;True;True;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;True;1;15;10;25;False;0.5;True;2;5;False;-1;10;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;Absolute;0;;0;-1;-1;1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;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
  174. WireConnection;52;0;47;0
  175. WireConnection;53;0;52;0
  176. WireConnection;54;0;52;0
  177. WireConnection;48;0;53;0
  178. WireConnection;48;1;54;0
  179. WireConnection;56;0;17;0
  180. WireConnection;56;1;48;0
  181. WireConnection;15;0;16;0
  182. WireConnection;15;1;56;0
  183. WireConnection;15;2;18;0
  184. WireConnection;15;3;19;0
  185. WireConnection;6;4;15;0
  186. WireConnection;28;0;6;0
  187. WireConnection;28;1;31;0
  188. WireConnection;24;1;25;0
  189. WireConnection;24;2;26;0
  190. WireConnection;24;3;27;2
  191. WireConnection;29;0;30;0
  192. WireConnection;29;1;3;0
  193. WireConnection;22;0;28;0
  194. WireConnection;22;1;23;0
  195. WireConnection;7;0;29;0
  196. WireConnection;7;9;3;4
  197. WireConnection;7;11;22;0
  198. ASEEND*/
  199. //CHKSM=789681A32E4027B79521C92C1D10F3381F411AA5