Add MEGA Ocean Liner, split decks, and detailed ship materials

This commit is contained in:
josh
2026-11-28 21:02:42 -05:00
parent ce0d38c8de
commit 46624bf5ba
47 changed files with 2042 additions and 382 deletions

View File

@@ -23,6 +23,7 @@ Shader "BigShipTycoon/Harbor Surface"
#pragma fragment frag
#include "UnityCG.cginc"
#include "OceanWaves.cginc"
#include "TycoonTexturing.cginc"
fixed4 _Color;
float _Roughness, _Metal, _Emissive, _Weather, _Finish, _Waterline;
@@ -51,89 +52,82 @@ Shader "BigShipTycoon/Harbor Surface"
return output;
}
float PanelShade(float2 cell)
float SurfaceTone(float3 local, float3 localNormal)
{
float3 p = frac(cell.xyx * .1031);
p += dot(p, p.yzx + 33.33);
return frac((p.x + p.y) * p.z);
}
float2 uv = TycoonPlane(local, localNormal);
float upward = abs(localNormal.y);
float weather = sin(uv.x * .91 + uv.y * 1.79) * sin(uv.y * 4.23 - uv.x * .47);
float tone = 1 + weather * _Weather * .057;
// Fade details whose period falls beneath a pixel, especially around the railings.
float Detail(float phase)
{
return 1 - smoothstep(.25, .86, fwidth(phase));
}
float Groove(float phase, float width)
{
float edge = abs(frac(phase + .5) - .5);
float feather = max(.002, fwidth(phase) * .56);
return (1 - smoothstep(width, width + feather, edge)) * Detail(phase);
}
float SurfaceTone(float3 p, float3 normal)
{
float paint = sin(p.x * .82 + p.z * 1.7) * sin(p.y * 3.5 + p.z * 4.8);
float tone = 1 + paint * _Weather * .16;
if (_Finish == 1)
{
float horizontal = step(.6, abs(normal.y));
float crossGrain = lerp(p.y, p.z, horizontal);
float across = crossGrain / .215;
float row = floor(across);
float along = p.x * .383 + row * .381966;
float plank = PanelShade(float2(floor(along), row)) - .5;
float fibre = crossGrain * 53 + .73 * sin(p.x * 2.8 + crossGrain * 32);
float grain = sin(fibre) * Detail(crossGrain * 8.4);
float seams = Groove(across, .014) + Groove(p.x * .383 + frac(row * .381966), .0026);
float wear = sin(p.x * 2.2 + crossGrain * 2.9) * cos(crossGrain * 8.2 - p.x * 1.9);
tone = 1 + plank * .19 * Detail(across) + grain * .055 - seams * lerp(.12, .27, horizontal)
+ wear * .036 * _Weather;
float board;
float caulk = TycoonPanel(uv, float2(.406, 6.1), .376, .0025, board);
float fibre = TycoonGrain(uv, 11);
float lowGrain = sin(uv.y * 26 + sin(uv.x * 1.16) * 2.6) * TycoonDetail(uv.y * 4.15);
tone += board * .26 + fibre * .049 + lowGrain * .055
- caulk * lerp(.17, .35, upward) + TycoonStipple(uv, 83) * .045;
}
else if (_Finish == 3)
{
float crossFibre = abs(normal.y) > .55 ? p.z : p.y;
float weave = cos(p.x * 142) * cos(crossFibre * 153) * Detail(crossFibre * 24.4) * Detail(p.x * 22.6);
float mottling = sin(p.x * 11 + crossFibre * 16) * sin(p.x * 23 - crossFibre * 13);
tone = 1 + .037 * weave + .028 * mottling * Detail(p.x * 3.7);
float weave = TycoonWeave(uv, float2(23, 29));
float nap = TycoonStipple(uv + float2(uv.y * .24, 0), 87) * .080;
tone += weave * .061 + nap;
if (_FabricMotif > .01)
{
float2 diamonds = float2(p.x + crossFibre, p.x - crossFibre) * 1.83;
float braid = Groove(diamonds.x, .065) * .046 + Groove(diamonds.y, .065) * .046;
float inset = Groove(diamonds.x + .5, .08) * Groove(diamonds.y + .5, .08) * .19;
tone += (braid + inset - .026) * _FabricMotif;
float2 diamonds = float2(uv.x + uv.y, uv.x - uv.y) * 1.83;
float border = TycoonJoint(diamonds.x, .056) + TycoonJoint(diamonds.y, .056);
float rosette = TycoonJoint(diamonds.x + .5, .13) * TycoonJoint(diamonds.y + .5, .13);
tone += (border * .084 + rosette * (.125 + .075 * weave) - .028) * _FabricMotif;
}
}
else if (_Finish == 4)
{
float brush = abs(normal.y) > .55 ? p.z : p.y;
float scratches = sin(brush * 82 + sin(p.x * 1.25)) * Detail(brush * 13);
tone = 1 + scratches * .04 + paint * .025;
float mill = uv.y * 79 + sin(uv.x * 1.25) * .20;
float satin = cos(mill * 6.283185) * TycoonDetail(uv.y * 79);
float polishing = TycoonGrain(uv, 13.2) * .034;
tone += satin * .058 + polishing + weather * .019;
}
else if (_Finish == 5)
else if (_Finish == 5 || _Finish == 9)
{
float along = p.x + p.z * .42;
float plateRow = floor(p.y * .86);
float plateAlong = along * .23 + plateRow * .5;
float irregular = PanelShade(float2(floor(plateAlong), plateRow)) - .5;
float runoff = sin(along * 9.1 + sin(along * 2.1)) * sin(along * 2.9 - .2 * p.y);
float plates = Groove(p.y * .86, .008) + Groove(plateAlong, .005);
float salt = 1 - smoothstep(-.04, .82, p.y);
tone = 1 + salt * .15
+ (irregular * .25 + paint * .1 + runoff * .21 * Detail(along * 1.45) - plates * .21) * _Weather;
float plate;
float strength = _Finish == 5 ? 1 : .45;
float above = 1 - smoothstep(.18, 1.74, local.y);
float joints = TycoonPanel(uv, float2(.193, .844), .5, .008, plate);
float runoff = sin(uv.x * 9.1 + sin(uv.x * 2.1)) * sin(uv.x * 2.9 - .2 * uv.y);
tone += (plate * .092 - joints * .21) * strength * (1 - upward * .80)
+ (.14 * above + runoff * .093 * TycoonDetail(uv.x * 1.45)) * _Weather
+ TycoonStipple(uv, 67) * .035;
}
else if (_Finish == 7)
{
float vein = max(TycoonVein(uv), TycoonVein(uv * .46 + float2(.45,.17)) * .78);
float stone;
float joints = TycoonPanel(uv, float2(1.31, 1.31), .5, .0035, stone);
tone += stone * .060 - vein * .096 - joints * .17 + TycoonStipple(uv, 94) * .033;
}
else if (_Finish == 8 || _Finish == 10)
{
float grass = _Finish == 8 ? 1 : 0;
float mowing = sin(uv.y * 3.7 + .25 * sin(uv.x * .63)) * TycoonDetail(uv.y * .59);
float aggregate = TycoonStipple(uv, 53) * .28 + TycoonStipple(uv, 130) * .13;
tone += aggregate + grass * (.075 * mowing + .058 * weather);
}
else if (_Finish != 2 && _Finish != 11)
{
// Orange-peel paint remains nearly solid on rails and thin moldings.
tone += TycoonStipple(uv, 118) * (.038 + _Weather * .025);
}
if (_TileFrequency > 0)
{
float3 axis = abs(normal);
float2 face = axis.y > .57 ? p.xz : axis.x > axis.z ? p.zy : p.xy;
float2 grout = face * _TileFrequency;
float tileVariation = (PanelShade(floor(grout)) - .5) * Detail(grout.x) * Detail(grout.y);
tone *= 1 + tileVariation * .18 - max(Groove(grout.x, .036), Groove(grout.y, .036)) * .31;
float ceramic;
float grout = TycoonPanel(uv, float2(_TileFrequency, _TileFrequency), 0, min(.009, .044 / _TileFrequency), ceramic);
tone *= 1 + ceramic * .23 - grout * .37;
}
return tone;
}
float3 PoolColor(float3 world, float4 basin, float3 normal, float3 eye, float3 sky, float glint, float fresnel)
float3 PoolColor(float4 basin, float3 normal, float3 eye, float3 sky, float glint, float fresnel)
{
// Unmapped water is used for small fountains. Pool caps carry distance to their own basin edges.
if (basin.z < .01)
@@ -141,14 +135,17 @@ Shader "BigShipTycoon/Harbor Surface"
float edge = min(basin.z - abs(basin.x), basin.w - abs(basin.y));
float shallow = 1 - smoothstep(.015, .86, edge);
float bottomShade = lerp(.73, 1, smoothstep(-.01, .14, edge));
float2 p = world.xz;
float2 p = basin.xy;
float time = _Time.y;
float2 wave = float2(p.x * 2.29 + p.y * 1.88, p.y * 2.63 - p.x * 1.03);
wave.x += .17 * sin(p.y * 6.3 - time * 1.7) + time * .22;
wave.y += .13 * sin(p.x * 5.04 + time * 1.52) - time * .31;
float distance = min(abs(frac(wave.x) - .5), abs(frac(wave.y) - .5));
float feather = max(max(fwidth(wave.x), fwidth(wave.y)) * .69, .029);
float caustic = (1 - smoothstep(.021, .027 + feather, distance)) * Detail(wave.x) * Detail(wave.y);
float caustic = (1 - smoothstep(.021, .027 + feather, distance)) * TycoonDetail(wave.x) * TycoonDetail(wave.y);
float tile;
float grout = TycoonPanel(p, float2(12.5, 12.5), 0, .0035, tile);
bottomShade *= 1 + tile * .05 - .11 * grout;
float3 body = _Color.rgb * lerp(float3(.52,.68,.83), float3(1.14,1.39,1.37), shallow);
float3 teal = body * bottomShade + caustic * float3(.07,.15,.13) * lerp(.45, 1, shallow);
float waterFresnel = .06 + pow(1 - saturate(dot(eye, normal)), 5) * .54;
@@ -160,11 +157,11 @@ Shader "BigShipTycoon/Harbor Surface"
float3 normal = normalize(input.normal);
if (_Finish == 6)
{
float2 p = input.world.xz;
float2 p = input.local.xz;
float rippleX = p.x * 5.7 + p.y * 2.2 - _Time.y * 2.7;
float rippleZ = p.y * 8.3 - p.x * 1.3 + _Time.y * 3.1;
float3 ripple = float3(sin(rippleX) * Detail(p.x * .91), 0, sin(rippleZ) * Detail(p.y * 1.32));
normal = normalize(normal + ripple * .095);
float3 ripple = float3(sin(rippleX) * TycoonDetail(p.x * .91), 0, sin(rippleZ) * TycoonDetail(p.y * 1.32));
normal = normalize(normal + mul((float3x3)unity_ObjectToWorld, ripple) * .095);
}
float3 eye = unity_OrthoParams.w > .5 ? UNITY_MATRIX_V[2].xyz
: normalize(_WorldSpaceCameraPos.xyz - input.world);
@@ -180,7 +177,7 @@ Shader "BigShipTycoon/Harbor Surface"
float3 skyReflection = lerp(float3(.11,.19,.27), float3(.39,.48,.60), saturate(reflected.y))
+ sunsetStripe * float3(.20,.12,.061);
if (_Finish == 6)
return fixed4(saturate(PoolColor(input.world, input.basin, normal, eye, skyReflection, specular, fresnel)), 1);
return fixed4(saturate(PoolColor(input.basin, normal, eye, skyReflection, specular, fresnel)), 1);
float overcast = _TycoonSeaWeather * _TycoonSeaSailing;
float3 direct = lerp(float3(.58,.46,.34), float3(.20,.24,.28), overcast);
float3 light = lerp(float3(.26,.34,.43), float3(.62,.69,.75), sky) + sunlight * direct;
@@ -195,7 +192,7 @@ Shader "BigShipTycoon/Harbor Surface"
diffuse *= lerp(.60, 1, smoothstep(0, .64, aboveWater));
diffuse += skyReflection * (.12 * (1 - smoothstep(.04,.67,aboveWater)) * (.26 + fresnel * .62));
}
if (_Finish == 2)
if (_Finish == 2 || _Finish == 11)
{
float horizon = 1 - smoothstep(.005, .067 + _Roughness * .12, abs(reflected.y - .025));
float roofReflection = smoothstep(.21, .28, reflected.y) * (1 - smoothstep(.31, .44, reflected.y));
@@ -203,11 +200,19 @@ Shader "BigShipTycoon/Harbor Surface"
+ float3(.18,.23,.25) * roofReflection * .12;
float facing = smoothstep(-.12, .49, reflected.y);
float3 glass = diffuse * (.47 + facing * .30) + glazing + specular * float3(.65,.55,.41) * .33;
return fixed4(saturate(lerp(glass, diffuse + glazing * .32 + _Color.rgb * .22, _Emissive)), 1);
if (_Finish == 11)
{
float2 uv = TycoonPlane(input.local, normalize(input.localNormal));
float2 centers = uv * 8.5 + float2(frac(floor(uv.y * 8.5) * .5), 0);
float2 cell = frac(centers) - .5;
float coverage = (1 - smoothstep(.022, .069, dot(cell, cell))) * TycoonDetail2(uv * 8.5);
glass = lerp(glass, float3(.54,.68,.71) + glazing * .32, coverage * .58);
}
return fixed4(TycoonHighlightRollOff(lerp(glass, diffuse + glazing * .32 + _Color.rgb * .22, _Emissive)), 1);
}
float3 shine = skyReflection * (.045 + fresnel * .21 + _Metal * .16) * (1 - _Roughness * .56)
+ specular * float3(.73,.60,.43) * (.10 + .47 * _Metal) * saturate(3 * sunlight);
return fixed4(saturate(diffuse + shine + _Color.rgb * _Emissive * .53), 1);
return fixed4(TycoonHighlightRollOff(diffuse + shine + _Color.rgb * _Emissive * .53), 1);
}
ENDCG
}