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.

543 lines
35 KiB

  1. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  2. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  3. // Shader created with Shader Forge v1.30
  4. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
  5. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  6. /*SF_DATA;ver:1.30;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,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:3,bdst:7,dpts:2,wrdp:False,dith:0,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:True,qofs:0,qpre:3,rntp:2,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:1,x:33430,y:32397,varname:node_1,prsc:2|diff-4940-OUT,spec-1863-OUT,normal-4935-OUT,transm-133-OUT,lwrap-133-OUT,alpha-6891-OUT,voffset-140-OUT;n:type:ShaderForge.SFN_Panner,id:23,x:30606,y:31816,varname:node_23,prsc:2,spu:5,spv:0|UVIN-882-OUT;n:type:ShaderForge.SFN_Power,id:133,x:31725,y:32205,cmnt:Panning gradient,varname:node_133,prsc:2|VAL-6791-OUT,EXP-8547-OUT;n:type:ShaderForge.SFN_NormalVector,id:139,x:31952,y:32688,prsc:2,pt:True;n:type:ShaderForge.SFN_Multiply,id:140,x:32326,y:32562,varname:node_140,prsc:2|A-1924-OUT,B-142-OUT,C-139-OUT;n:type:ShaderForge.SFN_ValueProperty,id:142,x:32099,y:32564,ptovrint:False,ptlb:Bulge Scale,ptin:_BulgeScale,varname:_BulgeScale,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:1.1;n:type:ShaderForge.SFN_Lerp,id:149,x:32304,y:31852,varname:node_149,prsc:2|A-288-OUT,B-168-RGB,T-133-OUT;n:type:ShaderForge.SFN_Lerp,id:150,x:32077,y:31694,varname:node_150,prsc:2|A-267-RGB,B-265-OUT,T-133-OUT;n:type:ShaderForge.SFN_Tex2d,id:151,x:30229,y:31339,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:_Diffuse,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:4620d1bc99cb5fd498e646d94b9ee22f,ntxv:2,isnm:False|UVIN-23-UVOUT;n:type:ShaderForge.SFN_Color,id:168,x:32014,y:32121,ptovrint:False,ptlb:Glow Color,ptin:_GlowColor,varname:_GlowColor,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Vector3,id:265,x:31861,y:31760,varname:node_265,prsc:2,v1:0,v2:0,v3:1;n:type:ShaderForge.SFN_Tex2d,id:267,x:31861,y:31576,ptovrint:False,ptlb:Normals,ptin:_Normals,varname:_Normals,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:e1110e8b284166c4090af21bb5bc02fe,ntxv:2,isnm:False|UVIN-23-UVOUT;n:type:ShaderForge.SFN_Vector1,id:4921,x:32326,y:32058,varname:node_4921,prsc:2,v1:1;n:type:ShaderForge.SFN_Normalize,id:4935,x:32359,y:32162,varname:node_4935,prsc:2|IN-150-OUT;n:type:ShaderForge.SFN_ValueProperty,id:8547,x:31500,y:32377,ptovrint:False,ptlb:Bulge Shape,ptin:_BulgeShape,varname:_BulgeShape,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:1.8;n:type:ShaderForge.SFN_Vector1,id:8608,x:32077,y:31543,varname:node_8608,prsc:2,v1:0.1;n:type:ShaderForge.SFN_TexCoord,id:5169,x:29011,y:31532,varname:node_5169,prsc:2,uv:0;n:type:ShaderForge.SFN_Relay,id:1924,x:32099,y:32472,varname:node_1924,prsc:2|IN-133-OUT;n:type:ShaderForge.SFN_Tex2d,id:1000,x:30900,y:31928,ptovrint:False,ptlb:Perlin,ptin:_Perlin,varname:node_1000,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:28c7aad1372ff114b90d330f8a2dd938,ntxv:3,isnm:False|UVIN-23-UVOUT;n:type:ShaderForge.SFN_Time,id:9449,x:30569,y:32615,varname:node_9449,prsc:2;n:type:ShaderForge.SFN_Sin,id:872,x:30830,y:32637,varname:node_872,prsc:2|IN-9449-TSL;n:type:ShaderForge.SFN_RemapRange,id:728,x:31123,y:32628,varname:node_728,prsc:2,frmn:-1,frmx:1,tomn:0,tomx:1|IN-872-OUT;n:type:ShaderForge.SFN_Lerp,id:6791,x:31328,y:32216,varname:node_6791,prsc:2|A-3165-OUT,B-5880-R,T-728-OUT;n:type:ShaderForge.SFN_Tex2d,id:5880,x:30772,y:32411,ptovrint:False,ptlb:Perlin_copy,ptin:_Perlin_copy,varname:_Perlin_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:28c7aad1372ff114b90d330f8a2dd938,ntxv:0,isnm:False|UVIN-4275-UVOUT;n:type:ShaderForge.SFN_Panner,id:4275,x:30532,y:32124,varname:node_4275,prsc:2,spu:2.5,spv:2.5|UVIN-882-OUT;n:type:ShaderForge.SFN_RemapRange,id:7035,x:31235,y:31503,varname:node_7035,prsc:2,frmn:0,frmx:1,tomn:0,tomx:1|IN-151-R;n:type:ShaderForge.SFN_Power,id:6956,x:31577,y:31867,varname:node_6956,prsc:2|VAL-7035-OUT,EXP-6075-OUT;n:type:ShaderForge.SFN_Multiply,id:3165,x:31213,y:31980,varname:node_3165,prsc:2|A-1000-R,B-6956-OUT;n:type:ShaderForge.SFN_Vector1,id:6075,x:31121,y:31811,varname:node_6075,prsc:2,v1:0.3;n:type:ShaderForge.SFN_OneMinus,id:1863,x:32474,y:31884,varname:node_1863,prsc:2|IN-149-OUT;n:type:ShaderForge.SFN_DepthBlend,id:8882,x:32532,y:33176,varname:node_8882,prsc:2|DIST-965-OUT;n:type:ShaderForge.SFN_Slider,id:965,x:32111,y:33235,ptovrint:False,ptlb:ShoreBlend,ptin:_ShoreBlend,varname:node_965,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:100;n:type:ShaderForge.SFN_Color,id:2802,x:32510,y:32768,ptovrint:False,ptlb:Shore,ptin:_Shore,varname:node_2802,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:0,c3:0,c4:1;n:type:ShaderForge.SFN_Lerp,id:4940,x:32895,y:32732,varname:node_4940,prsc:2|A-2802-RGB,B-149-OUT,T-8882-OUT;n:type:ShaderForge.SFN_Slider,id:6891,x:32824,y:33251,ptovrint:False,ptlb:Opacity,ptin:_Opacity,varname:node_6891,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.3994928,max:1;n:type:ShaderForge.SFN_Multiply,id:288,x:31220,y:31249,varname:node_288,prsc:2|A-2646-RGB,B-151-RGB;n:type:ShaderForge.SFN_Color,id:2646,x:30787,y:31052,ptovrint:False,ptlb:Color,ptin:_Color,varname:node_2646,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.07352942,c2:0.9233267,c3:1,c4:1;n:type:ShaderForge.SFN_Multiply,id:882,x:29290,y:31621,varname:node_882,prsc:2|A-5169-UVOUT,B-8975-OUT;n:type:ShaderForge.SFN_ObjectScale,id:3614,x:28773,y:31843,varname:node_3614,prsc:2,rcp:False;n:type:ShaderForge.SFN_ComponentMask,id:8975,x:28974,y:31843,varname:node_8975,prsc:2,cc1:0,cc2:2,cc3:-1,cc4:-1|IN-3614-XYZ;proporder:151-267-168-142-8547-1000-5880-965-2802-6891-2646;pass:END;sub:END;*/
  7. Shader "LightHouse/WaterShader" {
  8. Properties {
  9. _Diffuse ("Diffuse", 2D) = "black" {}
  10. _Normals ("Normals", 2D) = "black" {}
  11. _GlowColor ("Glow Color", Color) = (1,1,1,1)
  12. _BulgeScale ("Bulge Scale", Float ) = 1.1
  13. _BulgeShape ("Bulge Shape", Float ) = 1.8
  14. _Perlin ("Perlin", 2D) = "bump" {}
  15. _Perlin_copy ("Perlin_copy", 2D) = "white" {}
  16. _ShoreBlend ("ShoreBlend", Range(0, 100)) = 0
  17. _Shore ("Shore", Color) = (1,0,0,1)
  18. _Opacity ("Opacity", Range(0, 1)) = 0.3994928
  19. _Color ("Color", Color) = (0.07352942,0.9233267,1,1)
  20. [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  21. }
  22. SubShader {
  23. Tags {
  24. "IgnoreProjector"="True"
  25. "Queue"="Transparent"
  26. "RenderType"="Transparent"
  27. }
  28. Pass {
  29. Name "FORWARD"
  30. Tags {
  31. "LightMode"="ForwardBase"
  32. }
  33. Blend SrcAlpha OneMinusSrcAlpha
  34. ZWrite Off
  35. CGPROGRAM
  36. #pragma vertex vert
  37. #pragma fragment frag
  38. #define UNITY_PASS_FORWARDBASE
  39. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  40. #include "UnityCG.cginc"
  41. #include "Lighting.cginc"
  42. #include "UnityPBSLighting.cginc"
  43. #include "UnityStandardBRDF.cginc"
  44. #pragma multi_compile_fwdbase
  45. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  46. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  47. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  48. #pragma multi_compile_fog
  49. #pragma exclude_renderers xbox360 ps3
  50. #pragma target 3.0
  51. #pragma glsl
  52. uniform sampler2D _CameraDepthTexture;
  53. uniform float4 _TimeEditor;
  54. uniform float _BulgeScale;
  55. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  56. uniform float4 _GlowColor;
  57. uniform sampler2D _Normals; uniform float4 _Normals_ST;
  58. uniform float _BulgeShape;
  59. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  60. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  61. uniform float _ShoreBlend;
  62. uniform float4 _Shore;
  63. uniform float _Opacity;
  64. uniform float4 _Color;
  65. struct VertexInput {
  66. float4 vertex : POSITION;
  67. float3 normal : NORMAL;
  68. float4 tangent : TANGENT;
  69. float2 texcoord0 : TEXCOORD0;
  70. float2 texcoord1 : TEXCOORD1;
  71. float2 texcoord2 : TEXCOORD2;
  72. };
  73. struct VertexOutput {
  74. float4 pos : SV_POSITION;
  75. float2 uv0 : TEXCOORD0;
  76. float2 uv1 : TEXCOORD1;
  77. float2 uv2 : TEXCOORD2;
  78. float4 posWorld : TEXCOORD3;
  79. float3 normalDir : TEXCOORD4;
  80. float3 tangentDir : TEXCOORD5;
  81. float3 bitangentDir : TEXCOORD6;
  82. float4 projPos : TEXCOORD7;
  83. UNITY_FOG_COORDS(8)
  84. #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
  85. float4 ambientOrLightmapUV : TEXCOORD9;
  86. #endif
  87. };
  88. VertexOutput vert (VertexInput v) {
  89. VertexOutput o = (VertexOutput)0;
  90. o.uv0 = v.texcoord0;
  91. o.uv1 = v.texcoord1;
  92. o.uv2 = v.texcoord2;
  93. #ifdef LIGHTMAP_ON
  94. o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  95. o.ambientOrLightmapUV.zw = 0;
  96. #elif UNITY_SHOULD_SAMPLE_SH
  97. #endif
  98. #ifdef DYNAMICLIGHTMAP_ON
  99. o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
  100. #endif
  101. o.normalDir = UnityObjectToWorldNormal(v.normal);
  102. o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
  103. o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  104. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  105. float3 objScale = 1.0/recipObjScale;
  106. float4 node_3480 = _Time + _TimeEditor;
  107. float2 node_882 = (o.uv0*objScale.rb);
  108. float2 node_23 = (node_882+node_3480.g*float2(0.05,0));
  109. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  110. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  111. float2 node_4275 = (node_882+node_3480.g*float2(0.025,0.025));
  112. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  113. float4 node_9449 = _Time + _TimeEditor;
  114. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  115. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  116. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  117. float3 lightColor = _LightColor0.rgb;
  118. o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  119. UNITY_TRANSFER_FOG(o,o.pos);
  120. o.projPos = ComputeScreenPos (o.pos);
  121. COMPUTE_EYEDEPTH(o.projPos.z);
  122. return o;
  123. }
  124. float4 frag(VertexOutput i) : COLOR {
  125. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  126. float3 objScale = 1.0/recipObjScale;
  127. i.normalDir = normalize(i.normalDir);
  128. float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  129. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  130. float4 node_3480 = _Time + _TimeEditor;
  131. float2 node_882 = (i.uv0*objScale.rb);
  132. float2 node_23 = (node_882+node_3480.g*float2(0.05,0));
  133. float4 _Normals_var = tex2D(_Normals,TRANSFORM_TEX(node_23, _Normals));
  134. float4 _Perlin_var = tex2D(_Perlin,TRANSFORM_TEX(node_23, _Perlin));
  135. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(node_23, _Diffuse));
  136. float2 node_4275 = (node_882+node_3480.g*float2(0.025,0.025));
  137. float4 _Perlin_copy_var = tex2D(_Perlin_copy,TRANSFORM_TEX(node_4275, _Perlin_copy));
  138. float4 node_9449 = _Time + _TimeEditor;
  139. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  140. float3 normalLocal = normalize(lerp(_Normals_var.rgb,float3(0,0,1),node_133));
  141. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  142. float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
  143. float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
  144. float partZ = max(0,i.projPos.z - _ProjectionParams.g);
  145. float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  146. float3 lightColor = _LightColor0.rgb;
  147. float3 halfDirection = normalize(viewDirection+lightDirection);
  148. ////// Lighting:
  149. float attenuation = 1;
  150. float3 attenColor = attenuation * _LightColor0.xyz;
  151. ///////// Gloss:
  152. float gloss = 0.5;
  153. float specPow = exp2( gloss * 10.0+1.0);
  154. /////// GI Data:
  155. UnityLight light;
  156. #ifdef LIGHTMAP_OFF
  157. light.color = lightColor;
  158. light.dir = lightDirection;
  159. light.ndotl = LambertTerm (normalDirection, light.dir);
  160. #else
  161. light.color = half3(0.f, 0.f, 0.f);
  162. light.ndotl = 0.0f;
  163. light.dir = half3(0.f, 0.f, 0.f);
  164. #endif
  165. UnityGIInput d;
  166. d.light = light;
  167. d.worldPos = i.posWorld.xyz;
  168. d.worldViewDir = viewDirection;
  169. d.atten = attenuation;
  170. #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
  171. d.ambient = 0;
  172. d.lightmapUV = i.ambientOrLightmapUV;
  173. #else
  174. d.ambient = i.ambientOrLightmapUV;
  175. #endif
  176. Unity_GlossyEnvironmentData ugls_en_data;
  177. ugls_en_data.roughness = 1.0 - gloss;
  178. ugls_en_data.reflUVW = viewReflectDirection;
  179. UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
  180. lightDirection = gi.light.dir;
  181. lightColor = gi.light.color;
  182. ////// Specular:
  183. float NdotL = max(0, dot( normalDirection, lightDirection ));
  184. float3 node_149 = lerp((_Color.rgb*_Diffuse_var.rgb),_GlowColor.rgb,node_133);
  185. float3 specularColor = (1.0 - node_149);
  186. float3 directSpecular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),specPow)*specularColor;
  187. float3 specular = directSpecular;
  188. /////// Diffuse:
  189. NdotL = dot( normalDirection, lightDirection );
  190. float3 w = float3(node_133,node_133,node_133)*0.5; // Light wrapping
  191. float3 NdotLWrap = NdotL * ( 1.0 - w );
  192. float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
  193. float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(node_133,node_133,node_133);
  194. NdotL = max(0.0,dot( normalDirection, lightDirection ));
  195. float3 directDiffuse = (forwardLight+backLight) * attenColor;
  196. float3 indirectDiffuse = float3(0,0,0);
  197. indirectDiffuse += gi.indirect.diffuse;
  198. float3 diffuseColor = lerp(_Shore.rgb,node_149,saturate((sceneZ-partZ)/_ShoreBlend));
  199. float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
  200. /// Final Color:
  201. float3 finalColor = diffuse + specular;
  202. fixed4 finalRGBA = fixed4(finalColor,_Opacity);
  203. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  204. return finalRGBA;
  205. }
  206. ENDCG
  207. }
  208. Pass {
  209. Name "FORWARD_DELTA"
  210. Tags {
  211. "LightMode"="ForwardAdd"
  212. }
  213. Blend One One
  214. ZWrite Off
  215. CGPROGRAM
  216. #pragma vertex vert
  217. #pragma fragment frag
  218. #define UNITY_PASS_FORWARDADD
  219. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  220. #include "UnityCG.cginc"
  221. #include "AutoLight.cginc"
  222. #include "Lighting.cginc"
  223. #include "UnityPBSLighting.cginc"
  224. #include "UnityStandardBRDF.cginc"
  225. #pragma multi_compile_fwdadd
  226. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  227. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  228. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  229. #pragma multi_compile_fog
  230. #pragma exclude_renderers xbox360 ps3
  231. #pragma target 3.0
  232. #pragma glsl
  233. uniform sampler2D _CameraDepthTexture;
  234. uniform float4 _TimeEditor;
  235. uniform float _BulgeScale;
  236. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  237. uniform float4 _GlowColor;
  238. uniform sampler2D _Normals; uniform float4 _Normals_ST;
  239. uniform float _BulgeShape;
  240. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  241. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  242. uniform float _ShoreBlend;
  243. uniform float4 _Shore;
  244. uniform float _Opacity;
  245. uniform float4 _Color;
  246. struct VertexInput {
  247. float4 vertex : POSITION;
  248. float3 normal : NORMAL;
  249. float4 tangent : TANGENT;
  250. float2 texcoord0 : TEXCOORD0;
  251. float2 texcoord1 : TEXCOORD1;
  252. float2 texcoord2 : TEXCOORD2;
  253. };
  254. struct VertexOutput {
  255. float4 pos : SV_POSITION;
  256. float2 uv0 : TEXCOORD0;
  257. float2 uv1 : TEXCOORD1;
  258. float2 uv2 : TEXCOORD2;
  259. float4 posWorld : TEXCOORD3;
  260. float3 normalDir : TEXCOORD4;
  261. float3 tangentDir : TEXCOORD5;
  262. float3 bitangentDir : TEXCOORD6;
  263. float4 projPos : TEXCOORD7;
  264. LIGHTING_COORDS(8,9)
  265. UNITY_FOG_COORDS(10)
  266. };
  267. VertexOutput vert (VertexInput v) {
  268. VertexOutput o = (VertexOutput)0;
  269. o.uv0 = v.texcoord0;
  270. o.uv1 = v.texcoord1;
  271. o.uv2 = v.texcoord2;
  272. o.normalDir = UnityObjectToWorldNormal(v.normal);
  273. o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
  274. o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  275. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  276. float3 objScale = 1.0/recipObjScale;
  277. float4 node_175 = _Time + _TimeEditor;
  278. float2 node_882 = (o.uv0*objScale.rb);
  279. float2 node_23 = (node_882+node_175.g*float2(0.05,0));
  280. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  281. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  282. float2 node_4275 = (node_882+node_175.g*float2(0.025,0.025));
  283. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  284. float4 node_9449 = _Time + _TimeEditor;
  285. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  286. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  287. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  288. float3 lightColor = _LightColor0.rgb;
  289. o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  290. UNITY_TRANSFER_FOG(o,o.pos);
  291. o.projPos = ComputeScreenPos (o.pos);
  292. COMPUTE_EYEDEPTH(o.projPos.z);
  293. TRANSFER_VERTEX_TO_FRAGMENT(o)
  294. return o;
  295. }
  296. float4 frag(VertexOutput i) : COLOR {
  297. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  298. float3 objScale = 1.0/recipObjScale;
  299. i.normalDir = normalize(i.normalDir);
  300. float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  301. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  302. float4 node_175 = _Time + _TimeEditor;
  303. float2 node_882 = (i.uv0*objScale.rb);
  304. float2 node_23 = (node_882+node_175.g*float2(0.05,0));
  305. float4 _Normals_var = tex2D(_Normals,TRANSFORM_TEX(node_23, _Normals));
  306. float4 _Perlin_var = tex2D(_Perlin,TRANSFORM_TEX(node_23, _Perlin));
  307. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(node_23, _Diffuse));
  308. float2 node_4275 = (node_882+node_175.g*float2(0.025,0.025));
  309. float4 _Perlin_copy_var = tex2D(_Perlin_copy,TRANSFORM_TEX(node_4275, _Perlin_copy));
  310. float4 node_9449 = _Time + _TimeEditor;
  311. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  312. float3 normalLocal = normalize(lerp(_Normals_var.rgb,float3(0,0,1),node_133));
  313. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  314. float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
  315. float partZ = max(0,i.projPos.z - _ProjectionParams.g);
  316. float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
  317. float3 lightColor = _LightColor0.rgb;
  318. float3 halfDirection = normalize(viewDirection+lightDirection);
  319. ////// Lighting:
  320. float attenuation = LIGHT_ATTENUATION(i);
  321. float3 attenColor = attenuation * _LightColor0.xyz;
  322. ///////// Gloss:
  323. float gloss = 0.5;
  324. float specPow = exp2( gloss * 10.0+1.0);
  325. ////// Specular:
  326. float NdotL = max(0, dot( normalDirection, lightDirection ));
  327. float3 node_149 = lerp((_Color.rgb*_Diffuse_var.rgb),_GlowColor.rgb,node_133);
  328. float3 specularColor = (1.0 - node_149);
  329. float3 directSpecular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),specPow)*specularColor;
  330. float3 specular = directSpecular;
  331. /////// Diffuse:
  332. NdotL = dot( normalDirection, lightDirection );
  333. float3 w = float3(node_133,node_133,node_133)*0.5; // Light wrapping
  334. float3 NdotLWrap = NdotL * ( 1.0 - w );
  335. float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
  336. float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(node_133,node_133,node_133);
  337. NdotL = max(0.0,dot( normalDirection, lightDirection ));
  338. float3 directDiffuse = (forwardLight+backLight) * attenColor;
  339. float3 diffuseColor = lerp(_Shore.rgb,node_149,saturate((sceneZ-partZ)/_ShoreBlend));
  340. float3 diffuse = directDiffuse * diffuseColor;
  341. /// Final Color:
  342. float3 finalColor = diffuse + specular;
  343. fixed4 finalRGBA = fixed4(finalColor * _Opacity,0);
  344. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  345. return finalRGBA;
  346. }
  347. ENDCG
  348. }
  349. Pass {
  350. Name "ShadowCaster"
  351. Tags {
  352. "LightMode"="ShadowCaster"
  353. }
  354. Offset 1, 1
  355. CGPROGRAM
  356. #pragma vertex vert
  357. #pragma fragment frag
  358. #define UNITY_PASS_SHADOWCASTER
  359. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  360. #include "UnityCG.cginc"
  361. #include "Lighting.cginc"
  362. #include "UnityPBSLighting.cginc"
  363. #include "UnityStandardBRDF.cginc"
  364. #pragma fragmentoption ARB_precision_hint_fastest
  365. #pragma multi_compile_shadowcaster
  366. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  367. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  368. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  369. #pragma multi_compile_fog
  370. #pragma exclude_renderers xbox360 ps3
  371. #pragma target 3.0
  372. #pragma glsl
  373. uniform float4 _TimeEditor;
  374. uniform float _BulgeScale;
  375. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  376. uniform float _BulgeShape;
  377. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  378. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  379. struct VertexInput {
  380. float4 vertex : POSITION;
  381. float3 normal : NORMAL;
  382. float2 texcoord0 : TEXCOORD0;
  383. float2 texcoord1 : TEXCOORD1;
  384. float2 texcoord2 : TEXCOORD2;
  385. };
  386. struct VertexOutput {
  387. V2F_SHADOW_CASTER;
  388. float2 uv0 : TEXCOORD1;
  389. float2 uv1 : TEXCOORD2;
  390. float2 uv2 : TEXCOORD3;
  391. float4 posWorld : TEXCOORD4;
  392. float3 normalDir : TEXCOORD5;
  393. };
  394. VertexOutput vert (VertexInput v) {
  395. VertexOutput o = (VertexOutput)0;
  396. o.uv0 = v.texcoord0;
  397. o.uv1 = v.texcoord1;
  398. o.uv2 = v.texcoord2;
  399. o.normalDir = UnityObjectToWorldNormal(v.normal);
  400. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  401. float3 objScale = 1.0/recipObjScale;
  402. float4 node_8823 = _Time + _TimeEditor;
  403. float2 node_882 = (o.uv0*objScale.rb);
  404. float2 node_23 = (node_882+node_8823.g*float2(0.05,0));
  405. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  406. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  407. float2 node_4275 = (node_882+node_8823.g*float2(0.025,0.025));
  408. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  409. float4 node_9449 = _Time + _TimeEditor;
  410. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  411. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  412. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  413. o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
  414. TRANSFER_SHADOW_CASTER(o)
  415. return o;
  416. }
  417. float4 frag(VertexOutput i) : COLOR {
  418. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  419. float3 objScale = 1.0/recipObjScale;
  420. i.normalDir = normalize(i.normalDir);
  421. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  422. float3 normalDirection = i.normalDir;
  423. SHADOW_CASTER_FRAGMENT(i)
  424. }
  425. ENDCG
  426. }
  427. Pass {
  428. Name "Meta"
  429. Tags {
  430. "LightMode"="Meta"
  431. }
  432. Cull Off
  433. CGPROGRAM
  434. #pragma vertex vert
  435. #pragma fragment frag
  436. #define UNITY_PASS_META 1
  437. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  438. #include "UnityCG.cginc"
  439. #include "Lighting.cginc"
  440. #include "UnityPBSLighting.cginc"
  441. #include "UnityStandardBRDF.cginc"
  442. #include "UnityMetaPass.cginc"
  443. #pragma fragmentoption ARB_precision_hint_fastest
  444. #pragma multi_compile_shadowcaster
  445. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  446. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  447. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  448. #pragma multi_compile_fog
  449. #pragma exclude_renderers xbox360 ps3
  450. #pragma target 3.0
  451. #pragma glsl
  452. uniform sampler2D _CameraDepthTexture;
  453. uniform float4 _TimeEditor;
  454. uniform float _BulgeScale;
  455. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  456. uniform float4 _GlowColor;
  457. uniform float _BulgeShape;
  458. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  459. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  460. uniform float _ShoreBlend;
  461. uniform float4 _Shore;
  462. uniform float4 _Color;
  463. struct VertexInput {
  464. float4 vertex : POSITION;
  465. float3 normal : NORMAL;
  466. float2 texcoord0 : TEXCOORD0;
  467. float2 texcoord1 : TEXCOORD1;
  468. float2 texcoord2 : TEXCOORD2;
  469. };
  470. struct VertexOutput {
  471. float4 pos : SV_POSITION;
  472. float2 uv0 : TEXCOORD0;
  473. float2 uv1 : TEXCOORD1;
  474. float2 uv2 : TEXCOORD2;
  475. float4 posWorld : TEXCOORD3;
  476. float3 normalDir : TEXCOORD4;
  477. float4 projPos : TEXCOORD5;
  478. };
  479. VertexOutput vert (VertexInput v) {
  480. VertexOutput o = (VertexOutput)0;
  481. o.uv0 = v.texcoord0;
  482. o.uv1 = v.texcoord1;
  483. o.uv2 = v.texcoord2;
  484. o.normalDir = UnityObjectToWorldNormal(v.normal);
  485. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  486. float3 objScale = 1.0/recipObjScale;
  487. float4 node_4394 = _Time + _TimeEditor;
  488. float2 node_882 = (o.uv0*objScale.rb);
  489. float2 node_23 = (node_882+node_4394.g*float2(0.05,0));
  490. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  491. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  492. float2 node_4275 = (node_882+node_4394.g*float2(0.025,0.025));
  493. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  494. float4 node_9449 = _Time + _TimeEditor;
  495. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  496. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  497. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  498. o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
  499. o.projPos = ComputeScreenPos (o.pos);
  500. COMPUTE_EYEDEPTH(o.projPos.z);
  501. return o;
  502. }
  503. float4 frag(VertexOutput i) : SV_Target {
  504. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  505. float3 objScale = 1.0/recipObjScale;
  506. i.normalDir = normalize(i.normalDir);
  507. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  508. float3 normalDirection = i.normalDir;
  509. float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
  510. float partZ = max(0,i.projPos.z - _ProjectionParams.g);
  511. UnityMetaInput o;
  512. UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
  513. o.Emission = 0;
  514. float4 node_4394 = _Time + _TimeEditor;
  515. float2 node_882 = (i.uv0*objScale.rb);
  516. float2 node_23 = (node_882+node_4394.g*float2(0.05,0));
  517. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(node_23, _Diffuse));
  518. float4 _Perlin_var = tex2D(_Perlin,TRANSFORM_TEX(node_23, _Perlin));
  519. float2 node_4275 = (node_882+node_4394.g*float2(0.025,0.025));
  520. float4 _Perlin_copy_var = tex2D(_Perlin_copy,TRANSFORM_TEX(node_4275, _Perlin_copy));
  521. float4 node_9449 = _Time + _TimeEditor;
  522. float node_133 = pow(lerp((_Perlin_var.r*pow((_Diffuse_var.r*1.0+0.0),0.3)),_Perlin_copy_var.r,(sin(node_9449.r)*0.5+0.5)),_BulgeShape); // Panning gradient
  523. float3 node_149 = lerp((_Color.rgb*_Diffuse_var.rgb),_GlowColor.rgb,node_133);
  524. float3 diffColor = lerp(_Shore.rgb,node_149,saturate((sceneZ-partZ)/_ShoreBlend));
  525. float3 specColor = (1.0 - node_149);
  526. o.Albedo = diffColor + specColor * 0.125; // No gloss connected. Assume it's 0.5
  527. return UnityMetaFragment( o );
  528. }
  529. ENDCG
  530. }
  531. }
  532. FallBack "Diffuse"
  533. CustomEditor "ShaderForgeMaterialInspector"
  534. }