Improve close-up ship cameras and marine rendering
This commit is contained in:
@@ -17,7 +17,7 @@ Shader "Soundings/Passage Wake"
|
||||
#include "OceanWaves.cginc"
|
||||
|
||||
sampler2D _OceanDetail;
|
||||
float _SeaTime, _WeatherSeverity;
|
||||
float _SeaTime, _WeatherSeverity, _TrailLength;
|
||||
struct Input { float4 vertex : POSITION; float4 trace : TEXCOORD0; };
|
||||
struct Output { float4 clip : SV_POSITION; float4 trace : TEXCOORD0; float2 water : TEXCOORD1; };
|
||||
|
||||
@@ -34,23 +34,30 @@ Shader "Soundings/Passage Wake"
|
||||
|
||||
fixed4 frag(Output input) : SV_Target
|
||||
{
|
||||
float across = abs(input.trace.x);
|
||||
float across = input.trace.x;
|
||||
float age = input.trace.y;
|
||||
float thrust = input.trace.z;
|
||||
float distance = input.trace.w;
|
||||
float2 water = input.water;
|
||||
float eddies = tex2D(_OceanDetail, water * .118 + float2(-.016,.016) * _SeaTime).b;
|
||||
float flecks = tex2D(_OceanDetail, water * .285 + float2(.008,-.011) * _SeaTime).b;
|
||||
float disturbed = 1 - smoothstep(.28,.47, across + .065 * (eddies - .5));
|
||||
float stripes = sin(across * 22 + eddies * 5 + distance * .055);
|
||||
float churn = smoothstep(.36,.78, eddies * .57 + flecks * .43 + stripes * .14);
|
||||
float kelvin = 1 - smoothstep(.044,.155, abs(across - .76 + .08 * (eddies - .5)));
|
||||
float ripples = .41 + .59 * sin(distance * .47 + across * 16 - _SeaTime * 2.8);
|
||||
float whitewater = disturbed * (.54 + .45 * churn) + kelvin * saturate(ripples) * (.33 + .42 * eddies);
|
||||
float lifetime = (1 - smoothstep(4, 34, age));
|
||||
float alpha = whitewater * thrust * lifetime * (.89 - _WeatherSeverity * .13);
|
||||
float3 foam = lerp(float3(.47,.68,.71), float3(.87,.94,.93), churn * .84 + .15);
|
||||
return fixed4(foam, saturate(alpha));
|
||||
float2 cross = float2(dot(water, float2(.85,-.53)), dot(water, float2(.53,.85)));
|
||||
float eddies = tex2D(_OceanDetail, water * .055 + float2(-.016,.016) * _SeaTime).b;
|
||||
float bubbles = tex2D(_OceanDetail, cross * .168 + float2(.026,-.011) * _SeaTime).b;
|
||||
float flecks = tex2D(_OceanDetail, water * .35 + float2(.008,.028) * _SeaTime).b;
|
||||
float billow = (eddies - .5) * .18 + (bubbles - .5) * .074;
|
||||
float churn = smoothstep(.31,.73, eddies * .50 + bubbles * .34 + flecks * .16);
|
||||
float sternMix = smoothstep(2, 26, distance);
|
||||
float propellers = 1 - smoothstep(.03,.24, abs(abs(across + billow) - .23));
|
||||
float turbulence = 1 - smoothstep(.19,.56, abs(across + billow));
|
||||
float core = lerp(propellers, turbulence, sternMix);
|
||||
float shoulder = abs(across + billow * .45);
|
||||
float kelvin = 1 - smoothstep(.035,.165, abs(shoulder - .76));
|
||||
float crests = smoothstep(.18, .91, .5 + .5 * sin(distance * .36 + shoulder * 12.6 - _SeaTime * 1.56 + eddies * 4.3));
|
||||
float wake = turbulence * .14 + core * (.17 + .69 * churn) + kelvin * crests * (.16 + .35 * eddies);
|
||||
float endFade = smoothstep(0, min(_TrailLength * .38, 32), _TrailLength - distance);
|
||||
float lifetime = (1 - smoothstep(2, 34, age)) * endFade;
|
||||
float alpha = wake * thrust * lifetime * (.90 - _WeatherSeverity * .20);
|
||||
float3 foam = lerp(float3(.29,.50,.55), float3(.90,.96,.95), churn * .83 + .08);
|
||||
return fixed4(foam, alpha);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user