// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' // Shader created with Shader Forge v1.30 // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/ // Note: Manually altering this data may prevent you from opening it in Shader Forge /*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-7524-OUT,alpha-677-OUT,voffset-4711-OUT;n:type:ShaderForge.SFN_Distance,id:9544,x:31798,y:32501,varname:node_9544,prsc:2|A-1960-UVOUT,B-7815-OUT;n:type:ShaderForge.SFN_TexCoord,id:1960,x:31563,y:32410,varname:node_1960,prsc:2,uv:0;n:type:ShaderForge.SFN_Vector2,id:7815,x:31563,y:32587,varname:node_7815,prsc:2,v1:0.5,v2:0.5;n:type:ShaderForge.SFN_Add,id:7248,x:32013,y:32501,varname:node_7248,prsc:2|A-9544-OUT,B-8808-OUT;n:type:ShaderForge.SFN_Sin,id:5748,x:32366,y:32520,varname:node_5748,prsc:2|IN-6766-OUT;n:type:ShaderForge.SFN_RemapRange,id:8808,x:31776,y:32721,varname:node_8808,prsc:2,frmn:0,frmx:2,tomn:0,tomx:1|IN-9742-OUT;n:type:ShaderForge.SFN_Multiply,id:6766,x:32198,y:32520,varname:node_6766,prsc:2|A-7248-OUT,B-1783-OUT;n:type:ShaderForge.SFN_Slider,id:1783,x:31895,y:32812,ptovrint:False,ptlb:Ring_Amount,ptin:_Ring_Amount,varname:node_1783,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:1,cur:19.17478,max:200;n:type:ShaderForge.SFN_Time,id:8294,x:31085,y:32629,varname:node_8294,prsc:2;n:type:ShaderForge.SFN_OneMinus,id:6695,x:31563,y:32739,varname:node_6695,prsc:2|IN-5972-OUT;n:type:ShaderForge.SFN_NormalVector,id:5768,x:32771,y:33002,prsc:2,pt:False;n:type:ShaderForge.SFN_Multiply,id:4711,x:33050,y:32857,varname:node_4711,prsc:2|A-118-OUT,B-5768-OUT;n:type:ShaderForge.SFN_Color,id:5556,x:32639,y:32012,ptovrint:False,ptlb:FoamColor,ptin:_FoamColor,varname:node_5556,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_Multiply,id:118,x:32652,y:32879,varname:node_118,prsc:2|A-5748-OUT,B-3985-OUT;n:type:ShaderForge.SFN_Slider,id:3985,x:32250,y:33044,ptovrint:False,ptlb:WaveHeight,ptin:_WaveHeight,varname:node_3985,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:1,cur:5.549279,max:10;n:type:ShaderForge.SFN_Slider,id:9742,x:30915,y:32824,ptovrint:False,ptlb:Speed,ptin:_Speed,varname:node_9742,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:-1,cur:-1,max:1.5;n:type:ShaderForge.SFN_Clamp01,id:1198,x:32804,y:32376,varname:node_1198,prsc:2|IN-5748-OUT;n:type:ShaderForge.SFN_Multiply,id:677,x:33117,y:32477,varname:node_677,prsc:2|A-1198-OUT,B-2892-OUT,C-6357-OUT;n:type:ShaderForge.SFN_OneMinus,id:9994,x:32013,y:32251,varname:node_9994,prsc:2|IN-9544-OUT;n:type:ShaderForge.SFN_Round,id:2892,x:32210,y:32251,varname:node_2892,prsc:2|IN-9994-OUT;n:type:ShaderForge.SFN_Multiply,id:7524,x:33117,y:32314,varname:node_7524,prsc:2|A-5556-RGB,B-1198-OUT;n:type:ShaderForge.SFN_Multiply,id:5972,x:31340,y:32739,varname:node_5972,prsc:2|A-8294-T,B-9742-OUT;n:type:ShaderForge.SFN_Slider,id:6357,x:32597,y:32713,ptovrint:False,ptlb:Fade,ptin:_Fade,varname:node_6357,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;proporder:1783-5556-3985-9742-6357;pass:END;sub:END;*/ Shader "LightHouse/WaterShader" { Properties { _Ring_Amount ("Ring_Amount", Range(1, 200)) = 19.17478 _FoamColor ("FoamColor", Color) = (1,1,1,1) _WaveHeight ("WaveHeight", Range(1, 10)) = 5.549279 _Speed ("Speed", Range(-1, 1.5)) = -1 _Fade ("Fade", Range(0, 1)) = 1 [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } SubShader { Tags { "IgnoreProjector"="True" "Queue"="Transparent" "RenderType"="Transparent" } Pass { Name "FORWARD" Tags { "LightMode"="ForwardBase" } Blend SrcAlpha OneMinusSrcAlpha ZWrite Off CGPROGRAM #pragma vertex vert #pragma fragment frag #define UNITY_PASS_FORWARDBASE #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" #include "UnityStandardBRDF.cginc" #pragma multi_compile_fwdbase #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON #pragma multi_compile_fog #pragma exclude_renderers xbox360 ps3 #pragma target 3.0 uniform float _Ring_Amount; uniform float4 _FoamColor; uniform float _WaveHeight; uniform float _Speed; uniform float _Fade; struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; float4 tangent : TANGENT; float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; float2 texcoord2 : TEXCOORD2; }; struct VertexOutput { float4 pos : SV_POSITION; float2 uv0 : TEXCOORD0; float2 uv1 : TEXCOORD1; float2 uv2 : TEXCOORD2; float4 posWorld : TEXCOORD3; float3 normalDir : TEXCOORD4; float3 tangentDir : TEXCOORD5; float3 bitangentDir : TEXCOORD6; UNITY_FOG_COORDS(7) #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH) float4 ambientOrLightmapUV : TEXCOORD8; #endif }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.uv0 = v.texcoord0; o.uv1 = v.texcoord1; o.uv2 = v.texcoord2; #ifdef LIGHTMAP_ON o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; o.ambientOrLightmapUV.zw = 0; #elif UNITY_SHOULD_SAMPLE_SH #endif #ifdef DYNAMICLIGHTMAP_ON o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; #endif o.normalDir = UnityObjectToWorldNormal(v.normal); o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); float node_9544 = distance(o.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); v.vertex.xyz += ((node_5748*_WaveHeight)*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); float3 lightColor = _LightColor0.rgb; o.pos = UnityObjectToClipPos(v.vertex ); UNITY_TRANSFER_FOG(o,o.pos); return o; } float4 frag(VertexOutput i) : COLOR { i.normalDir = normalize(i.normalDir); float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 normalDirection = i.normalDir; float3 viewReflectDirection = reflect( -viewDirection, normalDirection ); float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz); float3 lightColor = _LightColor0.rgb; ////// Lighting: float attenuation = 1; float3 attenColor = attenuation * _LightColor0.xyz; /////// GI Data: UnityLight light; #ifdef LIGHTMAP_OFF light.color = lightColor; light.dir = lightDirection; light.ndotl = LambertTerm (normalDirection, light.dir); #else light.color = half3(0.f, 0.f, 0.f); light.ndotl = 0.0f; light.dir = half3(0.f, 0.f, 0.f); #endif UnityGIInput d; d.light = light; d.worldPos = i.posWorld.xyz; d.worldViewDir = viewDirection; d.atten = attenuation; #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) d.ambient = 0; d.lightmapUV = i.ambientOrLightmapUV; #else d.ambient = i.ambientOrLightmapUV; #endif Unity_GlossyEnvironmentData ugls_en_data; ugls_en_data.roughness = 1.0 - 0; ugls_en_data.reflUVW = viewReflectDirection; UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data ); lightDirection = gi.light.dir; lightColor = gi.light.color; /////// Diffuse: float NdotL = max(0.0,dot( normalDirection, lightDirection )); float3 directDiffuse = max( 0.0, NdotL) * attenColor; float3 indirectDiffuse = float3(0,0,0); indirectDiffuse += gi.indirect.diffuse; float node_9544 = distance(i.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); float node_1198 = saturate(node_5748); float3 diffuseColor = (_FoamColor.rgb*node_1198); float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor; /// Final Color: float3 finalColor = diffuse; fixed4 finalRGBA = fixed4(finalColor,(node_1198*round((1.0 - node_9544))*_Fade)); UNITY_APPLY_FOG(i.fogCoord, finalRGBA); return finalRGBA; } ENDCG } Pass { Name "FORWARD_DELTA" Tags { "LightMode"="ForwardAdd" } Blend One One ZWrite Off CGPROGRAM #pragma vertex vert #pragma fragment frag #define UNITY_PASS_FORWARDADD #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "AutoLight.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" #include "UnityStandardBRDF.cginc" #pragma multi_compile_fwdadd #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON #pragma multi_compile_fog #pragma exclude_renderers xbox360 ps3 #pragma target 3.0 uniform float _Ring_Amount; uniform float4 _FoamColor; uniform float _WaveHeight; uniform float _Speed; uniform float _Fade; struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; float4 tangent : TANGENT; float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; float2 texcoord2 : TEXCOORD2; }; struct VertexOutput { float4 pos : SV_POSITION; float2 uv0 : TEXCOORD0; float2 uv1 : TEXCOORD1; float2 uv2 : TEXCOORD2; float4 posWorld : TEXCOORD3; float3 normalDir : TEXCOORD4; float3 tangentDir : TEXCOORD5; float3 bitangentDir : TEXCOORD6; LIGHTING_COORDS(7,8) UNITY_FOG_COORDS(9) }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.uv0 = v.texcoord0; o.uv1 = v.texcoord1; o.uv2 = v.texcoord2; o.normalDir = UnityObjectToWorldNormal(v.normal); o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); float node_9544 = distance(o.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); v.vertex.xyz += ((node_5748*_WaveHeight)*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); float3 lightColor = _LightColor0.rgb; o.pos = UnityObjectToClipPos(v.vertex ); UNITY_TRANSFER_FOG(o,o.pos); TRANSFER_VERTEX_TO_FRAGMENT(o) return o; } float4 frag(VertexOutput i) : COLOR { i.normalDir = normalize(i.normalDir); float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 normalDirection = i.normalDir; float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); float3 lightColor = _LightColor0.rgb; ////// Lighting: float attenuation = LIGHT_ATTENUATION(i); float3 attenColor = attenuation * _LightColor0.xyz; /////// Diffuse: float NdotL = max(0.0,dot( normalDirection, lightDirection )); float3 directDiffuse = max( 0.0, NdotL) * attenColor; float node_9544 = distance(i.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); float node_1198 = saturate(node_5748); float3 diffuseColor = (_FoamColor.rgb*node_1198); float3 diffuse = directDiffuse * diffuseColor; /// Final Color: float3 finalColor = diffuse; fixed4 finalRGBA = fixed4(finalColor * (node_1198*round((1.0 - node_9544))*_Fade),0); UNITY_APPLY_FOG(i.fogCoord, finalRGBA); return finalRGBA; } ENDCG } Pass { Name "ShadowCaster" Tags { "LightMode"="ShadowCaster" } Offset 1, 1 CGPROGRAM #pragma vertex vert #pragma fragment frag #define UNITY_PASS_SHADOWCASTER #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" #include "UnityStandardBRDF.cginc" #pragma fragmentoption ARB_precision_hint_fastest #pragma multi_compile_shadowcaster #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON #pragma multi_compile_fog #pragma exclude_renderers xbox360 ps3 #pragma target 3.0 uniform float _Ring_Amount; uniform float _WaveHeight; uniform float _Speed; struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; float2 texcoord2 : TEXCOORD2; }; struct VertexOutput { V2F_SHADOW_CASTER; float2 uv0 : TEXCOORD1; float2 uv1 : TEXCOORD2; float2 uv2 : TEXCOORD3; float4 posWorld : TEXCOORD4; float3 normalDir : TEXCOORD5; }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.uv0 = v.texcoord0; o.uv1 = v.texcoord1; o.uv2 = v.texcoord2; o.normalDir = UnityObjectToWorldNormal(v.normal); float node_9544 = distance(o.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); v.vertex.xyz += ((node_5748*_WaveHeight)*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); o.pos = UnityObjectToClipPos(v.vertex ); TRANSFER_SHADOW_CASTER(o) return o; } float4 frag(VertexOutput i) : COLOR { i.normalDir = normalize(i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 normalDirection = i.normalDir; SHADOW_CASTER_FRAGMENT(i) } ENDCG } Pass { Name "Meta" Tags { "LightMode"="Meta" } Cull Off CGPROGRAM #pragma vertex vert #pragma fragment frag #define UNITY_PASS_META 1 #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" #include "UnityPBSLighting.cginc" #include "UnityStandardBRDF.cginc" #include "UnityMetaPass.cginc" #pragma fragmentoption ARB_precision_hint_fastest #pragma multi_compile_shadowcaster #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON #pragma multi_compile_fog #pragma exclude_renderers xbox360 ps3 #pragma target 3.0 uniform float _Ring_Amount; uniform float4 _FoamColor; uniform float _WaveHeight; uniform float _Speed; struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; float2 texcoord2 : TEXCOORD2; }; struct VertexOutput { float4 pos : SV_POSITION; float2 uv0 : TEXCOORD0; float2 uv1 : TEXCOORD1; float2 uv2 : TEXCOORD2; float4 posWorld : TEXCOORD3; float3 normalDir : TEXCOORD4; }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.uv0 = v.texcoord0; o.uv1 = v.texcoord1; o.uv2 = v.texcoord2; o.normalDir = UnityObjectToWorldNormal(v.normal); float node_9544 = distance(o.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); v.vertex.xyz += ((node_5748*_WaveHeight)*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST ); return o; } float4 frag(VertexOutput i) : SV_Target { i.normalDir = normalize(i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 normalDirection = i.normalDir; UnityMetaInput o; UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o ); o.Emission = 0; float node_9544 = distance(i.uv0,float2(0.5,0.5)); float node_5748 = sin(((node_9544+(_Speed*0.5+0.0))*_Ring_Amount)); float node_1198 = saturate(node_5748); float3 diffColor = (_FoamColor.rgb*node_1198); o.Albedo = diffColor; return UnityMetaFragment( o ); } ENDCG } } FallBack "Diffuse" CustomEditor "ShaderForgeMaterialInspector" }