Animate passenger venues and add port-specific cinematics
This commit is contained in:
@@ -7,6 +7,13 @@ Shader "Soundings/Harbor Water"
|
||||
_BackdropCrop ("Harbor crop", Vector) = (1,1,0,0)
|
||||
_HullSpan ("Hull length and beam", Vector) = (71,7,0,0)
|
||||
_HullCourse ("Hull heading and wake strength", Vector) = (1,0,0,0)
|
||||
_PortBerth ("Cinematic berth position and dimensions", Vector) = (0,0,0,0)
|
||||
_PortMotion ("Port maneuver", Float) = 0
|
||||
_PortSky ("Port sunset color", Color) = (.86,.62,.43,1)
|
||||
_PortShallows ("Shallow harbor water", Range(0,1)) = .25
|
||||
_PortMatte ("Port waterfront matte", 2D) = "black" {}
|
||||
_PortMatteCrop ("Port waterfront crop", Vector) = (1,1,0,0)
|
||||
_PortMatteActive ("Port waterfront matte is available", Float) = 0
|
||||
_Underway ("Open water", Float) = 0
|
||||
_WeatherSeverity ("Sea conditions", Range(0,1)) = 0
|
||||
}
|
||||
@@ -24,10 +31,11 @@ Shader "Soundings/Harbor Water"
|
||||
#include "UnityCG.cginc"
|
||||
#include "OceanWaves.cginc"
|
||||
|
||||
sampler2D _Backdrop, _OceanDetail;
|
||||
float4 _BackdropCrop, _HullSpan, _HullCourse, _ViewSize;
|
||||
sampler2D _Backdrop, _OceanDetail, _PortMatte;
|
||||
float4 _BackdropCrop, _HullSpan, _HullCourse, _PortBerth, _ViewSize;
|
||||
float4 _PortSky, _PortMatteCrop;
|
||||
float3 _ViewOrigin, _ViewForward, _ViewRight, _ViewUp;
|
||||
float _Underway, _WeatherSeverity, _SeaTime;
|
||||
float _Underway, _WeatherSeverity, _SeaTime, _PortMotion, _PortShallows, _PortMatteActive;
|
||||
static const float3 Sun = float3(-.761,.441,-.474);
|
||||
struct Output { float4 clip : SV_POSITION; float2 screen : TEXCOORD0; };
|
||||
|
||||
@@ -47,6 +55,11 @@ Shader "Soundings/Harbor Water"
|
||||
float elevation = sqrt(saturate(ray.y));
|
||||
float3 sky = lerp(horizon, float3(.081,.242,.408), elevation);
|
||||
float3 squall = lerp(float3(.41,.50,.56), float3(.112,.174,.230), elevation);
|
||||
if (_PortMotion > .5)
|
||||
{
|
||||
float3 shoreGlow = lerp(float3(.62,.70,.76), _PortSky.rgb, .28 + warmth * .64);
|
||||
sky = lerp(shoreGlow, float3(.16,.30,.48), elevation);
|
||||
}
|
||||
return lerp(sky, squall, _WeatherSeverity);
|
||||
}
|
||||
|
||||
@@ -149,6 +162,11 @@ Shader "Soundings/Harbor Water"
|
||||
float cap = saturate(dot(normal, Sun) * .84 + (chop.b - .5) * textureDetail * .63 + .35);
|
||||
float3 fromBelow = lerp(float3(.028,.125,.192), float3(.078,.250,.294), cap);
|
||||
fromBelow = lerp(fromBelow, fromBelow * .57 + float3(.022,.032,.036), _WeatherSeverity);
|
||||
if (_PortMotion > .5)
|
||||
{
|
||||
float3 shallowWater = lerp(float3(.03,.31,.32), float3(.15,.52,.48), cap);
|
||||
fromBelow = lerp(fromBelow, shallowWater, _PortShallows);
|
||||
}
|
||||
float3 color = lerp(fromBelow, SkyGradient(reflected) * .83, reflection);
|
||||
float sunHit = saturate(dot(reflected, Sun));
|
||||
float nearSun = pow(sunHit, lerp(162, 60, _WeatherSeverity));
|
||||
@@ -172,6 +190,11 @@ Shader "Soundings/Harbor Water"
|
||||
color = lerp(color, float3(.88,.94,.94), foam.y);
|
||||
}
|
||||
}
|
||||
if (_PortMotion > .5)
|
||||
{
|
||||
float2 quayEdge = max(0, abs(position - _PortBerth.xy) - _PortBerth.zw);
|
||||
color *= 1 - (1 - smoothstep(.14, 3.4, length(quayEdge))) * .29;
|
||||
}
|
||||
|
||||
float mist = 1 - exp(-distance * (.00040 + .00077 * _WeatherSeverity));
|
||||
color = lerp(color, SkyGradient(float3(ray.x, 0, ray.z)) * .90, mist * .80);
|
||||
@@ -186,6 +209,23 @@ Shader "Soundings/Harbor Water"
|
||||
return color;
|
||||
}
|
||||
|
||||
float3 PortMatteWater(float3 origin, float3 ray, float2 screen)
|
||||
{
|
||||
float2 uv = (screen - .5) * _PortMatteCrop.xy + .5 + _PortMatteCrop.zw;
|
||||
float water = 1 - smoothstep(.28,.55,uv.y);
|
||||
float viewDistance = clamp(origin.y / max(.00042, -ray.y), 0, 1200);
|
||||
float2 world = origin.xz + ray.xz * viewDistance;
|
||||
float ripple = sin(dot(world, float2(.54,1.16)) - _SeaTime * 1.72);
|
||||
uv.x += ripple * (.00058 * water);
|
||||
float3 matte = tex2D(_PortMatte, uv).rgb;
|
||||
if (water < .009 || ray.y > 0)
|
||||
return matte;
|
||||
|
||||
float3 sea = OpenSea(origin, ray, screen);
|
||||
// Preserve the distant quay's photographic reflection while the ship and its wake move over live water.
|
||||
return lerp(matte, sea, water * .74);
|
||||
}
|
||||
|
||||
fixed4 frag(Output input) : SV_Target
|
||||
{
|
||||
float2 screen = input.screen;
|
||||
@@ -193,7 +233,9 @@ Shader "Soundings/Harbor Water"
|
||||
float3 viewOffset = offsetOnFilm.x * _ViewRight + offsetOnFilm.y * _ViewUp;
|
||||
float3 origin = _ViewOrigin + viewOffset * _ViewSize.z;
|
||||
float3 ray = normalize(_ViewForward + viewOffset * (1 - _ViewSize.z));
|
||||
if (_Underway > .5)
|
||||
if (_PortMotion > .5 && _PortMatteActive > .5)
|
||||
return fixed4(PortMatteWater(origin, ray, screen), 1);
|
||||
if (_Underway > .5 || _PortMotion > .5)
|
||||
{
|
||||
if (ray.y >= .0010)
|
||||
return fixed4(Sky(ray, _SeaTime), 1);
|
||||
|
||||
Reference in New Issue
Block a user