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.

145 lines
6.1 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/Matcap"
  4. {
  5. Properties
  6. {
  7. [HideInInspector] __dirty( "", Int ) = 1
  8. _Matcap("Matcap", 2D) = "white" {}
  9. }
  10. SubShader
  11. {
  12. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" }
  13. Cull Back
  14. ZTest LEqual
  15. CGINCLUDE
  16. #include "UnityShaderVariables.cginc"
  17. #include "UnityPBSLighting.cginc"
  18. #include "Lighting.cginc"
  19. #pragma target 3.0
  20. #ifdef UNITY_PASS_SHADOWCASTER
  21. #undef INTERNAL_DATA
  22. #undef WorldReflectionVector
  23. #undef WorldNormalVector
  24. #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
  25. #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
  26. #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
  27. #endif
  28. struct Input
  29. {
  30. float3 worldNormal;
  31. INTERNAL_DATA
  32. };
  33. uniform sampler2D _Matcap;
  34. void surf( Input i , inout SurfaceOutputStandard o )
  35. {
  36. fixed3 temp_cast_1 = 0.5;
  37. o.Emission = tex2D( _Matcap,( ( mul( UNITY_MATRIX_V , fixed4( i.worldNormal , 0.0 ) ) * 0.5 ) + temp_cast_1 ).xy).xyz;
  38. o.Alpha = 1;
  39. }
  40. ENDCG
  41. CGPROGRAM
  42. #pragma surface surf Standard keepalpha
  43. ENDCG
  44. Pass
  45. {
  46. Name "ShadowCaster"
  47. Tags{ "LightMode" = "ShadowCaster" }
  48. ZWrite On
  49. CGPROGRAM
  50. #pragma vertex vert
  51. #pragma fragment frag
  52. #pragma target 3.0
  53. #pragma multi_compile_shadowcaster
  54. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  55. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  56. # include "HLSLSupport.cginc"
  57. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  58. #define CAN_SKIP_VPOS
  59. #endif
  60. #include "UnityCG.cginc"
  61. #include "Lighting.cginc"
  62. #include "UnityPBSLighting.cginc"
  63. sampler3D _DitherMaskLOD;
  64. struct v2f
  65. {
  66. V2F_SHADOW_CASTER;
  67. float3 worldPos : TEXCOORD6;
  68. float4 tSpace0 : TEXCOORD1;
  69. float4 tSpace1 : TEXCOORD2;
  70. float4 tSpace2 : TEXCOORD3;
  71. UNITY_VERTEX_INPUT_INSTANCE_ID
  72. };
  73. v2f vert( appdata_full v )
  74. {
  75. v2f o;
  76. UNITY_SETUP_INSTANCE_ID( v );
  77. UNITY_INITIALIZE_OUTPUT( v2f, o );
  78. UNITY_TRANSFER_INSTANCE_ID( v, o );
  79. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  80. half3 worldNormal = UnityObjectToWorldNormal( v.normal );
  81. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  82. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  83. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  84. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  85. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  86. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  87. o.worldPos = worldPos;
  88. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  89. return o;
  90. }
  91. fixed4 frag( v2f IN
  92. #if !defined( CAN_SKIP_VPOS )
  93. , UNITY_VPOS_TYPE vpos : VPOS
  94. #endif
  95. ) : SV_Target
  96. {
  97. UNITY_SETUP_INSTANCE_ID( IN );
  98. Input surfIN;
  99. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  100. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  101. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  102. surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
  103. surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
  104. surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
  105. surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
  106. SurfaceOutputStandard o;
  107. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
  108. surf( surfIN, o );
  109. #if defined( CAN_SKIP_VPOS )
  110. float2 vpos = IN.pos;
  111. #endif
  112. SHADOW_CASTER_FRAGMENT( IN )
  113. }
  114. ENDCG
  115. }
  116. }
  117. Fallback "Diffuse"
  118. CustomEditor "ASEMaterialInspector"
  119. }
  120. /*ASEBEGIN
  121. Version=6001
  122. 344;100;1180;639;1799.74;363.6467;1.6;True;True
  123. Node;AmplifyShaderEditor.ViewMatrixNode;21;-1119.276,47.42967;Float;False;FLOAT4x4
  124. Node;AmplifyShaderEditor.WorldNormalVector;26;-1199.464,141.5635;Float;False;0;FLOAT3;0,0,0;False;FLOAT3;FLOAT;FLOAT;FLOAT
  125. Node;AmplifyShaderEditor.RangedFloatNode;23;-971.5502,205.5904;Float;False;Constant;_Float0;Float 0;-1;0;0.5;0;0;FLOAT
  126. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;18;-960.7327,77.2156;Float;False;0;FLOAT4x4;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;False;1;FLOAT3;0.0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;False;FLOAT3
  127. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;22;-793.4805,113.6614;Float;False;0;FLOAT3;0.0,0,0;False;1;FLOAT;0;False;FLOAT3
  128. Node;AmplifyShaderEditor.SimpleAddOpNode;24;-618.1711,163.7383;Float;False;0;FLOAT3;0.0,0,0;False;1;FLOAT;0.0,0,0;False;FLOAT3
  129. Node;AmplifyShaderEditor.SamplerNode;1;-422.7262,121.5546;Float;True;Property;_Matcap;Matcap;-1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;0;SAMPLER2D;0,0;False;1;FLOAT2;1.0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  130. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;-49.57976,164.356;Fixed;False;True;2;Fixed;ASEMaterialInspector;Standard;ASESampleShaders/Matcap;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;3;False;0;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;False;0;255;255;0;0;0;0;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;False;Cylindrical;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,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;0.0;False;11;FLOAT3;0.0,0,0;False;12;FLOAT3;0.0,0,0;False;13;OBJECT;0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False
  131. WireConnection;18;0;21;0
  132. WireConnection;18;1;26;0
  133. WireConnection;22;0;18;0
  134. WireConnection;22;1;23;0
  135. WireConnection;24;0;22;0
  136. WireConnection;24;1;23;0
  137. WireConnection;1;1;24;0
  138. WireConnection;0;2;1;0
  139. ASEEND*/
  140. //CHKSM=C05DB1C2BB41B24BB6E3AF89EEC5670794765541