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.

182 lines
7.5 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/ScreenSpaceCurvature"
  4. {
  5. Properties
  6. {
  7. [HideInInspector] __dirty( "", Int ) = 1
  8. _ScaleFactor("ScaleFactor", Float) = 4
  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. float3 worldPos;
  33. };
  34. uniform float _ScaleFactor;
  35. void surf( Input i , inout SurfaceOutputStandard o )
  36. {
  37. float3 worldNormal = i.worldNormal;
  38. float3 temp_output_2_0 = ddx( worldNormal );
  39. float3 temp_output_7_0 = ddy( worldNormal );
  40. float3 vertexPos = mul( unity_WorldToObject, float4( i.worldPos , 1 ) );
  41. float3 temp_cast_0 = ( ( ( cross( ( worldNormal - temp_output_2_0 ) , ( worldNormal + temp_output_2_0 ) ).y - cross( ( worldNormal - temp_output_7_0 ) , ( worldNormal + temp_output_7_0 ) ).x ) * _ScaleFactor ) / length( vertexPos ) );
  42. o.Emission = ( temp_cast_0 + float3(0.5,0.5,0.5) );
  43. o.Alpha = 1;
  44. }
  45. ENDCG
  46. CGPROGRAM
  47. #pragma surface surf Standard keepalpha
  48. ENDCG
  49. Pass
  50. {
  51. Name "ShadowCaster"
  52. Tags{ "LightMode" = "ShadowCaster" }
  53. ZWrite On
  54. CGPROGRAM
  55. #pragma vertex vert
  56. #pragma fragment frag
  57. #pragma target 3.0
  58. #pragma multi_compile_instancing
  59. #pragma multi_compile_shadowcaster
  60. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  61. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  62. # include "HLSLSupport.cginc"
  63. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  64. #define CAN_SKIP_VPOS
  65. #endif
  66. #include "UnityCG.cginc"
  67. #include "Lighting.cginc"
  68. #include "UnityPBSLighting.cginc"
  69. sampler3D _DitherMaskLOD;
  70. struct v2f
  71. {
  72. V2F_SHADOW_CASTER;
  73. float3 worldPos : TEXCOORD6;
  74. float4 tSpace0 : TEXCOORD1;
  75. float4 tSpace1 : TEXCOORD2;
  76. float4 tSpace2 : TEXCOORD3;
  77. UNITY_VERTEX_INPUT_INSTANCE_ID
  78. };
  79. v2f vert( appdata_full v )
  80. {
  81. v2f o;
  82. UNITY_SETUP_INSTANCE_ID( v );
  83. UNITY_INITIALIZE_OUTPUT( v2f, o );
  84. UNITY_TRANSFER_INSTANCE_ID( v, o );
  85. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  86. half3 worldNormal = UnityObjectToWorldNormal( v.normal );
  87. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  88. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  89. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  90. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  91. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  92. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  93. o.worldPos = worldPos;
  94. TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
  95. return o;
  96. }
  97. fixed4 frag( v2f IN
  98. #if !defined( CAN_SKIP_VPOS )
  99. , UNITY_VPOS_TYPE vpos : VPOS
  100. #endif
  101. ) : SV_Target
  102. {
  103. UNITY_SETUP_INSTANCE_ID( IN );
  104. Input surfIN;
  105. UNITY_INITIALIZE_OUTPUT( Input, surfIN );
  106. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  107. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  108. surfIN.worldPos = worldPos;
  109. surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
  110. surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
  111. surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
  112. surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
  113. SurfaceOutputStandard o;
  114. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
  115. surf( surfIN, o );
  116. #if defined( CAN_SKIP_VPOS )
  117. float2 vpos = IN.pos;
  118. #endif
  119. SHADOW_CASTER_FRAGMENT( IN )
  120. }
  121. ENDCG
  122. }
  123. }
  124. Fallback "Diffuse"
  125. CustomEditor "ASEMaterialInspector"
  126. }
  127. /*ASEBEGIN
  128. Version=5002
  129. 339;92;1190;648;507.5048;148.1995;1.3;True;False
  130. Node;AmplifyShaderEditor.SimpleSubtractOpNode;19;-531.6992,126.5998;Float;FLOAT3;0.0,0,0;FLOAT3;0.0,0,0
  131. Node;AmplifyShaderEditor.CrossProductOpNode;21;-373.0967,-141.1999;Float;FLOAT3;0,0,0;FLOAT3;0,0,0
  132. Node;AmplifyShaderEditor.SimpleAddOpNode;20;-536.899,289.1003;Float;FLOAT3;0.0,0,0;FLOAT3;0.0,0,0
  133. Node;AmplifyShaderEditor.BreakToComponentsNode;24;-212.5965,203.3003;Float;FLOAT3;FLOAT3;0.0,0,0
  134. Node;AmplifyShaderEditor.BreakToComponentsNode;23;-206.0973,-189.2997;Float;FLOAT3;FLOAT3;0.0,0,0
  135. Node;AmplifyShaderEditor.SimpleSubtractOpNode;25;8.402822,-21.59954;Float;FLOAT;0.0;FLOAT;0.0
  136. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;26;173.5023,10.90066;Float;FLOAT;0.0;FLOAT;0.0
  137. Node;AmplifyShaderEditor.LengthOpNode;16;92.40041,431.3006;Float;FLOAT3;0,0,0
  138. Node;AmplifyShaderEditor.SimpleAddOpNode;29;479.1028,217.2994;Float;FLOAT;0.0;FLOAT3;0.0
  139. Node;AmplifyShaderEditor.DdyOpNode;7;-820.8997,285.6999;Float;FLOAT3;0.0,0,0
  140. Node;AmplifyShaderEditor.DdxOpNode;2;-835.1998,-79.59997;Float;FLOAT3;0.0,0,0
  141. Node;AmplifyShaderEditor.SimpleSubtractOpNode;17;-573.0988,-142.6001;Float;FLOAT3;0.0,0,0;FLOAT3;0.0,0,0
  142. Node;AmplifyShaderEditor.SimpleAddOpNode;18;-575.8983,-12.50004;Float;FLOAT3;0.0,0,0;FLOAT3;0.0,0,0
  143. Node;AmplifyShaderEditor.CrossProductOpNode;22;-375.2969,147;Float;FLOAT3;0,0,0;FLOAT3;0,0,0
  144. Node;AmplifyShaderEditor.WorldNormalVector;33;-1093.197,86.89935;Float;FLOAT3;0,0,0
  145. Node;AmplifyShaderEditor.RangedFloatNode;27;19.00231,144.3006;Float;Property;_ScaleFactor;ScaleFactor;-1;0;4;0;0
  146. Node;AmplifyShaderEditor.SimpleDivideOpNode;28;305.8015,139.5998;Float;FLOAT;0.0;FLOAT;0.0
  147. Node;AmplifyShaderEditor.Vector3Node;30;288.9025,325.6991;Float;Constant;_Vector0;Vector 0;-1;0;0.5,0.5,0.5
  148. Node;AmplifyShaderEditor.PosVertexDataNode;14;-108.1999,367.4005;Float
  149. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;678.9996,117.8999;Float;True;2;Float;ASEMaterialInspector;Standard;ASESampleShaders/ScreenSpaceCurvature;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;FLOAT3;0,0,0;FLOAT3;0,0,0;FLOAT3;0,0,0;FLOAT;0.0;FLOAT;0.0;FLOAT;0.0;FLOAT3;0.0;FLOAT3;0.0;FLOAT;0.0;FLOAT;0.0;OBJECT;0.0;FLOAT3;0,0,0;FLOAT3;0.0,0,0;OBJECT;0;FLOAT4;0,0,0,0;FLOAT3;0,0,0
  150. WireConnection;19;0;33;0
  151. WireConnection;19;1;7;0
  152. WireConnection;21;0;17;0
  153. WireConnection;21;1;18;0
  154. WireConnection;20;0;33;0
  155. WireConnection;20;1;7;0
  156. WireConnection;24;0;22;0
  157. WireConnection;23;0;21;0
  158. WireConnection;25;0;23;1
  159. WireConnection;25;1;24;0
  160. WireConnection;26;0;25;0
  161. WireConnection;26;1;27;0
  162. WireConnection;16;0;14;0
  163. WireConnection;29;0;28;0
  164. WireConnection;29;1;30;0
  165. WireConnection;7;0;33;0
  166. WireConnection;2;0;33;0
  167. WireConnection;17;0;33;0
  168. WireConnection;17;1;2;0
  169. WireConnection;18;0;33;0
  170. WireConnection;18;1;2;0
  171. WireConnection;22;0;19;0
  172. WireConnection;22;1;20;0
  173. WireConnection;28;0;26;0
  174. WireConnection;28;1;16;0
  175. WireConnection;0;2;29;0
  176. ASEEND*/
  177. //CHKSM=34269978B1C24CFA4BFCC2027D3E544A88F693D9