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.

198 lines
11 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/SnowAccum"
  4. {
  5. Properties
  6. {
  7. _RockAlbedo("Rock Albedo", 2D) = "white" {}
  8. _RockNormal("Rock Normal", 2D) = "bump" {}
  9. _RockSpecular("Rock Specular", 2D) = "white" {}
  10. _SnowAlbedo("Snow Albedo", 2D) = "white" {}
  11. _SnowNormal("Snow Normal", 2D) = "bump" {}
  12. _SnowSpecular("Snow Specular", 2D) = "white" {}
  13. _SnowAmount("SnowAmount", Range( 0 , 2)) = 0.13
  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. ZTest LEqual
  22. CGINCLUDE
  23. #include "UnityPBSLighting.cginc"
  24. #include "Lighting.cginc"
  25. #pragma target 3.0
  26. #ifdef UNITY_PASS_SHADOWCASTER
  27. #undef INTERNAL_DATA
  28. #undef WorldReflectionVector
  29. #undef WorldNormalVector
  30. #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
  31. #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
  32. #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
  33. #endif
  34. struct Input
  35. {
  36. float2 uv_texcoord;
  37. float3 worldNormal;
  38. INTERNAL_DATA
  39. };
  40. uniform sampler2D _RockNormal;
  41. uniform float4 _RockNormal_ST;
  42. uniform sampler2D _SnowNormal;
  43. uniform float4 _SnowNormal_ST;
  44. uniform float _SnowAmount;
  45. uniform sampler2D _RockAlbedo;
  46. uniform float4 _RockAlbedo_ST;
  47. uniform sampler2D _SnowAlbedo;
  48. uniform float4 _SnowAlbedo_ST;
  49. uniform sampler2D _RockSpecular;
  50. uniform float4 _RockSpecular_ST;
  51. uniform sampler2D _SnowSpecular;
  52. uniform float4 _SnowSpecular_ST;
  53. void surf( Input i , inout SurfaceOutputStandardSpecular o )
  54. {
  55. float2 uv_RockNormal = i.uv_texcoord * _RockNormal_ST.xy + _RockNormal_ST.zw;
  56. float2 uv_SnowNormal = i.uv_texcoord * _SnowNormal_ST.xy + _SnowNormal_ST.zw;
  57. float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
  58. float3 lerpResult15 = lerp( UnpackNormal( tex2D( _RockNormal, uv_RockNormal ) ) , UnpackNormal( tex2D( _SnowNormal, uv_SnowNormal ) ) , saturate( ( ase_worldNormal.y * _SnowAmount ) ));
  59. o.Normal = lerpResult15;
  60. float2 uv_RockAlbedo = i.uv_texcoord * _RockAlbedo_ST.xy + _RockAlbedo_ST.zw;
  61. float2 uv_SnowAlbedo = i.uv_texcoord * _SnowAlbedo_ST.xy + _SnowAlbedo_ST.zw;
  62. float temp_output_18_0 = saturate( ( WorldNormalVector( i , lerpResult15 ).y * _SnowAmount ) );
  63. float4 lerpResult10 = lerp( tex2D( _RockAlbedo, uv_RockAlbedo ) , tex2D( _SnowAlbedo, uv_SnowAlbedo ) , temp_output_18_0);
  64. o.Albedo = lerpResult10.rgb;
  65. float2 uv_RockSpecular = i.uv_texcoord * _RockSpecular_ST.xy + _RockSpecular_ST.zw;
  66. float2 uv_SnowSpecular = i.uv_texcoord * _SnowSpecular_ST.xy + _SnowSpecular_ST.zw;
  67. float4 lerpResult17 = lerp( tex2D( _RockSpecular, uv_RockSpecular ) , tex2D( _SnowSpecular, uv_SnowSpecular ) , temp_output_18_0);
  68. o.Specular = lerpResult17.rgb;
  69. o.Alpha = 1;
  70. }
  71. ENDCG
  72. CGPROGRAM
  73. #pragma surface surf StandardSpecular keepalpha fullforwardshadows
  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 3.0
  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. struct v2f
  95. {
  96. V2F_SHADOW_CASTER;
  97. float2 customPack1 : TEXCOORD1;
  98. float4 tSpace0 : TEXCOORD2;
  99. float4 tSpace1 : TEXCOORD3;
  100. float4 tSpace2 : TEXCOORD4;
  101. UNITY_VERTEX_INPUT_INSTANCE_ID
  102. };
  103. v2f vert( appdata_full v )
  104. {
  105. v2f o;
  106. UNITY_SETUP_INSTANCE_ID( v );
  107. UNITY_INITIALIZE_OUTPUT( v2f, o );
  108. UNITY_TRANSFER_INSTANCE_ID( v, o );
  109. Input customInputData;
  110. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  111. fixed3 worldNormal = UnityObjectToWorldNormal( v.normal );
  112. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  113. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  114. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  115. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  116. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  117. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  118. o.customPack1.xy = customInputData.uv_texcoord;
  119. o.customPack1.xy = v.texcoord;
  120. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  121. return o;
  122. }
  123. fixed4 frag( v2f IN
  124. #if !defined( CAN_SKIP_VPOS )
  125. , UNITY_VPOS_TYPE vpos : VPOS
  126. #endif
  127. ) : SV_Target
  128. {
  129. UNITY_SETUP_INSTANCE_ID( IN );
  130. Input surfIN;
  131. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  132. surfIN.uv_texcoord = IN.customPack1.xy;
  133. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  134. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  135. surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
  136. surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
  137. surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
  138. surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
  139. SurfaceOutputStandardSpecular o;
  140. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o )
  141. surf( surfIN, o );
  142. #if defined( CAN_SKIP_VPOS )
  143. float2 vpos = IN.pos;
  144. #endif
  145. SHADOW_CASTER_FRAGMENT( IN )
  146. }
  147. ENDCG
  148. }
  149. }
  150. Fallback "Diffuse"
  151. CustomEditor "ASEMaterialInspector"
  152. }
  153. /*ASEBEGIN
  154. Version=14504
  155. 713;92;740;673;2183;870.8956;1.9;True;False
  156. Node;AmplifyShaderEditor.RangedFloatNode;12;-1773.599,-115.1001;Float;False;Property;_SnowAmount;SnowAmount;6;0;Create;True;0;0;False;0;0.13;0.95;0;2;0;1;FLOAT;0
  157. Node;AmplifyShaderEditor.WorldNormalVector;20;-1685.906,-319.7951;Float;False;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  158. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;21;-1444.505,-272.8951;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  159. Node;AmplifyShaderEditor.SamplerNode;14;-1548.101,267.1998;Float;True;Property;_SnowNormal;Snow Normal;4;0;Create;True;0;0;False;0;None;24e31ecbf813d9e49bf7a1e0d4034916;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;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
  160. Node;AmplifyShaderEditor.SamplerNode;4;-1548.101,72.7999;Float;True;Property;_RockNormal;Rock Normal;1;0;Create;True;0;0;False;0;None;0bebe40e9ebbecc48b8e9cfea982da7e;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;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
  161. Node;AmplifyShaderEditor.SaturateNode;22;-1283.806,-264.4951;Float;False;1;0;FLOAT;0;False;1;FLOAT;0
  162. Node;AmplifyShaderEditor.LerpOp;15;-1067.3,73.59992;Float;False;3;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT;0;False;1;FLOAT3;0
  163. Node;AmplifyShaderEditor.WorldNormalVector;19;-865.5047,-194.2967;Float;False;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  164. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;11;-651.7996,-116.3;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
  165. Node;AmplifyShaderEditor.SaturateNode;18;-496.7049,-110.1974;Float;False;1;0;FLOAT;0;False;1;FLOAT;0
  166. Node;AmplifyShaderEditor.SamplerNode;16;-704.8019,470.7009;Float;True;Property;_SnowSpecular;Snow Specular;5;0;Create;True;0;0;False;0;None;84d76c914224da14a8210ba4ba8a2992;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;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
  167. Node;AmplifyShaderEditor.SamplerNode;1;-811.4,-722.1001;Float;True;Property;_RockAlbedo;Rock Albedo;0;0;Create;True;0;0;False;0;None;b297077dae62c1944ba14cad801cddf5;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;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
  168. Node;AmplifyShaderEditor.SamplerNode;2;-693.0005,253.9001;Float;True;Property;_RockSpecular;Rock Specular;2;0;Create;True;0;0;False;0;None;6618005f6bafebf40b3d09f498401fba;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;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.SamplerNode;9;-824.2003,-500.8003;Float;True;Property;_SnowAlbedo;Snow Albedo;3;0;Create;True;0;0;False;0;None;4112a019314dad94f9ffc2f8481f31bc;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;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
  170. Node;AmplifyShaderEditor.LerpOp;17;-223.4019,317.8009;Float;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
  171. Node;AmplifyShaderEditor.LerpOp;10;-127.1,-308.6001;Float;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
  172. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;146.9001,42.89999;Float;False;True;2;Float;ASEMaterialInspector;0;0;StandardSpecular;ASESampleShaders/SnowAccum;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;3;False;-1;False;0;0;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;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;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;0;0;False;0;0;0;False;-1;-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
  173. WireConnection;21;0;20;2
  174. WireConnection;21;1;12;0
  175. WireConnection;22;0;21;0
  176. WireConnection;15;0;4;0
  177. WireConnection;15;1;14;0
  178. WireConnection;15;2;22;0
  179. WireConnection;19;0;15;0
  180. WireConnection;11;0;19;2
  181. WireConnection;11;1;12;0
  182. WireConnection;18;0;11;0
  183. WireConnection;17;0;2;0
  184. WireConnection;17;1;16;0
  185. WireConnection;17;2;18;0
  186. WireConnection;10;0;1;0
  187. WireConnection;10;1;9;0
  188. WireConnection;10;2;18;0
  189. WireConnection;0;0;10;0
  190. WireConnection;0;1;15;0
  191. WireConnection;0;3;17;0
  192. ASEEND*/
  193. //CHKSM=ADF5A2109BEC255F388E49268BE3862C27F6C709