Files
cruiseSimulator/Assets/Soundings/Resources/HarborReflection.shader

53 lines
2.1 KiB
Plaintext

Shader "Soundings/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 _SoundingsSeaSailing, _SoundingsSeaWeather, _SoundingsSeaTime;
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, _SoundingsSeaTime, _SoundingsSeaSailing);
float3 wave = OceanWave(worldPosition.xz, time, _SoundingsSeaWeather) * _SoundingsSeaSailing;
worldPosition.y = -worldPosition.y * .59;
worldPosition.y += wave.x * 1.5;
worldPosition.z += sin(worldPosition.x * .53 + worldPosition.y * 2.14 + time * 1.55) * .27 + wave.z * 4;
worldPosition.x += sin(worldPosition.y * .88 - time) * .29 + wave.y * 4;
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, _SoundingsSeaTime, _SoundingsSeaSailing);
float breakup = .48 + .38 * sin(input.world.y * 14 + input.world.x * .62 - time * 1.02);
float alpha = saturate(1 + input.world.y / 7.5) * breakup * lerp(.34, .24 - .11 * _SoundingsSeaWeather, _SoundingsSeaSailing);
return fixed4(_Color.rgb * float3(.51,.60,.64), alpha);
}
ENDCG
}
}
}