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.

585 lines
38 KiB

7 years ago
7 years ago
7 years ago
7 years ago
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  3. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  4. // Shader created with Shader Forge v1.30
  5. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
  6. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  7. /*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:29724,y:31689,varname:node_23,prsc:2,spu:0.05,spv:0|UVIN-882-OUT,DIST-4763-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:30307,y:32597,varname:node_9449,prsc:2;n:type:ShaderForge.SFN_Sin,id:872,x:30830,y:32637,varname:node_872,prsc:2|IN-3394-OUT;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-5923-OUT,T-728-OUT;n:type:ShaderForge.SFN_Tex2d,id:5880,x:30689,y:32396,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:0.05,spv:0.05|UVIN-882-OUT,DIST-4763-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;n:type:ShaderForge.SFN_ValueProperty,id:633,x:30307,y:32767,ptovrint:False,ptlb:buffer Speed,ptin:_bufferSpeed,varname:node_633,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:0.7;n:type:ShaderForge.SFN_Multiply,id:3394,x:30553,y:32623,varname:node_3394,prsc:2|A-9449-T,B-633-OUT;n:type:ShaderForge.SFN_Multiply,id:5923,x:30969,y:32378,varname:node_5923,prsc:2|A-5880-R,B-6956-OUT;n:type:ShaderForge.SFN_Time,id:7529,x:28507,y:32136,varname:node_7529,prsc:2;n:type:ShaderForge.SFN_Sin,id:2710,x:28903,y:32187,varname:node_2710,prsc:2|IN-6302-OUT;n:type:ShaderForge.SFN_Vector1,id:7346,x:28676,y:32623,varname:node_7346,prsc:2,v1:10;n:type:ShaderForge.SFN_Divide,id:6302,x:28715,y:32261,varname:node_6302,prsc:2|A-7529-T,B-7346-OUT;n:type:ShaderForge.SFN_Multiply,id:4763,x:29135,y:32158,varname:node_4763,prsc:2|A-2710-OUT,B-7346-OUT;proporder:151-267-168-142-8547-1000-5880-965-2802-6891-2646-633;pass:END;sub:END;*/
  8. Shader "LightHouse/WaterShader" {
  9. Properties {
  10. _Diffuse ("Diffuse", 2D) = "black" {}
  11. _Normals ("Normals", 2D) = "black" {}
  12. _GlowColor ("Glow Color", Color) = (1,1,1,1)
  13. _BulgeScale ("Bulge Scale", Float ) = 1.1
  14. _BulgeShape ("Bulge Shape", Float ) = 1.8
  15. _Perlin ("Perlin", 2D) = "bump" {}
  16. _Perlin_copy ("Perlin_copy", 2D) = "white" {}
  17. _ShoreBlend ("ShoreBlend", Range(0, 100)) = 0
  18. _Shore ("Shore", Color) = (1,0,0,1)
  19. _Opacity ("Opacity", Range(0, 1)) = 0.3994928
  20. _Color ("Color", Color) = (0.07352942,0.9233267,1,1)
  21. _bufferSpeed ("buffer Speed", Float ) = 0.7
  22. [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  23. }
  24. SubShader {
  25. Tags {
  26. "IgnoreProjector"="True"
  27. "Queue"="Transparent"
  28. "RenderType"="Transparent"
  29. }
  30. Pass {
  31. Name "FORWARD"
  32. Tags {
  33. "LightMode"="ForwardBase"
  34. }
  35. Blend SrcAlpha OneMinusSrcAlpha
  36. ZWrite Off
  37. CGPROGRAM
  38. #pragma vertex vert
  39. #pragma fragment frag
  40. #define UNITY_PASS_FORWARDBASE
  41. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  42. #include "UnityCG.cginc"
  43. #include "Lighting.cginc"
  44. #include "UnityPBSLighting.cginc"
  45. #include "UnityStandardBRDF.cginc"
  46. #pragma multi_compile_fwdbase
  47. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  48. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  49. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  50. #pragma multi_compile_fog
  51. #pragma exclude_renderers xbox360 ps3
  52. #pragma target 3.0
  53. #pragma glsl
  54. uniform sampler2D _CameraDepthTexture;
  55. uniform float4 _TimeEditor;
  56. uniform float _BulgeScale;
  57. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  58. uniform float4 _GlowColor;
  59. uniform sampler2D _Normals; uniform float4 _Normals_ST;
  60. uniform float _BulgeShape;
  61. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  62. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  63. uniform float _ShoreBlend;
  64. uniform float4 _Shore;
  65. uniform float _Opacity;
  66. uniform float4 _Color;
  67. uniform float _bufferSpeed;
  68. struct VertexInput {
  69. float4 vertex : POSITION;
  70. float3 normal : NORMAL;
  71. float4 tangent : TANGENT;
  72. float2 texcoord0 : TEXCOORD0;
  73. float2 texcoord1 : TEXCOORD1;
  74. float2 texcoord2 : TEXCOORD2;
  75. };
  76. struct VertexOutput {
  77. float4 pos : SV_POSITION;
  78. float2 uv0 : TEXCOORD0;
  79. float2 uv1 : TEXCOORD1;
  80. float2 uv2 : TEXCOORD2;
  81. float4 posWorld : TEXCOORD3;
  82. float3 normalDir : TEXCOORD4;
  83. float3 tangentDir : TEXCOORD5;
  84. float3 bitangentDir : TEXCOORD6;
  85. float4 projPos : TEXCOORD7;
  86. UNITY_FOG_COORDS(8)
  87. #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
  88. float4 ambientOrLightmapUV : TEXCOORD9;
  89. #endif
  90. };
  91. VertexOutput vert (VertexInput v) {
  92. VertexOutput o = (VertexOutput)0;
  93. o.uv0 = v.texcoord0;
  94. o.uv1 = v.texcoord1;
  95. o.uv2 = v.texcoord2;
  96. #ifdef LIGHTMAP_ON
  97. o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  98. o.ambientOrLightmapUV.zw = 0;
  99. #elif UNITY_SHOULD_SAMPLE_SH
  100. #endif
  101. #ifdef DYNAMICLIGHTMAP_ON
  102. o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
  103. #endif
  104. o.normalDir = UnityObjectToWorldNormal(v.normal);
  105. o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
  106. o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  107. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  108. float3 objScale = 1.0/recipObjScale;
  109. float4 node_7529 = _Time + _TimeEditor;
  110. float node_7346 = 10.0;
  111. float node_6302 = (node_7529.g/node_7346);
  112. float node_2710 = sin(node_6302);
  113. float node_4763 = (node_2710*node_7346);
  114. float2 node_882 = (o.uv0*objScale.rb);
  115. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  116. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  117. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  118. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  119. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  120. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  121. float4 node_9449 = _Time + _TimeEditor;
  122. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  123. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  124. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  125. float3 lightColor = _LightColor0.rgb;
  126. o.pos = UnityObjectToClipPos(v.vertex );
  127. UNITY_TRANSFER_FOG(o,o.pos);
  128. o.projPos = ComputeScreenPos (o.pos);
  129. COMPUTE_EYEDEPTH(o.projPos.z);
  130. return o;
  131. }
  132. float4 frag(VertexOutput i) : COLOR {
  133. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  134. float3 objScale = 1.0/recipObjScale;
  135. i.normalDir = normalize(i.normalDir);
  136. float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  137. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  138. float4 node_7529 = _Time + _TimeEditor;
  139. float node_7346 = 10.0;
  140. float node_6302 = (node_7529.g/node_7346);
  141. float node_2710 = sin(node_6302);
  142. float node_4763 = (node_2710*node_7346);
  143. float2 node_882 = (i.uv0*objScale.rb);
  144. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  145. float4 _Normals_var = tex2D(_Normals,TRANSFORM_TEX(node_23, _Normals));
  146. float4 _Perlin_var = tex2D(_Perlin,TRANSFORM_TEX(node_23, _Perlin));
  147. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(node_23, _Diffuse));
  148. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  149. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  150. float4 _Perlin_copy_var = tex2D(_Perlin_copy,TRANSFORM_TEX(node_4275, _Perlin_copy));
  151. float4 node_9449 = _Time + _TimeEditor;
  152. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  153. float3 normalLocal = normalize(lerp(_Normals_var.rgb,float3(0,0,1),node_133));
  154. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  155. float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
  156. float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
  157. float partZ = max(0,i.projPos.z - _ProjectionParams.g);
  158. float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  159. float3 lightColor = _LightColor0.rgb;
  160. float3 halfDirection = normalize(viewDirection+lightDirection);
  161. ////// Lighting:
  162. float attenuation = 1;
  163. float3 attenColor = attenuation * _LightColor0.xyz;
  164. ///////// Gloss:
  165. float gloss = 0.5;
  166. float specPow = exp2( gloss * 10.0+1.0);
  167. /////// GI Data:
  168. UnityLight light;
  169. #ifdef LIGHTMAP_OFF
  170. light.color = lightColor;
  171. light.dir = lightDirection;
  172. light.ndotl = LambertTerm (normalDirection, light.dir);
  173. #else
  174. light.color = half3(0.f, 0.f, 0.f);
  175. light.ndotl = 0.0f;
  176. light.dir = half3(0.f, 0.f, 0.f);
  177. #endif
  178. UnityGIInput d;
  179. d.light = light;
  180. d.worldPos = i.posWorld.xyz;
  181. d.worldViewDir = viewDirection;
  182. d.atten = attenuation;
  183. #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
  184. d.ambient = 0;
  185. d.lightmapUV = i.ambientOrLightmapUV;
  186. #else
  187. d.ambient = i.ambientOrLightmapUV;
  188. #endif
  189. Unity_GlossyEnvironmentData ugls_en_data;
  190. ugls_en_data.roughness = 1.0 - gloss;
  191. ugls_en_data.reflUVW = viewReflectDirection;
  192. UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
  193. lightDirection = gi.light.dir;
  194. lightColor = gi.light.color;
  195. ////// Specular:
  196. float NdotL = max(0, dot( normalDirection, lightDirection ));
  197. float3 node_149 = lerp((_Color.rgb*_Diffuse_var.rgb),_GlowColor.rgb,node_133);
  198. float3 specularColor = (1.0 - node_149);
  199. float3 directSpecular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),specPow)*specularColor;
  200. float3 specular = directSpecular;
  201. /////// Diffuse:
  202. NdotL = dot( normalDirection, lightDirection );
  203. float3 w = float3(node_133,node_133,node_133)*0.5; // Light wrapping
  204. float3 NdotLWrap = NdotL * ( 1.0 - w );
  205. float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
  206. float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(node_133,node_133,node_133);
  207. NdotL = max(0.0,dot( normalDirection, lightDirection ));
  208. float3 directDiffuse = (forwardLight+backLight) * attenColor;
  209. float3 indirectDiffuse = float3(0,0,0);
  210. indirectDiffuse += gi.indirect.diffuse;
  211. float3 diffuseColor = lerp(_Shore.rgb,node_149,saturate((sceneZ-partZ)/_ShoreBlend));
  212. float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
  213. /// Final Color:
  214. float3 finalColor = diffuse + specular;
  215. fixed4 finalRGBA = fixed4(finalColor,_Opacity);
  216. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  217. return finalRGBA;
  218. }
  219. ENDCG
  220. }
  221. Pass {
  222. Name "FORWARD_DELTA"
  223. Tags {
  224. "LightMode"="ForwardAdd"
  225. }
  226. Blend One One
  227. ZWrite Off
  228. CGPROGRAM
  229. #pragma vertex vert
  230. #pragma fragment frag
  231. #define UNITY_PASS_FORWARDADD
  232. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  233. #include "UnityCG.cginc"
  234. #include "AutoLight.cginc"
  235. #include "Lighting.cginc"
  236. #include "UnityPBSLighting.cginc"
  237. #include "UnityStandardBRDF.cginc"
  238. #pragma multi_compile_fwdadd
  239. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  240. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  241. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  242. #pragma multi_compile_fog
  243. #pragma exclude_renderers xbox360 ps3
  244. #pragma target 3.0
  245. #pragma glsl
  246. uniform sampler2D _CameraDepthTexture;
  247. uniform float4 _TimeEditor;
  248. uniform float _BulgeScale;
  249. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  250. uniform float4 _GlowColor;
  251. uniform sampler2D _Normals; uniform float4 _Normals_ST;
  252. uniform float _BulgeShape;
  253. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  254. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  255. uniform float _ShoreBlend;
  256. uniform float4 _Shore;
  257. uniform float _Opacity;
  258. uniform float4 _Color;
  259. uniform float _bufferSpeed;
  260. struct VertexInput {
  261. float4 vertex : POSITION;
  262. float3 normal : NORMAL;
  263. float4 tangent : TANGENT;
  264. float2 texcoord0 : TEXCOORD0;
  265. float2 texcoord1 : TEXCOORD1;
  266. float2 texcoord2 : TEXCOORD2;
  267. };
  268. struct VertexOutput {
  269. float4 pos : SV_POSITION;
  270. float2 uv0 : TEXCOORD0;
  271. float2 uv1 : TEXCOORD1;
  272. float2 uv2 : TEXCOORD2;
  273. float4 posWorld : TEXCOORD3;
  274. float3 normalDir : TEXCOORD4;
  275. float3 tangentDir : TEXCOORD5;
  276. float3 bitangentDir : TEXCOORD6;
  277. float4 projPos : TEXCOORD7;
  278. LIGHTING_COORDS(8,9)
  279. UNITY_FOG_COORDS(10)
  280. };
  281. VertexOutput vert (VertexInput v) {
  282. VertexOutput o = (VertexOutput)0;
  283. o.uv0 = v.texcoord0;
  284. o.uv1 = v.texcoord1;
  285. o.uv2 = v.texcoord2;
  286. o.normalDir = UnityObjectToWorldNormal(v.normal);
  287. o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
  288. o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  289. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  290. float3 objScale = 1.0/recipObjScale;
  291. float4 node_7529 = _Time + _TimeEditor;
  292. float node_7346 = 10.0;
  293. float node_6302 = (node_7529.g/node_7346);
  294. float node_2710 = sin(node_6302);
  295. float node_4763 = (node_2710*node_7346);
  296. float2 node_882 = (o.uv0*objScale.rb);
  297. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  298. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  299. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  300. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  301. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  302. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  303. float4 node_9449 = _Time + _TimeEditor;
  304. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  305. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  306. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  307. float3 lightColor = _LightColor0.rgb;
  308. o.pos = UnityObjectToClipPos(v.vertex );
  309. UNITY_TRANSFER_FOG(o,o.pos);
  310. o.projPos = ComputeScreenPos (o.pos);
  311. COMPUTE_EYEDEPTH(o.projPos.z);
  312. TRANSFER_VERTEX_TO_FRAGMENT(o)
  313. return o;
  314. }
  315. float4 frag(VertexOutput i) : COLOR {
  316. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  317. float3 objScale = 1.0/recipObjScale;
  318. i.normalDir = normalize(i.normalDir);
  319. float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
  320. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  321. float4 node_7529 = _Time + _TimeEditor;
  322. float node_7346 = 10.0;
  323. float node_6302 = (node_7529.g/node_7346);
  324. float node_2710 = sin(node_6302);
  325. float node_4763 = (node_2710*node_7346);
  326. float2 node_882 = (i.uv0*objScale.rb);
  327. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  328. float4 _Normals_var = tex2D(_Normals,TRANSFORM_TEX(node_23, _Normals));
  329. float4 _Perlin_var = tex2D(_Perlin,TRANSFORM_TEX(node_23, _Perlin));
  330. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(node_23, _Diffuse));
  331. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  332. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  333. float4 _Perlin_copy_var = tex2D(_Perlin_copy,TRANSFORM_TEX(node_4275, _Perlin_copy));
  334. float4 node_9449 = _Time + _TimeEditor;
  335. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  336. float3 normalLocal = normalize(lerp(_Normals_var.rgb,float3(0,0,1),node_133));
  337. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  338. float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
  339. float partZ = max(0,i.projPos.z - _ProjectionParams.g);
  340. float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
  341. float3 lightColor = _LightColor0.rgb;
  342. float3 halfDirection = normalize(viewDirection+lightDirection);
  343. ////// Lighting:
  344. float attenuation = LIGHT_ATTENUATION(i);
  345. float3 attenColor = attenuation * _LightColor0.xyz;
  346. ///////// Gloss:
  347. float gloss = 0.5;
  348. float specPow = exp2( gloss * 10.0+1.0);
  349. ////// Specular:
  350. float NdotL = max(0, dot( normalDirection, lightDirection ));
  351. float3 node_149 = lerp((_Color.rgb*_Diffuse_var.rgb),_GlowColor.rgb,node_133);
  352. float3 specularColor = (1.0 - node_149);
  353. float3 directSpecular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),specPow)*specularColor;
  354. float3 specular = directSpecular;
  355. /////// Diffuse:
  356. NdotL = dot( normalDirection, lightDirection );
  357. float3 w = float3(node_133,node_133,node_133)*0.5; // Light wrapping
  358. float3 NdotLWrap = NdotL * ( 1.0 - w );
  359. float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
  360. float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(node_133,node_133,node_133);
  361. NdotL = max(0.0,dot( normalDirection, lightDirection ));
  362. float3 directDiffuse = (forwardLight+backLight) * attenColor;
  363. float3 diffuseColor = lerp(_Shore.rgb,node_149,saturate((sceneZ-partZ)/_ShoreBlend));
  364. float3 diffuse = directDiffuse * diffuseColor;
  365. /// Final Color:
  366. float3 finalColor = diffuse + specular;
  367. fixed4 finalRGBA = fixed4(finalColor * _Opacity,0);
  368. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  369. return finalRGBA;
  370. }
  371. ENDCG
  372. }
  373. Pass {
  374. Name "ShadowCaster"
  375. Tags {
  376. "LightMode"="ShadowCaster"
  377. }
  378. Offset 1, 1
  379. CGPROGRAM
  380. #pragma vertex vert
  381. #pragma fragment frag
  382. #define UNITY_PASS_SHADOWCASTER
  383. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  384. #include "UnityCG.cginc"
  385. #include "Lighting.cginc"
  386. #include "UnityPBSLighting.cginc"
  387. #include "UnityStandardBRDF.cginc"
  388. #pragma fragmentoption ARB_precision_hint_fastest
  389. #pragma multi_compile_shadowcaster
  390. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  391. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  392. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  393. #pragma multi_compile_fog
  394. #pragma exclude_renderers xbox360 ps3
  395. #pragma target 3.0
  396. #pragma glsl
  397. uniform float4 _TimeEditor;
  398. uniform float _BulgeScale;
  399. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  400. uniform float _BulgeShape;
  401. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  402. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  403. uniform float _bufferSpeed;
  404. struct VertexInput {
  405. float4 vertex : POSITION;
  406. float3 normal : NORMAL;
  407. float2 texcoord0 : TEXCOORD0;
  408. float2 texcoord1 : TEXCOORD1;
  409. float2 texcoord2 : TEXCOORD2;
  410. };
  411. struct VertexOutput {
  412. V2F_SHADOW_CASTER;
  413. float2 uv0 : TEXCOORD1;
  414. float2 uv1 : TEXCOORD2;
  415. float2 uv2 : TEXCOORD3;
  416. float4 posWorld : TEXCOORD4;
  417. float3 normalDir : TEXCOORD5;
  418. };
  419. VertexOutput vert (VertexInput v) {
  420. VertexOutput o = (VertexOutput)0;
  421. o.uv0 = v.texcoord0;
  422. o.uv1 = v.texcoord1;
  423. o.uv2 = v.texcoord2;
  424. o.normalDir = UnityObjectToWorldNormal(v.normal);
  425. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  426. float3 objScale = 1.0/recipObjScale;
  427. float4 node_7529 = _Time + _TimeEditor;
  428. float node_7346 = 10.0;
  429. float node_6302 = (node_7529.g/node_7346);
  430. float node_2710 = sin(node_6302);
  431. float node_4763 = (node_2710*node_7346);
  432. float2 node_882 = (o.uv0*objScale.rb);
  433. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  434. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  435. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  436. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  437. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  438. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  439. float4 node_9449 = _Time + _TimeEditor;
  440. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  441. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  442. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  443. o.pos = UnityObjectToClipPos(v.vertex );
  444. TRANSFER_SHADOW_CASTER(o)
  445. return o;
  446. }
  447. float4 frag(VertexOutput i) : COLOR {
  448. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  449. float3 objScale = 1.0/recipObjScale;
  450. i.normalDir = normalize(i.normalDir);
  451. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  452. float3 normalDirection = i.normalDir;
  453. SHADOW_CASTER_FRAGMENT(i)
  454. }
  455. ENDCG
  456. }
  457. Pass {
  458. Name "Meta"
  459. Tags {
  460. "LightMode"="Meta"
  461. }
  462. Cull Off
  463. CGPROGRAM
  464. #pragma vertex vert
  465. #pragma fragment frag
  466. #define UNITY_PASS_META 1
  467. #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
  468. #include "UnityCG.cginc"
  469. #include "Lighting.cginc"
  470. #include "UnityPBSLighting.cginc"
  471. #include "UnityStandardBRDF.cginc"
  472. #include "UnityMetaPass.cginc"
  473. #pragma fragmentoption ARB_precision_hint_fastest
  474. #pragma multi_compile_shadowcaster
  475. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  476. #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
  477. #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
  478. #pragma multi_compile_fog
  479. #pragma exclude_renderers xbox360 ps3
  480. #pragma target 3.0
  481. #pragma glsl
  482. uniform sampler2D _CameraDepthTexture;
  483. uniform float4 _TimeEditor;
  484. uniform float _BulgeScale;
  485. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  486. uniform float4 _GlowColor;
  487. uniform float _BulgeShape;
  488. uniform sampler2D _Perlin; uniform float4 _Perlin_ST;
  489. uniform sampler2D _Perlin_copy; uniform float4 _Perlin_copy_ST;
  490. uniform float _ShoreBlend;
  491. uniform float4 _Shore;
  492. uniform float4 _Color;
  493. uniform float _bufferSpeed;
  494. struct VertexInput {
  495. float4 vertex : POSITION;
  496. float3 normal : NORMAL;
  497. float2 texcoord0 : TEXCOORD0;
  498. float2 texcoord1 : TEXCOORD1;
  499. float2 texcoord2 : TEXCOORD2;
  500. };
  501. struct VertexOutput {
  502. float4 pos : SV_POSITION;
  503. float2 uv0 : TEXCOORD0;
  504. float2 uv1 : TEXCOORD1;
  505. float2 uv2 : TEXCOORD2;
  506. float4 posWorld : TEXCOORD3;
  507. float3 normalDir : TEXCOORD4;
  508. float4 projPos : TEXCOORD5;
  509. };
  510. VertexOutput vert (VertexInput v) {
  511. VertexOutput o = (VertexOutput)0;
  512. o.uv0 = v.texcoord0;
  513. o.uv1 = v.texcoord1;
  514. o.uv2 = v.texcoord2;
  515. o.normalDir = UnityObjectToWorldNormal(v.normal);
  516. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  517. float3 objScale = 1.0/recipObjScale;
  518. float4 node_7529 = _Time + _TimeEditor;
  519. float node_7346 = 10.0;
  520. float node_6302 = (node_7529.g/node_7346);
  521. float node_2710 = sin(node_6302);
  522. float node_4763 = (node_2710*node_7346);
  523. float2 node_882 = (o.uv0*objScale.rb);
  524. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  525. float4 _Perlin_var = tex2Dlod(_Perlin,float4(TRANSFORM_TEX(node_23, _Perlin),0.0,0));
  526. float4 _Diffuse_var = tex2Dlod(_Diffuse,float4(TRANSFORM_TEX(node_23, _Diffuse),0.0,0));
  527. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  528. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  529. float4 _Perlin_copy_var = tex2Dlod(_Perlin_copy,float4(TRANSFORM_TEX(node_4275, _Perlin_copy),0.0,0));
  530. float4 node_9449 = _Time + _TimeEditor;
  531. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  532. v.vertex.xyz += (node_133*_BulgeScale*v.normal);
  533. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  534. o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
  535. o.projPos = ComputeScreenPos (o.pos);
  536. COMPUTE_EYEDEPTH(o.projPos.z);
  537. return o;
  538. }
  539. float4 frag(VertexOutput i) : SV_Target {
  540. float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );
  541. float3 objScale = 1.0/recipObjScale;
  542. i.normalDir = normalize(i.normalDir);
  543. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  544. float3 normalDirection = i.normalDir;
  545. float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
  546. float partZ = max(0,i.projPos.z - _ProjectionParams.g);
  547. UnityMetaInput o;
  548. UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
  549. o.Emission = 0;
  550. float4 node_7529 = _Time + _TimeEditor;
  551. float node_7346 = 10.0;
  552. float node_6302 = (node_7529.g/node_7346);
  553. float node_2710 = sin(node_6302);
  554. float node_4763 = (node_2710*node_7346);
  555. float2 node_882 = (i.uv0*objScale.rb);
  556. float2 node_23 = (node_882+node_4763*float2(0.05,0));
  557. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(node_23, _Diffuse));
  558. float4 _Perlin_var = tex2D(_Perlin,TRANSFORM_TEX(node_23, _Perlin));
  559. float node_6956 = pow((_Diffuse_var.r*1.0+0.0),0.3);
  560. float2 node_4275 = (node_882+node_4763*float2(0.05,0.05));
  561. float4 _Perlin_copy_var = tex2D(_Perlin_copy,TRANSFORM_TEX(node_4275, _Perlin_copy));
  562. float4 node_9449 = _Time + _TimeEditor;
  563. float node_133 = pow(lerp((_Perlin_var.r*node_6956),(_Perlin_copy_var.r*node_6956),(sin((node_9449.g*_bufferSpeed))*0.5+0.5)),_BulgeShape); // Panning gradient
  564. float3 node_149 = lerp((_Color.rgb*_Diffuse_var.rgb),_GlowColor.rgb,node_133);
  565. float3 diffColor = lerp(_Shore.rgb,node_149,saturate((sceneZ-partZ)/_ShoreBlend));
  566. float3 specColor = (1.0 - node_149);
  567. o.Albedo = diffColor + specColor * 0.125; // No gloss connected. Assume it's 0.5
  568. return UnityMetaFragment( o );
  569. }
  570. ENDCG
  571. }
  572. }
  573. FallBack "Diffuse"
  574. CustomEditor "ShaderForgeMaterialInspector"
  575. }