Shader "BigShipTycoon/Harbor Reflection" { Properties { _Color ("Paint", Color) = (1,1,1,1) } SubShader { Tags { "Queue"="Background+3" "RenderType"="Transparent" } Pass { Cull Off ZWrite Off Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma target 3.0 #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" #include "OceanWaves.cginc" fixed4 _Color; float _TycoonSeaSailing, _TycoonSeaWeather, _TycoonSeaTime; struct Output { float4 clip : SV_POSITION; float3 world : TEXCOORD0; }; Output vert(appdata_base input) { Output output; float4 worldPosition = mul(unity_ObjectToWorld, input.vertex); float time = lerp(_Time.y, _TycoonSeaTime, _TycoonSeaSailing); float3 wave = OceanWave(worldPosition.xz, time, _TycoonSeaWeather) * _TycoonSeaSailing; worldPosition.y = -worldPosition.y * .59; float spread = smoothstep(0, 5, -worldPosition.y); worldPosition.y += wave.x * .80; worldPosition.z += (sin(worldPosition.x * .53 + worldPosition.y * 2.14 + time * 1.55) * .27 + wave.z * 3.5) * spread; worldPosition.x += (sin(worldPosition.y * .88 - time) * .29 + wave.y * 3.5) * spread; output.clip = UnityWorldToClipPos(worldPosition.xyz); output.world = worldPosition.xyz; return output; } fixed4 frag(Output input) : SV_Target { clip(-input.world.y); float time = lerp(_Time.y, _TycoonSeaTime, _TycoonSeaSailing); float3 view = lerp(normalize(_WorldSpaceCameraPos - input.world), UNITY_MATRIX_V[2].xyz, unity_OrthoParams.w); float depth = -input.world.y; float2 surface = input.world.xz + view.xz * depth / max(.10, view.y); float primary = sin(dot(surface, float2(.58, 2.83)) + depth * 1.40 - time * 2.22); float crossing = sin(dot(surface, float2(-1.19, 1.62)) + depth * 2.71 + time * 1.43); float breakup = .58 + .26 * primary + .16 * crossing; float closeReflection = lerp(.43, breakup, smoothstep(0, 1.5, depth)); float grazing = 1 - saturate(view.y); float strength = lerp(.36, .25 - .10 * _TycoonSeaWeather, _TycoonSeaSailing); float fade = exp(-depth * lerp(.24, .43, _TycoonSeaSailing)) * (1 - smoothstep(6, 10, depth)); float alpha = fade * closeReflection * strength * (.66 + .34 * grazing); return fixed4(_Color.rgb * float3(.55,.65,.68), alpha); } ENDCG } } }