Soft Holo Cone.shader 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "Knife/Soft Holo Cone"
  4. {
  5. Properties
  6. {
  7. _Softness("Softness", Range( 0 , 1)) = 0
  8. [HDR]_Color("Color", Color) = (0,0,0,0)
  9. _Mask("Mask", 2D) = "white" {}
  10. _DepthFadeDistance("DepthFadeDistance", Float) = 0
  11. _MaskSoftness("MaskSoftness", Range( 0 , 1)) = 0
  12. _MaskSoftness2("MaskSoftness 2", Range( 0 , 1)) = 0
  13. _Mask2("Mask 2", 2D) = "white" {}
  14. _Mask2Speed("Mask2Speed", Vector) = (0,0,0,0)
  15. _Alpha("Alpha", Range( 0 , 1)) = 1
  16. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  17. [HideInInspector] __dirty( "", Int ) = 1
  18. }
  19. SubShader
  20. {
  21. Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" "IsEmissive" = "true" }
  22. Cull Off
  23. CGINCLUDE
  24. #include "UnityShaderVariables.cginc"
  25. #include "UnityCG.cginc"
  26. #include "UnityPBSLighting.cginc"
  27. #include "Lighting.cginc"
  28. #pragma target 3.0
  29. struct Input
  30. {
  31. float2 uv_texcoord;
  32. float3 worldNormal;
  33. float3 viewDir;
  34. float4 screenPos;
  35. };
  36. uniform float4 _Color;
  37. uniform float _MaskSoftness2;
  38. uniform sampler2D _Mask2;
  39. uniform float2 _Mask2Speed;
  40. uniform float4 _Mask2_ST;
  41. uniform float _MaskSoftness;
  42. uniform sampler2D _Mask;
  43. uniform float4 _Mask_ST;
  44. uniform float _Softness;
  45. UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture );
  46. uniform float4 _CameraDepthTexture_TexelSize;
  47. uniform float _DepthFadeDistance;
  48. uniform float _Alpha;
  49. inline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten )
  50. {
  51. return half4 ( 0, 0, 0, s.Alpha );
  52. }
  53. void surf( Input i , inout SurfaceOutput o )
  54. {
  55. o.Emission = _Color.rgb;
  56. float2 uv0_Mask2 = i.uv_texcoord * _Mask2_ST.xy + _Mask2_ST.zw;
  57. float2 panner25 = ( 1.0 * _Time.y * _Mask2Speed + uv0_Mask2);
  58. float smoothstepResult23 = smoothstep( 0.0 , _MaskSoftness2 , tex2D( _Mask2, panner25 ).r);
  59. float2 uv_Mask = i.uv_texcoord * _Mask_ST.xy + _Mask_ST.zw;
  60. float smoothstepResult19 = smoothstep( 0.0 , _MaskSoftness , tex2D( _Mask, uv_Mask ).r);
  61. float3 ase_worldNormal = i.worldNormal;
  62. float dotResult4 = dot( ase_worldNormal , i.viewDir );
  63. float smoothstepResult7 = smoothstep( 0.0 , _Softness , abs( dotResult4 ));
  64. float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000000001 );
  65. float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w;
  66. ase_screenPosNorm.z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
  67. float screenDepth16 = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, ase_screenPosNorm.xy ));
  68. float distanceDepth16 = abs( ( screenDepth16 - LinearEyeDepth( ase_screenPosNorm.z ) ) / ( _DepthFadeDistance ) );
  69. float clampResult18 = clamp( distanceDepth16 , 0.0 , 1.0 );
  70. o.Alpha = ( ( smoothstepResult23 * smoothstepResult19 * _Color.a ) * smoothstepResult7 * clampResult18 * _Alpha );
  71. }
  72. ENDCG
  73. CGPROGRAM
  74. #pragma surface surf Unlit alpha:fade keepalpha fullforwardshadows
  75. ENDCG
  76. Pass
  77. {
  78. Name "ShadowCaster"
  79. Tags{ "LightMode" = "ShadowCaster" }
  80. ZWrite On
  81. CGPROGRAM
  82. #pragma vertex vert
  83. #pragma fragment frag
  84. #pragma target 3.0
  85. #pragma multi_compile_shadowcaster
  86. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  87. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  88. #include "HLSLSupport.cginc"
  89. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  90. #define CAN_SKIP_VPOS
  91. #endif
  92. #include "UnityCG.cginc"
  93. #include "Lighting.cginc"
  94. #include "UnityPBSLighting.cginc"
  95. sampler3D _DitherMaskLOD;
  96. struct v2f
  97. {
  98. V2F_SHADOW_CASTER;
  99. float2 customPack1 : TEXCOORD1;
  100. float3 worldPos : TEXCOORD2;
  101. float4 screenPos : TEXCOORD3;
  102. float3 worldNormal : TEXCOORD4;
  103. UNITY_VERTEX_INPUT_INSTANCE_ID
  104. UNITY_VERTEX_OUTPUT_STEREO
  105. };
  106. v2f vert( appdata_full v )
  107. {
  108. v2f o;
  109. UNITY_SETUP_INSTANCE_ID( v );
  110. UNITY_INITIALIZE_OUTPUT( v2f, o );
  111. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
  112. UNITY_TRANSFER_INSTANCE_ID( v, o );
  113. Input customInputData;
  114. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  115. half3 worldNormal = UnityObjectToWorldNormal( v.normal );
  116. o.worldNormal = worldNormal;
  117. o.customPack1.xy = customInputData.uv_texcoord;
  118. o.customPack1.xy = v.texcoord;
  119. o.worldPos = worldPos;
  120. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  121. o.screenPos = ComputeScreenPos( o.pos );
  122. return o;
  123. }
  124. half4 frag( v2f IN
  125. #if !defined( CAN_SKIP_VPOS )
  126. , UNITY_VPOS_TYPE vpos : VPOS
  127. #endif
  128. ) : SV_Target
  129. {
  130. UNITY_SETUP_INSTANCE_ID( IN );
  131. Input surfIN;
  132. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  133. surfIN.uv_texcoord = IN.customPack1.xy;
  134. float3 worldPos = IN.worldPos;
  135. half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  136. surfIN.viewDir = worldViewDir;
  137. surfIN.worldNormal = IN.worldNormal;
  138. surfIN.screenPos = IN.screenPos;
  139. SurfaceOutput o;
  140. UNITY_INITIALIZE_OUTPUT( SurfaceOutput, o )
  141. surf( surfIN, o );
  142. #if defined( CAN_SKIP_VPOS )
  143. float2 vpos = IN.pos;
  144. #endif
  145. half alphaRef = tex3D( _DitherMaskLOD, float3( vpos.xy * 0.25, o.Alpha * 0.9375 ) ).a;
  146. clip( alphaRef - 0.01 );
  147. SHADOW_CASTER_FRAGMENT( IN )
  148. }
  149. ENDCG
  150. }
  151. }
  152. Fallback "Diffuse"
  153. CustomEditor "ASEMaterialInspector"
  154. }
  155. /*ASEBEGIN
  156. Version=18100
  157. -1920;0;1920;1018;1398.417;23.88959;1;True;False
  158. Node;AmplifyShaderEditor.Vector2Node;26;-1731.5,-340.5;Inherit;False;Property;_Mask2Speed;Mask2Speed;7;0;Create;True;0;0;False;0;False;0,0;0,0.1;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
  159. Node;AmplifyShaderEditor.TextureCoordinatesNode;24;-1796.5,-491.5;Inherit;False;0;21;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
  160. Node;AmplifyShaderEditor.ViewDirInputsCoordNode;2;-1073.5,459.5;Inherit;False;World;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  161. Node;AmplifyShaderEditor.WorldNormalVector;3;-1099.5,281.5;Inherit;False;False;1;0;FLOAT3;0,0,1;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  162. Node;AmplifyShaderEditor.PannerNode;25;-1456.5,-563.5;Inherit;False;3;0;FLOAT2;0,0;False;2;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT2;0
  163. Node;AmplifyShaderEditor.RangedFloatNode;20;-900.5,46.5;Inherit;False;Property;_MaskSoftness;MaskSoftness;4;0;Create;True;0;0;False;0;False;0;0.897;0;1;0;1;FLOAT;0
  164. Node;AmplifyShaderEditor.SamplerNode;13;-860.5,-201.5;Inherit;True;Property;_Mask;Mask;2;0;Create;True;0;0;False;0;False;-1;None;c6504c94fed70cf49a38669fda63c389;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
  165. Node;AmplifyShaderEditor.DotProductOpNode;4;-865.5,326.5;Inherit;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT;0
  166. Node;AmplifyShaderEditor.RangedFloatNode;17;-823.5,898.5;Inherit;False;Property;_DepthFadeDistance;DepthFadeDistance;3;0;Create;True;0;0;False;0;False;0;0.5;0;0;0;1;FLOAT;0
  167. Node;AmplifyShaderEditor.SamplerNode;21;-897.5,-561.5;Inherit;True;Property;_Mask2;Mask 2;6;0;Create;True;0;0;False;0;False;-1;None;f1d1e317c910b2a49a88762d16bfc211;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
  168. Node;AmplifyShaderEditor.RangedFloatNode;22;-864.5,-356.5;Inherit;False;Property;_MaskSoftness2;MaskSoftness 2;5;0;Create;True;0;0;False;0;False;0;1;0;1;0;1;FLOAT;0
  169. Node;AmplifyShaderEditor.AbsOpNode;15;-705.5,300.5;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
  170. Node;AmplifyShaderEditor.DepthFade;16;-622.5,806.5;Inherit;False;True;False;True;2;1;FLOAT3;0,0,0;False;0;FLOAT;1;False;1;FLOAT;0
  171. Node;AmplifyShaderEditor.ColorNode;11;-627.5,13.5;Inherit;False;Property;_Color;Color;1;1;[HDR];Create;True;0;0;False;0;False;0,0,0,0;0.4139633,0.8850594,1.976675,0.6431373;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  172. Node;AmplifyShaderEditor.SmoothstepOpNode;19;-518.5,-124.5;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0
  173. Node;AmplifyShaderEditor.RangedFloatNode;8;-735.5,658.5;Inherit;False;Property;_Softness;Softness;0;0;Create;True;0;0;False;0;False;0;1;0;1;0;1;FLOAT;0
  174. Node;AmplifyShaderEditor.SmoothstepOpNode;23;-544.5,-434.5;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0
  175. Node;AmplifyShaderEditor.SmoothstepOpNode;7;-444.5,457.5;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0
  176. Node;AmplifyShaderEditor.ClampOpNode;18;-363.5,806.5;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0
  177. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;14;-270.5,88.5;Inherit;False;3;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0
  178. Node;AmplifyShaderEditor.RangedFloatNode;27;-363.417,613.1104;Inherit;False;Property;_Alpha;Alpha;8;0;Create;True;0;0;False;0;False;1;1;0;1;0;1;FLOAT;0
  179. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;12;-265.5,445.5;Inherit;False;4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT;0
  180. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;10;139,211;Float;False;True;-1;2;ASEMaterialInspector;0;0;Unlit;Knife/Soft Holo Cone;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;False;False;False;False;False;False;Off;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Transparent;0.5;True;True;0;False;Transparent;;Transparent;All;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;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;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;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
  181. WireConnection;25;0;24;0
  182. WireConnection;25;2;26;0
  183. WireConnection;4;0;3;0
  184. WireConnection;4;1;2;0
  185. WireConnection;21;1;25;0
  186. WireConnection;15;0;4;0
  187. WireConnection;16;0;17;0
  188. WireConnection;19;0;13;1
  189. WireConnection;19;2;20;0
  190. WireConnection;23;0;21;1
  191. WireConnection;23;2;22;0
  192. WireConnection;7;0;15;0
  193. WireConnection;7;2;8;0
  194. WireConnection;18;0;16;0
  195. WireConnection;14;0;23;0
  196. WireConnection;14;1;19;0
  197. WireConnection;14;2;11;4
  198. WireConnection;12;0;14;0
  199. WireConnection;12;1;7;0
  200. WireConnection;12;2;18;0
  201. WireConnection;12;3;27;0
  202. WireConnection;10;2;11;0
  203. WireConnection;10;9;12;0
  204. ASEEND*/
  205. //CHKSM=39BA58FFC26ABFAA7087C0ED7B2E07687730C814