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.

230 lines
13 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/Community/TFHC/2 Sided"
  4. {
  5. Properties
  6. {
  7. [HideInInspector] __dirty( "", Int ) = 1
  8. _MaskClipValue( "Mask Clip Value", Float ) = 0.5
  9. _FrontFacesColor("Front Faces Color", Color) = (1,0,0,0)
  10. _FrontFacesAlbedo("Front Faces Albedo", 2D) = "white" {}
  11. _FrontFacesNormal("Front Faces Normal", 2D) = "bump" {}
  12. _BackFacesColor("Back Faces Color", Color) = (0,0.04827571,1,0)
  13. _BackFacesAlbedo("Back Faces Albedo", 2D) = "white" {}
  14. _BackFacesNormal("Back Faces Normal", 2D) = "bump" {}
  15. _OpacityMask("Opacity Mask", 2D) = "white" {}
  16. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  17. }
  18. SubShader
  19. {
  20. Tags{ "RenderType" = "TransparentCutout" "Queue" = "AlphaTest+0" }
  21. Cull Off
  22. Stencil
  23. {
  24. Ref 1
  25. Comp Always
  26. Pass Replace
  27. }
  28. CGINCLUDE
  29. #include "UnityPBSLighting.cginc"
  30. #include "Lighting.cginc"
  31. #pragma target 3.0
  32. #ifdef UNITY_PASS_SHADOWCASTER
  33. #undef INTERNAL_DATA
  34. #undef WorldReflectionVector
  35. #undef WorldNormalVector
  36. #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
  37. #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
  38. #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
  39. #endif
  40. struct Input
  41. {
  42. float2 uv_texcoord;
  43. float3 worldNormal;
  44. INTERNAL_DATA
  45. float3 worldPos;
  46. };
  47. uniform sampler2D _FrontFacesNormal;
  48. uniform float4 _FrontFacesNormal_ST;
  49. uniform sampler2D _BackFacesNormal;
  50. uniform float4 _BackFacesNormal_ST;
  51. uniform float4 _FrontFacesColor;
  52. uniform sampler2D _FrontFacesAlbedo;
  53. uniform float4 _FrontFacesAlbedo_ST;
  54. uniform float4 _BackFacesColor;
  55. uniform sampler2D _BackFacesAlbedo;
  56. uniform float4 _BackFacesAlbedo_ST;
  57. uniform sampler2D _OpacityMask;
  58. uniform float4 _OpacityMask_ST;
  59. uniform float _MaskClipValue = 0.5;
  60. void surf( Input i , inout SurfaceOutputStandard o )
  61. {
  62. float2 uv_FrontFacesNormal = i.uv_texcoord * _FrontFacesNormal_ST.xy + _FrontFacesNormal_ST.zw;
  63. float3 FrontFacesNormal = UnpackNormal( tex2D( _FrontFacesNormal, uv_FrontFacesNormal ) );
  64. float2 uv_BackFacesNormal = i.uv_texcoord * _BackFacesNormal_ST.xy + _BackFacesNormal_ST.zw;
  65. float3 BackFacesNormal = UnpackNormal( tex2D( _BackFacesNormal, uv_BackFacesNormal ) );
  66. float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
  67. float3 worldViewDir = normalize( UnityWorldSpaceViewDir( i.worldPos ) );
  68. float FaceSign = (1.0 + (sign( dot( ase_worldNormal , worldViewDir ) ) - -1.0) * (0.0 - 1.0) / (1.0 - -1.0));
  69. o.Normal = lerp( FrontFacesNormal , BackFacesNormal , FaceSign );
  70. float2 uv_FrontFacesAlbedo = i.uv_texcoord * _FrontFacesAlbedo_ST.xy + _FrontFacesAlbedo_ST.zw;
  71. float4 FrontFacesAlbedo = ( _FrontFacesColor * tex2D( _FrontFacesAlbedo, uv_FrontFacesAlbedo ) );
  72. float2 uv_BackFacesAlbedo = i.uv_texcoord * _BackFacesAlbedo_ST.xy + _BackFacesAlbedo_ST.zw;
  73. float4 BackFacesAlbedo = ( _BackFacesColor * tex2D( _BackFacesAlbedo, uv_BackFacesAlbedo ) );
  74. o.Albedo = lerp( FrontFacesAlbedo , BackFacesAlbedo , FaceSign ).rgb;
  75. o.Alpha = 1;
  76. float2 uv_OpacityMask = i.uv_texcoord * _OpacityMask_ST.xy + _OpacityMask_ST.zw;
  77. float OpacityMask = tex2D( _OpacityMask, uv_OpacityMask ).a;
  78. clip( OpacityMask - _MaskClipValue );
  79. }
  80. ENDCG
  81. CGPROGRAM
  82. #pragma surface surf Standard keepalpha fullforwardshadows
  83. ENDCG
  84. Pass
  85. {
  86. Name "ShadowCaster"
  87. Tags{ "LightMode" = "ShadowCaster" }
  88. ZWrite On
  89. CGPROGRAM
  90. #pragma vertex vert
  91. #pragma fragment frag
  92. #pragma target 3.0
  93. #pragma multi_compile_shadowcaster
  94. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  95. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  96. # include "HLSLSupport.cginc"
  97. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  98. #define CAN_SKIP_VPOS
  99. #endif
  100. #include "UnityCG.cginc"
  101. #include "Lighting.cginc"
  102. #include "UnityPBSLighting.cginc"
  103. sampler3D _DitherMaskLOD;
  104. struct v2f
  105. {
  106. V2F_SHADOW_CASTER;
  107. float3 worldPos : TEXCOORD6;
  108. float4 tSpace0 : TEXCOORD1;
  109. float4 tSpace1 : TEXCOORD2;
  110. float4 tSpace2 : TEXCOORD3;
  111. float4 texcoords01 : TEXCOORD4;
  112. UNITY_VERTEX_INPUT_INSTANCE_ID
  113. };
  114. v2f vert( appdata_full v )
  115. {
  116. v2f o;
  117. UNITY_SETUP_INSTANCE_ID( v );
  118. UNITY_INITIALIZE_OUTPUT( v2f, o );
  119. UNITY_TRANSFER_INSTANCE_ID( v, o );
  120. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  121. half3 worldNormal = UnityObjectToWorldNormal( v.normal );
  122. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  123. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  124. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  125. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  126. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  127. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  128. o.texcoords01 = float4( v.texcoord.xy, v.texcoord1.xy );
  129. o.worldPos = worldPos;
  130. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  131. return o;
  132. }
  133. fixed4 frag( v2f IN
  134. #if !defined( CAN_SKIP_VPOS )
  135. , UNITY_VPOS_TYPE vpos : VPOS
  136. #endif
  137. ) : SV_Target
  138. {
  139. UNITY_SETUP_INSTANCE_ID( IN );
  140. Input surfIN;
  141. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  142. surfIN.uv_texcoord.xy = IN.texcoords01.xy;
  143. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  144. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  145. surfIN.worldPos = worldPos;
  146. surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
  147. surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
  148. surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
  149. surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
  150. SurfaceOutputStandard o;
  151. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
  152. surf( surfIN, o );
  153. #if defined( CAN_SKIP_VPOS )
  154. float2 vpos = IN.pos;
  155. #endif
  156. SHADOW_CASTER_FRAGMENT( IN )
  157. }
  158. ENDCG
  159. }
  160. }
  161. Fallback "Diffuse"
  162. CustomEditor "ASEMaterialInspector"
  163. }
  164. /*ASEBEGIN
  165. Version=10011
  166. 646;227;1066;638;1866.415;636.1154;1.9;True;False
  167. Node;AmplifyShaderEditor.CommentaryNode;49;-1774.799,4.739527;Float;False;1094.131;402.4268;Comment;6;20;22;23;48;19;41;Face Sign (0 = Front, 1 = Back);0;0
  168. Node;AmplifyShaderEditor.ViewDirInputsCoordNode;19;-1699.579,223.1664;Float;False;World;0;4;FLOAT3;FLOAT;FLOAT;FLOAT
  169. Node;AmplifyShaderEditor.WorldNormalVector;41;-1724.799,54.73954;Float;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT
  170. Node;AmplifyShaderEditor.DotProductOpNode;20;-1466.548,149.8606;Float;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0.0,0,0,0;False;1;FLOAT
  171. Node;AmplifyShaderEditor.CommentaryNode;52;-1776.875,-811.7521;Float;False;870.9222;707.2373;Comment;6;43;44;28;42;50;51;Front Faces;0;0
  172. Node;AmplifyShaderEditor.CommentaryNode;55;-864.2166,-812.0974;Float;False;865.924;714.2354;Comment;6;45;46;47;29;53;54;Back Faces;0;0
  173. Node;AmplifyShaderEditor.ColorNode;28;-1708.367,-761.7521;Float;False;Property;_FrontFacesColor;Front Faces Color;0;0;1,0,0,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  174. Node;AmplifyShaderEditor.ColorNode;29;-772.7956,-762.0974;Float;False;Property;_BackFacesColor;Back Faces Color;3;0;0,0.04827571,1,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  175. Node;AmplifyShaderEditor.SamplerNode;45;-814.2166,-573.6706;Float;True;Property;_BackFacesAlbedo;Back Faces Albedo;4;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  176. Node;AmplifyShaderEditor.SamplerNode;42;-1726.875,-565.9415;Float;True;Property;_FrontFacesAlbedo;Front Faces Albedo;1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  177. Node;AmplifyShaderEditor.SignOpNode;22;-1298.996,161.4731;Float;False;1;0;FLOAT;0.0;False;1;FLOAT
  178. Node;AmplifyShaderEditor.CommentaryNode;57;-614.5056,32.69087;Float;False;626.0693;280;Comment;2;56;27;Opacity Mask;0;0
  179. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;46;-423.7787,-601.559;Float;False;2;2;0;COLOR;0.0;False;1;FLOAT4;0,0,0,0;False;1;COLOR
  180. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;43;-1358.749,-630.0837;Float;False;2;2;0;COLOR;0.0;False;1;FLOAT4;0,0,0,0;False;1;COLOR
  181. Node;AmplifyShaderEditor.SamplerNode;50;-1700.404,-334.5151;Float;True;Property;_FrontFacesNormal;Front Faces Normal;2;0;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
  182. Node;AmplifyShaderEditor.SamplerNode;53;-762.2464,-327.8621;Float;True;Property;_BackFacesNormal;Back Faces Normal;5;0;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
  183. Node;AmplifyShaderEditor.TFHCRemap;23;-1136.493,143.3126;Float;False;5;0;FLOAT;0.0;False;1;FLOAT;-1.0;False;2;FLOAT;1.0;False;3;FLOAT;1.0;False;4;FLOAT;0.0;False;1;FLOAT
  184. Node;AmplifyShaderEditor.RegisterLocalVarNode;47;-245.2925,-601.559;Float;False;BackFacesAlbedo;-1;True;1;0;COLOR;0.0;False;1;COLOR
  185. Node;AmplifyShaderEditor.RegisterLocalVarNode;54;-430.3735,-314.3162;Float;False;BackFacesNormal;-1;True;1;0;FLOAT3;0.0;False;1;FLOAT3
  186. Node;AmplifyShaderEditor.GetLocalVarNode;60;118.8098,-452.1644;Float;False;47;0;1;COLOR
  187. Node;AmplifyShaderEditor.RegisterLocalVarNode;51;-1358.372,-334.5151;Float;False;FrontFacesNormal;-1;True;1;0;FLOAT3;0.0;False;1;FLOAT3
  188. Node;AmplifyShaderEditor.RegisterLocalVarNode;44;-1157.953,-630.0831;Float;False;FrontFacesAlbedo;-1;True;1;0;COLOR;0.0;False;1;COLOR
  189. Node;AmplifyShaderEditor.GetLocalVarNode;62;119.0541,-269.2288;Float;False;51;0;1;FLOAT3
  190. Node;AmplifyShaderEditor.RegisterLocalVarNode;48;-914.667,139.6586;Float;False;FaceSign;-1;True;1;0;FLOAT;0.0;False;1;FLOAT
  191. Node;AmplifyShaderEditor.GetLocalVarNode;59;141.1735,-548.2174;Float;False;44;0;1;COLOR
  192. Node;AmplifyShaderEditor.GetLocalVarNode;61;165.1398,-361.4234;Float;False;48;0;1;FLOAT
  193. Node;AmplifyShaderEditor.GetLocalVarNode;65;143.0204,-84.28967;Float;False;48;0;1;FLOAT
  194. Node;AmplifyShaderEditor.GetLocalVarNode;63;117.0938,-175.0307;Float;False;54;0;1;FLOAT3
  195. Node;AmplifyShaderEditor.SamplerNode;27;-564.5056,82.69086;Float;True;Property;_OpacityMask;Opacity Mask;6;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  196. Node;AmplifyShaderEditor.RegisterLocalVarNode;56;-222.4362,170.9077;Float;False;OpacityMask;-1;True;1;0;FLOAT;0.0;False;1;FLOAT
  197. Node;AmplifyShaderEditor.LerpOp;64;375.2734,-209.8589;Float;False;3;0;FLOAT3;0,0,0,0;False;1;FLOAT3;0;False;2;FLOAT;0.0;False;1;FLOAT3
  198. Node;AmplifyShaderEditor.GetLocalVarNode;58;345.5315,126.3971;Float;False;56;0;1;FLOAT
  199. Node;AmplifyShaderEditor.LerpOp;24;404.8121,-409.0887;Float;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0;False;2;FLOAT;0.0;False;1;COLOR
  200. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;596.1226,-305.096;Float;False;True;2;Float;ASEMaterialInspector;0;Standard;ASESampleShaders/Community/TFHC/2 Sided;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Off;0;0;False;0;0;Masked;0.5;True;True;0;False;TransparentCutout;AlphaTest;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;1;255;255;7;3;0;0;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;1,0.4344827,0,0;VertexScale;False;Cylindrical;Relative;0;;-1;-1;-1;-1;0;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0.0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;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
  201. WireConnection;20;0;41;0
  202. WireConnection;20;1;19;0
  203. WireConnection;22;0;20;0
  204. WireConnection;46;0;29;0
  205. WireConnection;46;1;45;0
  206. WireConnection;43;0;28;0
  207. WireConnection;43;1;42;0
  208. WireConnection;23;0;22;0
  209. WireConnection;47;0;46;0
  210. WireConnection;54;0;53;0
  211. WireConnection;51;0;50;0
  212. WireConnection;44;0;43;0
  213. WireConnection;48;0;23;0
  214. WireConnection;56;0;27;4
  215. WireConnection;64;0;62;0
  216. WireConnection;64;1;63;0
  217. WireConnection;64;2;65;0
  218. WireConnection;24;0;59;0
  219. WireConnection;24;1;60;0
  220. WireConnection;24;2;61;0
  221. WireConnection;0;0;24;0
  222. WireConnection;0;1;64;0
  223. WireConnection;0;10;58;0
  224. ASEEND*/
  225. //CHKSM=C7892A3B0CD9F89298ADCEB0093D67A509CB3721