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.

223 lines
16 KiB

  1. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  2. // Shader created with Shader Forge v1.30
  3. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
  4. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  5. /*SF_DATA;ver:1.30;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False;n:type:ShaderForge.SFN_Final,id:9361,x:33209,y:32712,varname:node_9361,prsc:2|normal-7335-RGB,custl-4882-OUT,olcol-2127-OUT;n:type:ShaderForge.SFN_Dot,id:6424,x:31547,y:33253,varname:node_6424,prsc:2,dt:0|A-3093-OUT,B-321-OUT;n:type:ShaderForge.SFN_Slider,id:5658,x:30329,y:33392,ptovrint:False,ptlb:Shadows,ptin:_Shadows,varname:node_5658,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:-1,cur:0,max:1;n:type:ShaderForge.SFN_NormalVector,id:7295,x:30447,y:33021,prsc:2,pt:True;n:type:ShaderForge.SFN_LightVector,id:7110,x:30447,y:33197,varname:node_7110,prsc:2;n:type:ShaderForge.SFN_Code,id:3093,x:30813,y:33114,varname:node_3093,prsc:2,code:ZgBsAG8AYQB0ADMAIAByAGUAdABWAGEAbAAgAD0AIABOAG8AcgBtADsACgAKAGkAbgB0ACAAcABvAHMAIAA9ACAAcwBpAGcAbgAoAFMAbABpAGQAZQByACkAOwAKAAoAcgBlAHQAVgBhAGwAIAA9ACAAbABlAHIAcAAoAE4AbwByAG0ALAAoAHAAbwBzACAAKgAgAEwAaQBnAGgAdAApACwAIAAoAHAAbwBzACAAKgAgAFMAbABpAGQAZQByACkAIAAvACAAMgApADsACgAKAHIAZQB0AHUAcgBuACAAcgBlAHQAVgBhAGwAOwAKAA==,output:2,fname:LerpnegLerp,width:422,height:155,input:2,input:2,input:0,input_1_label:Norm,input_2_label:Light,input_3_label:Slider|A-7295-OUT,B-7110-OUT,C-5658-OUT;n:type:ShaderForge.SFN_Color,id:9263,x:31810,y:32895,ptovrint:False,ptlb:HighLight,ptin:_HighLight,varname:node_9263,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Color,id:6362,x:31810,y:32402,ptovrint:False,ptlb:LowLight,ptin:_LowLight,varname:_HighLight_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Lerp,id:4882,x:32569,y:32899,varname:node_4882,prsc:2|A-2411-OUT,B-982-OUT,T-4220-OUT;n:type:ShaderForge.SFN_Relay,id:2127,x:32559,y:32659,varname:node_2127,prsc:2|IN-2411-OUT;n:type:ShaderForge.SFN_Slider,id:260,x:31143,y:33716,ptovrint:False,ptlb:Gradiant,ptin:_Gradiant,varname:node_260,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:-1,cur:-1,max:1;n:type:ShaderForge.SFN_Code,id:9708,x:32006,y:33414,varname:node_9708,prsc:2,code:ZgBsAG8AYQB0ACAAcgBlAHQAVgBhAGwAOwAKAAoAZgBsAG8AYQB0ACAAdAAgAD0AIAAoACgASQBuAHAAdQB0ACAAKwAgAFMAbABpAGQAZQByACkALwAoADIAKgBTAGwAaQBkAGUAcgApACkAOwAKAHIAZQB0AFYAYQBsACAAPQAgAGwAZQByAHAAIAAoADAALAAxACwAdAApADsACgAKAHIAZQB0AHUAcgBuACAAYwBsAGEAbQBwACAAKAByAGUAdABWAGEAbAAsACAAMAAuADAALAAgADEALgAwACkAOwAKAA==,output:0,fname:CeilifGrad,width:339,height:149,input:0,input:0,input_1_label:Input,input_2_label:Slider|A-6424-OUT,B-257-OUT;n:type:ShaderForge.SFN_LightVector,id:321,x:31167,y:33337,varname:node_321,prsc:2;n:type:ShaderForge.SFN_Slider,id:3114,x:32033,y:33977,ptovrint:False,ptlb:Pen. Intensity,ptin:_PenIntensity,varname:node_3114,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_LightAttenuation,id:1671,x:32252,y:33718,varname:node_1671,prsc:2;n:type:ShaderForge.SFN_Lerp,id:3593,x:32469,y:33784,varname:node_3593,prsc:2|A-1597-OUT,B-1671-OUT,T-3114-OUT;n:type:ShaderForge.SFN_Vector1,id:1597,x:32206,y:33889,varname:node_1597,prsc:2,v1:1;n:type:ShaderForge.SFN_Multiply,id:4220,x:32678,y:33602,varname:node_4220,prsc:2|A-9708-OUT,B-3593-OUT;n:type:ShaderForge.SFN_TexCoord,id:9176,x:30931,y:33742,varname:node_9176,prsc:2,uv:0;n:type:ShaderForge.SFN_TexCoord,id:1762,x:31513,y:32152,varname:node_1762,prsc:2,uv:0;n:type:ShaderForge.SFN_Tex2d,id:7335,x:32519,y:32229,ptovrint:False,ptlb:Normal Map,ptin:_NormalMap,varname:node_7335,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:bbab0a6f7bae9cf42bf057d8ee2755f6,ntxv:3,isnm:True|UVIN-1762-UVOUT;n:type:ShaderForge.SFN_Add,id:6459,x:31564,y:33798,varname:node_6459,prsc:2|A-260-OUT,B-8009-R;n:type:ShaderForge.SFN_Tex2d,id:8009,x:31272,y:33844,ptovrint:False,ptlb:Gradient Map,ptin:_GradientMap,varname:node_8009,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:2,isnm:False|UVIN-9176-UVOUT;n:type:ShaderForge.SFN_Clamp01,id:257,x:31736,y:33709,varname:node_257,prsc:2|IN-6459-OUT;n:type:ShaderForge.SFN_Lerp,id:2411,x:32036,y:32513,varname:node_2411,prsc:2|A-6362-RGB,B-3920-RGB,T-6894-OUT;n:type:ShaderForge.SFN_Tex2d,id:3920,x:31810,y:32572,ptovrint:False,ptlb:LowLight Texture,ptin:_LowLightTexture,varname:node_3920,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:2,isnm:False|UVIN-1762-UVOUT;n:type:ShaderForge.SFN_ToggleProperty,id:6894,x:31810,y:32784,ptovrint:False,ptlb:Use Textures,ptin:_UseTextures,varname:node_6894,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,on:False;n:type:ShaderForge.SFN_Lerp,id:982,x:32054,y:32919,varname:node_982,prsc:2|A-9263-RGB,B-3736-RGB,T-6894-OUT;n:type:ShaderForge.SFN_Tex2d,id:3736,x:31810,y:33067,ptovrint:False,ptlb:HighLight Texture_copy,ptin:_HighLightTexture_copy,varname:_LowLightTexture_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False|UVIN-1762-UVOUT;proporder:5658-260-9263-6362-6894-3736-3920-7335-8009-3114;pass:END;sub:END;*/
  6. Shader "Geomantle/TwoToneDiffuse" {
  7. Properties {
  8. _Shadows ("Shadows", Range(-1, 1)) = 0
  9. _Gradiant ("Gradiant", Range(-1, 1)) = -1
  10. _HighLight ("HighLight", Color) = (1,0.5,0.5,1)
  11. _LowLight ("LowLight", Color) = (0,0.5,0.5,1)
  12. [MaterialToggle] _UseTextures ("Use Textures", Float ) = 0
  13. _HighLightTexture_copy ("HighLight Texture_copy", 2D) = "white" {}
  14. _LowLightTexture ("LowLight Texture", 2D) = "black" {}
  15. _NormalMap ("Normal Map", 2D) = "bump" {}
  16. _GradientMap ("Gradient Map", 2D) = "black" {}
  17. _PenIntensity ("Pen. Intensity", Range(0, 1)) = 0
  18. }
  19. SubShader {
  20. Tags {
  21. "RenderType"="Opaque"
  22. }
  23. Pass {
  24. Name "FORWARD"
  25. Tags {
  26. "LightMode"="ForwardBase"
  27. }
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #define UNITY_PASS_FORWARDBASE
  32. #include "UnityCG.cginc"
  33. #include "AutoLight.cginc"
  34. #include "Lighting.cginc"
  35. #pragma multi_compile_fwdbase_fullshadows
  36. #pragma multi_compile_fog
  37. #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
  38. #pragma target 3.0
  39. uniform float _Shadows;
  40. float3 LerpnegLerp( float3 Norm , float3 Light , float Slider ){
  41. float3 retVal = Norm;
  42. int pos = sign(Slider);
  43. retVal = lerp(Norm,(pos * Light), (pos * Slider) / 2);
  44. return retVal;
  45. }
  46. uniform float4 _HighLight;
  47. uniform float4 _LowLight;
  48. uniform float _Gradiant;
  49. float CeilifGrad( float Input , float Slider ){
  50. float retVal;
  51. float t = ((Input + Slider)/(2*Slider));
  52. retVal = lerp (0,1,t);
  53. return clamp (retVal, 0.0, 1.0);
  54. }
  55. uniform float _PenIntensity;
  56. uniform sampler2D _NormalMap; uniform float4 _NormalMap_ST;
  57. uniform sampler2D _GradientMap; uniform float4 _GradientMap_ST;
  58. uniform sampler2D _LowLightTexture; uniform float4 _LowLightTexture_ST;
  59. uniform fixed _UseTextures;
  60. uniform sampler2D _HighLightTexture_copy; uniform float4 _HighLightTexture_copy_ST;
  61. struct VertexInput {
  62. float4 vertex : POSITION;
  63. float3 normal : NORMAL;
  64. float4 tangent : TANGENT;
  65. float2 texcoord0 : TEXCOORD0;
  66. };
  67. struct VertexOutput {
  68. float4 pos : SV_POSITION;
  69. float2 uv0 : TEXCOORD0;
  70. float4 posWorld : TEXCOORD1;
  71. float3 normalDir : TEXCOORD2;
  72. float3 tangentDir : TEXCOORD3;
  73. float3 bitangentDir : TEXCOORD4;
  74. LIGHTING_COORDS(5,6)
  75. UNITY_FOG_COORDS(7)
  76. };
  77. VertexOutput vert (VertexInput v) {
  78. VertexOutput o = (VertexOutput)0;
  79. o.uv0 = v.texcoord0;
  80. o.normalDir = UnityObjectToWorldNormal(v.normal);
  81. o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
  82. o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  83. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  84. o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  85. UNITY_TRANSFER_FOG(o,o.pos);
  86. TRANSFER_VERTEX_TO_FRAGMENT(o)
  87. return o;
  88. }
  89. float4 frag(VertexOutput i) : COLOR {
  90. i.normalDir = normalize(i.normalDir);
  91. float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  92. float3 _NormalMap_var = UnpackNormal(tex2D(_NormalMap,TRANSFORM_TEX(i.uv0, _NormalMap)));
  93. float3 normalLocal = _NormalMap_var.rgb;
  94. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  95. float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  96. ////// Lighting:
  97. float attenuation = LIGHT_ATTENUATION(i);
  98. float4 _LowLightTexture_var = tex2D(_LowLightTexture,TRANSFORM_TEX(i.uv0, _LowLightTexture));
  99. float3 node_2411 = lerp(_LowLight.rgb,_LowLightTexture_var.rgb,_UseTextures);
  100. float4 _HighLightTexture_copy_var = tex2D(_HighLightTexture_copy,TRANSFORM_TEX(i.uv0, _HighLightTexture_copy));
  101. float4 _GradientMap_var = tex2D(_GradientMap,TRANSFORM_TEX(i.uv0, _GradientMap));
  102. float3 finalColor = lerp(node_2411,lerp(_HighLight.rgb,_HighLightTexture_copy_var.rgb,_UseTextures),(CeilifGrad( dot(LerpnegLerp( normalDirection , lightDirection , _Shadows ),lightDirection) , saturate((_Gradiant+_GradientMap_var.r)) )*lerp(1.0,attenuation,_PenIntensity)));
  103. fixed4 finalRGBA = fixed4(finalColor,1);
  104. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  105. return finalRGBA;
  106. }
  107. ENDCG
  108. }
  109. Pass {
  110. Name "FORWARD_DELTA"
  111. Tags {
  112. "LightMode"="ForwardAdd"
  113. }
  114. Blend One One
  115. CGPROGRAM
  116. #pragma vertex vert
  117. #pragma fragment frag
  118. #define UNITY_PASS_FORWARDADD
  119. #include "UnityCG.cginc"
  120. #include "AutoLight.cginc"
  121. #include "Lighting.cginc"
  122. #pragma multi_compile_fwdadd_fullshadows
  123. #pragma multi_compile_fog
  124. #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
  125. #pragma target 3.0
  126. uniform float _Shadows;
  127. float3 LerpnegLerp( float3 Norm , float3 Light , float Slider ){
  128. float3 retVal = Norm;
  129. int pos = sign(Slider);
  130. retVal = lerp(Norm,(pos * Light), (pos * Slider) / 2);
  131. return retVal;
  132. }
  133. uniform float4 _HighLight;
  134. uniform float4 _LowLight;
  135. uniform float _Gradiant;
  136. float CeilifGrad( float Input , float Slider ){
  137. float retVal;
  138. float t = ((Input + Slider)/(2*Slider));
  139. retVal = lerp (0,1,t);
  140. return clamp (retVal, 0.0, 1.0);
  141. }
  142. uniform float _PenIntensity;
  143. uniform sampler2D _NormalMap; uniform float4 _NormalMap_ST;
  144. uniform sampler2D _GradientMap; uniform float4 _GradientMap_ST;
  145. uniform sampler2D _LowLightTexture; uniform float4 _LowLightTexture_ST;
  146. uniform fixed _UseTextures;
  147. uniform sampler2D _HighLightTexture_copy; uniform float4 _HighLightTexture_copy_ST;
  148. struct VertexInput {
  149. float4 vertex : POSITION;
  150. float3 normal : NORMAL;
  151. float4 tangent : TANGENT;
  152. float2 texcoord0 : TEXCOORD0;
  153. };
  154. struct VertexOutput {
  155. float4 pos : SV_POSITION;
  156. float2 uv0 : TEXCOORD0;
  157. float4 posWorld : TEXCOORD1;
  158. float3 normalDir : TEXCOORD2;
  159. float3 tangentDir : TEXCOORD3;
  160. float3 bitangentDir : TEXCOORD4;
  161. LIGHTING_COORDS(5,6)
  162. UNITY_FOG_COORDS(7)
  163. };
  164. VertexOutput vert (VertexInput v) {
  165. VertexOutput o = (VertexOutput)0;
  166. o.uv0 = v.texcoord0;
  167. o.normalDir = UnityObjectToWorldNormal(v.normal);
  168. o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
  169. o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  170. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  171. o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  172. UNITY_TRANSFER_FOG(o,o.pos);
  173. TRANSFER_VERTEX_TO_FRAGMENT(o)
  174. return o;
  175. }
  176. float4 frag(VertexOutput i) : COLOR {
  177. i.normalDir = normalize(i.normalDir);
  178. float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  179. float3 _NormalMap_var = UnpackNormal(tex2D(_NormalMap,TRANSFORM_TEX(i.uv0, _NormalMap)));
  180. float3 normalLocal = _NormalMap_var.rgb;
  181. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  182. float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
  183. ////// Lighting:
  184. float attenuation = LIGHT_ATTENUATION(i);
  185. float4 _LowLightTexture_var = tex2D(_LowLightTexture,TRANSFORM_TEX(i.uv0, _LowLightTexture));
  186. float3 node_2411 = lerp(_LowLight.rgb,_LowLightTexture_var.rgb,_UseTextures);
  187. float4 _HighLightTexture_copy_var = tex2D(_HighLightTexture_copy,TRANSFORM_TEX(i.uv0, _HighLightTexture_copy));
  188. float4 _GradientMap_var = tex2D(_GradientMap,TRANSFORM_TEX(i.uv0, _GradientMap));
  189. float3 finalColor = lerp(node_2411,lerp(_HighLight.rgb,_HighLightTexture_copy_var.rgb,_UseTextures),(CeilifGrad( dot(LerpnegLerp( normalDirection , lightDirection , _Shadows ),lightDirection) , saturate((_Gradiant+_GradientMap_var.r)) )*lerp(1.0,attenuation,_PenIntensity)));
  190. fixed4 finalRGBA = fixed4(finalColor * 1,0);
  191. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  192. return finalRGBA;
  193. }
  194. ENDCG
  195. }
  196. }
  197. FallBack "Diffuse"
  198. CustomEditor "ShaderForgeMaterialInspector"
  199. }