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.

241 lines
14 KiB

  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "ASESampleShaders/Community/EnvironmentGradient"
  4. {
  5. Properties
  6. {
  7. [HideInInspector] __dirty( "", Int ) = 1
  8. _Top_XZ("Top_XZ", Color) = (0.2569204,0.5525266,0.7279412,0)
  9. _Bot_Y("Bot_Y", Color) = (0.3877363,0.5955882,0.188311,0)
  10. _GradientHeight("GradientHeight", Range( 0 , 20)) = 6.4
  11. _Top_Y("Top_Y", Color) = (0.7259277,0.7647059,0.06185123,0)
  12. _Bot_XZ("Bot_XZ", Color) = (0.7058823,0.2024221,0.2024221,0)
  13. _EdgeColor("EdgeColor", Color) = (0.9411765,0.9197947,0.7474049,0)
  14. _NormalMap("NormalMap", 2D) = "bump" {}
  15. _EdgeMultiplier("EdgeMultiplier", Range( 0 , 5)) = 1
  16. _AO_Power("AO_Power", Range( 0 , 4)) = 1
  17. _R_AO_G_Edges("R_AO_G_Edges", 2D) = "white" {}
  18. }
  19. SubShader
  20. {
  21. Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
  22. Cull Back
  23. ZTest LEqual
  24. CGINCLUDE
  25. #include "UnityPBSLighting.cginc"
  26. #include "Lighting.cginc"
  27. #pragma target 3.0
  28. #ifdef UNITY_PASS_SHADOWCASTER
  29. #undef INTERNAL_DATA
  30. #undef WorldReflectionVector
  31. #undef WorldNormalVector
  32. #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
  33. #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
  34. #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
  35. #endif
  36. struct Input
  37. {
  38. float2 texcoord_0;
  39. float3 worldNormal;
  40. INTERNAL_DATA
  41. float3 worldPos;
  42. };
  43. uniform sampler2D _NormalMap;
  44. uniform float4 _EdgeColor;
  45. uniform float _EdgeMultiplier;
  46. uniform sampler2D _R_AO_G_Edges;
  47. uniform float _AO_Power;
  48. uniform float4 _Bot_XZ;
  49. uniform float4 _Bot_Y;
  50. uniform float4 _Top_XZ;
  51. uniform float4 _Top_Y;
  52. uniform float _GradientHeight;
  53. void vertexDataFunc( inout appdata_full v, out Input o )
  54. {
  55. UNITY_INITIALIZE_OUTPUT( Input, o );
  56. o.texcoord_0.xy = v.texcoord.xy * float2( 1,1 ) + float2( 0,0 );
  57. }
  58. void surf( Input i , inout SurfaceOutputStandard o )
  59. {
  60. o.Normal = UnpackNormal( tex2D( _NormalMap, i.texcoord_0 ) );
  61. float4 tex2DNode13 = tex2D( _R_AO_G_Edges, i.texcoord_0 );
  62. float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
  63. float componentMask23 = ( abs( ase_worldNormal ) * abs( ase_worldNormal ) ).y;
  64. float3 ase_worldPos = i.worldPos;
  65. float4 temp_cast_0 = (0.0).xxxx;
  66. float4 temp_cast_1 = (1.0).xxxx;
  67. o.Albedo = clamp( ( ( _EdgeColor * ( _EdgeMultiplier * tex2DNode13.g ) ) + ( pow( tex2DNode13.r , _AO_Power ) * lerp( lerp( _Bot_XZ , _Bot_Y , componentMask23 ) , lerp( _Top_XZ , _Top_Y , componentMask23 ) , clamp( ( ase_worldPos.y / _GradientHeight ) , 0.0 , 1.0 ) ) ) ) , temp_cast_0 , temp_cast_1 ).rgb;
  68. o.Alpha = 1;
  69. }
  70. ENDCG
  71. CGPROGRAM
  72. #pragma surface surf Standard keepalpha fullforwardshadows exclude_path:deferred vertex:vertexDataFunc
  73. ENDCG
  74. Pass
  75. {
  76. Name "ShadowCaster"
  77. Tags{ "LightMode" = "ShadowCaster" }
  78. ZWrite On
  79. CGPROGRAM
  80. #pragma vertex vert
  81. #pragma fragment frag
  82. #pragma target 3.0
  83. #pragma multi_compile_shadowcaster
  84. #pragma multi_compile UNITY_PASS_SHADOWCASTER
  85. #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
  86. # include "HLSLSupport.cginc"
  87. #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
  88. #define CAN_SKIP_VPOS
  89. #endif
  90. #include "UnityCG.cginc"
  91. #include "Lighting.cginc"
  92. #include "UnityPBSLighting.cginc"
  93. sampler3D _DitherMaskLOD;
  94. struct v2f
  95. {
  96. V2F_SHADOW_CASTER;
  97. float3 worldPos : TEXCOORD6;
  98. float4 tSpace0 : TEXCOORD1;
  99. float4 tSpace1 : TEXCOORD2;
  100. float4 tSpace2 : TEXCOORD3;
  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. vertexDataFunc( v, customInputData );
  111. float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
  112. half3 worldNormal = UnityObjectToWorldNormal( v.normal );
  113. fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
  114. fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
  115. fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
  116. o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
  117. o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
  118. o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
  119. o.worldPos = worldPos;
  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. float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
  133. fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
  134. surfIN.worldPos = 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. SurfaceOutputStandard o;
  140. UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, 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=10011
  155. 646;227;1066;638;-903.477;126.8352;1;True;False
  156. Node;AmplifyShaderEditor.CommentaryNode;43;-2309.229,387.8848;Float;False;901.0599;287.59;Get World Y Vector Mask;4;23;8;22;15;;0;0
  157. Node;AmplifyShaderEditor.WorldNormalVector;8;-2272.451,474.9954;Float;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT
  158. Node;AmplifyShaderEditor.CommentaryNode;46;-2264.596,-210.1021;Float;False;730.3268;510.8144;Create the world gradient;6;7;2;5;32;33;34;;0;0
  159. Node;AmplifyShaderEditor.AbsOpNode;22;-2001.508,487.0916;Float;False;1;0;FLOAT3;0.0,0,0;False;1;FLOAT3
  160. Node;AmplifyShaderEditor.RangedFloatNode;2;-2214.596,7.199674;Float;False;Property;_GradientHeight;GradientHeight;-1;0;6.4;0;20;0;1;FLOAT
  161. Node;AmplifyShaderEditor.WorldPosInputsNode;7;-2152.796,-160.1021;Float;False;0;4;FLOAT3;FLOAT;FLOAT;FLOAT
  162. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;15;-1802.105,484.8918;Float;False;2;2;0;FLOAT3;0.0,0,0;False;1;FLOAT3;0.0,0,0;False;1;FLOAT3
  163. Node;AmplifyShaderEditor.CommentaryNode;44;-1757.627,730.2855;Float;False;897.6793;426.1704;Lerp the 2 Gradient Bottom Colors according to the above normals y vector;3;21;17;19;;0;0
  164. Node;AmplifyShaderEditor.CommentaryNode;45;-1762.024,1189.983;Float;False;907.8201;534.3306;The same lerp for the Top Gradient Colors;3;27;26;25;;0;0
  165. Node;AmplifyShaderEditor.CommentaryNode;48;-836.3126,-1205.842;Float;False;577.7001;260.6001;Properties to affect the AO;2;41;40;;0;0
  166. Node;AmplifyShaderEditor.ColorNode;26;-1708.009,1484.99;Float;False;Property;_Top_Y;Top_Y;-1;0;0.7259277,0.7647059,0.06185123,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  167. Node;AmplifyShaderEditor.ColorNode;25;-1699.706,1273.792;Float;False;Property;_Top_XZ;Top_XZ;-1;0;0.2569204,0.5525266,0.7279412,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  168. Node;AmplifyShaderEditor.ComponentMaskNode;23;-1620.908,491.5916;Float;False;False;True;False;True;1;0;FLOAT3;0,0,0;False;1;FLOAT
  169. Node;AmplifyShaderEditor.CommentaryNode;47;-831.4337,-898.4309;Float;False;732.6006;499.3974;Properties to affect the edge highlight;4;30;35;37;36;;0;0
  170. Node;AmplifyShaderEditor.CommentaryNode;52;-1809.752,-980.1052;Float;False;886;278;Custom Map (Ambient Occlusion on Red Channel, Edges-like curvature map on Green Channel);1;13;;0;0
  171. Node;AmplifyShaderEditor.RangedFloatNode;34;-1938.991,180.7123;Float;False;Constant;_Float1;Float 1;-1;0;1;0;0;0;1;FLOAT
  172. Node;AmplifyShaderEditor.RangedFloatNode;33;-1935.627,86.51085;Float;False;Constant;_Float0;Float 0;-1;0;0;0;0;0;1;FLOAT
  173. Node;AmplifyShaderEditor.ColorNode;21;-1710.605,947.5924;Float;False;Property;_Bot_Y;Bot_Y;-1;0;0.3877363,0.5955882,0.188311,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  174. Node;AmplifyShaderEditor.ColorNode;19;-1710.304,780.3916;Float;False;Property;_Bot_XZ;Bot_XZ;-1;0;0.7058823,0.2024221,0.2024221,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  175. Node;AmplifyShaderEditor.SimpleDivideOpNode;5;-1896.661,-81.79171;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT
  176. Node;AmplifyShaderEditor.TextureCoordinatesNode;11;-2167.653,-535.7055;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT
  177. Node;AmplifyShaderEditor.LerpOp;27;-1096.107,1417.091;Float;False;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0.0,0,0,0;False;2;FLOAT;0.0;False;1;COLOR
  178. Node;AmplifyShaderEditor.LerpOp;17;-1086.904,837.2902;Float;False;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0.0,0,0,0;False;2;FLOAT;0.0;False;1;COLOR
  179. Node;AmplifyShaderEditor.RangedFloatNode;37;-781.4337,-666.7295;Float;False;Property;_EdgeMultiplier;EdgeMultiplier;-1;0;1;0;5;0;1;FLOAT
  180. Node;AmplifyShaderEditor.SamplerNode;13;-1759.752,-930.1052;Float;True;Property;_R_AO_G_Edges;R_AO_G_Edges;-1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;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;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
  181. Node;AmplifyShaderEditor.ClampOpNode;32;-1722.269,-84.3163;Float;False;3;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;1;FLOAT
  182. Node;AmplifyShaderEditor.RangedFloatNode;41;-786.3125,-1065.242;Float;False;Property;_AO_Power;AO_Power;-1;0;1;0;4;0;1;FLOAT
  183. Node;AmplifyShaderEditor.CommentaryNode;54;-250.27,968.5449;Float;False;574.3599;190.4;Lerp the Bottom and Top Colors according to the world gradient;1;28;;0;0
  184. Node;AmplifyShaderEditor.CommentaryNode;49;16.10875,-872.9755;Float;False;268.1501;198.07;Combine AO with multiply;1;39;;0;0
  185. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;30;-458.5143,-542.0326;Float;False;2;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT
  186. Node;AmplifyShaderEditor.ColorNode;36;-705.3331,-848.4308;Float;False;Property;_EdgeColor;EdgeColor;-1;0;0.9411765,0.9197947,0.7474049,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
  187. Node;AmplifyShaderEditor.LerpOp;28;-200.27,1018.545;Float;False;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0.0;False;1;COLOR
  188. Node;AmplifyShaderEditor.PowerNode;40;-417.6125,-1155.842;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT
  189. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;39;66.10875,-822.9755;Float;False;2;2;0;FLOAT;0.0;False;1;COLOR;0;False;1;COLOR
  190. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;35;-257.8333,-542.6294;Float;False;2;2;0;COLOR;0.0,0,0,0;False;1;FLOAT;0.0,0,0,0;False;1;COLOR
  191. Node;AmplifyShaderEditor.CommentaryNode;50;267.7985,-587.8406;Float;False;273.22;179.4799;Combine Edge color with add;1;38;;0;0
  192. Node;AmplifyShaderEditor.SimpleAddOpNode;38;317.7985,-537.8406;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0.0,0,0,0;False;1;COLOR
  193. Node;AmplifyShaderEditor.CommentaryNode;53;526.0432,467.4425;Float;False;431;239;Normal Map;1;9;;0;0
  194. Node;AmplifyShaderEditor.CommentaryNode;51;568.7342,84.52158;Float;False;918;182;Final Clamp, you can disable it or rise the max value if you want to produce values higher than 1 for HDR;1;42;;0;0
  195. Node;AmplifyShaderEditor.SamplerNode;9;576.0432,517.4425;Float;True;Property;_NormalMap;NormalMap;-1;0;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;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;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
  196. Node;AmplifyShaderEditor.ClampOpNode;42;618.7342,134.5216;Float;False;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0,0,0,0;False;2;COLOR;0,0,0,0;False;1;COLOR
  197. Node;AmplifyShaderEditor.CommentaryNode;55;1607.965,38.88491;Float;False;596.7905;477.5201;Created by Mourelas Konstantinos @mourelask - www.moure.xyz;1;0;;0;0
  198. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1777.777,104.7652;Float;False;True;2;Float;ASEMaterialInspector;0;Standard;ASESampleShaders/Community/EnvironmentGradient;False;False;False;False;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;ForwardOnly;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;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;False;7;FLOAT3;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,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
  199. WireConnection;22;0;8;0
  200. WireConnection;15;0;22;0
  201. WireConnection;15;1;22;0
  202. WireConnection;23;0;15;0
  203. WireConnection;5;0;7;2
  204. WireConnection;5;1;2;0
  205. WireConnection;27;0;25;0
  206. WireConnection;27;1;26;0
  207. WireConnection;27;2;23;0
  208. WireConnection;17;0;19;0
  209. WireConnection;17;1;21;0
  210. WireConnection;17;2;23;0
  211. WireConnection;13;1;11;0
  212. WireConnection;32;0;5;0
  213. WireConnection;32;1;33;0
  214. WireConnection;32;2;34;0
  215. WireConnection;30;0;37;0
  216. WireConnection;30;1;13;2
  217. WireConnection;28;0;17;0
  218. WireConnection;28;1;27;0
  219. WireConnection;28;2;32;0
  220. WireConnection;40;0;13;1
  221. WireConnection;40;1;41;0
  222. WireConnection;39;0;40;0
  223. WireConnection;39;1;28;0
  224. WireConnection;35;0;36;0
  225. WireConnection;35;1;30;0
  226. WireConnection;38;0;35;0
  227. WireConnection;38;1;39;0
  228. WireConnection;9;1;11;0
  229. WireConnection;42;0;38;0
  230. WireConnection;42;1;33;0
  231. WireConnection;42;2;34;0
  232. WireConnection;0;0;42;0
  233. WireConnection;0;1;9;0
  234. ASEEND*/
  235. //CHKSM=CC7D15FE34396B385108885B6E65443ED7FFB4B6