From 384f140b92e97a718072a73256515d6c862bdce1 Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 28 Nov 2026 00:16:51 -0500 Subject: [PATCH] Improve close-up ship cameras and marine rendering --- Assets/Soundings/Editor/SoundingsBuild.cs | 2 +- .../Resources/HarborReflection.shader | 22 +- .../Soundings/Resources/HarborSurface.shader | 129 +++++- Assets/Soundings/Resources/HarborWater.shader | 161 ++++--- Assets/Soundings/Resources/PassageWake.shader | 35 +- Assets/Soundings/Runtime/DeckPassengers.cs | 22 +- Assets/Soundings/Runtime/Harbor.cs | 207 +++++++-- Assets/Soundings/Runtime/HarborMesh.cs | 49 ++- Assets/Soundings/Runtime/PassageInterface.cs | 2 +- Assets/Soundings/Runtime/PassageWake.cs | 1 + Assets/Soundings/Runtime/SoundingsApp.cs | 17 +- Assets/Soundings/Runtime/VesselExterior.cs | 409 ++++++++++++++---- Assets/Soundings/Runtime/VisualSmoke.cs | 43 ++ ProjectSettings/ProjectSettings.asset | 2 +- README.md | 4 +- 15 files changed, 875 insertions(+), 230 deletions(-) diff --git a/Assets/Soundings/Editor/SoundingsBuild.cs b/Assets/Soundings/Editor/SoundingsBuild.cs index ecd3a10..a8aead1 100644 --- a/Assets/Soundings/Editor/SoundingsBuild.cs +++ b/Assets/Soundings/Editor/SoundingsBuild.cs @@ -24,7 +24,7 @@ namespace Soundings.Editor EditorBuildSettings.scenes = new[] { new EditorBuildSettingsScene(ScenePath, true) }; PlayerSettings.companyName = "Soundings"; PlayerSettings.productName = "Soundings"; - PlayerSettings.bundleVersion = "0.6.0"; + PlayerSettings.bundleVersion = "0.6.1"; PlayerSettings.defaultScreenWidth = 1920; PlayerSettings.defaultScreenHeight = 1080; PlayerSettings.fullScreenMode = FullScreenMode.FullScreenWindow; diff --git a/Assets/Soundings/Resources/HarborReflection.shader b/Assets/Soundings/Resources/HarborReflection.shader index 5a9f1bb..380c071 100644 --- a/Assets/Soundings/Resources/HarborReflection.shader +++ b/Assets/Soundings/Resources/HarborReflection.shader @@ -30,9 +30,10 @@ Shader "Soundings/Harbor Reflection" 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; + 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; @@ -42,9 +43,18 @@ Shader "Soundings/Harbor Reflection" { 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); + 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 * _SoundingsSeaWeather, _SoundingsSeaSailing); + float fade = exp(-depth * lerp(.24, .43, _SoundingsSeaSailing)) * (1 - smoothstep(6, 10, depth)); + float alpha = fade * closeReflection * strength * (.66 + .34 * grazing); + return fixed4(_Color.rgb * float3(.55,.65,.68), alpha); } ENDCG } diff --git a/Assets/Soundings/Resources/HarborSurface.shader b/Assets/Soundings/Resources/HarborSurface.shader index bd5cd4c..3dbf090 100644 --- a/Assets/Soundings/Resources/HarborSurface.shader +++ b/Assets/Soundings/Resources/HarborSurface.shader @@ -7,6 +7,8 @@ Shader "Soundings/Harbor Surface" _Metal ("Metal", Range(0,1)) = 0 _Emissive ("Emission", Range(0,1)) = 0 _Weather ("Weathering", Range(0,1)) = .1 + _Finish ("Surface finish", Float) = 0 + _Waterline ("Opaque hull at the waterline", Float) = 0 } SubShader { @@ -14,14 +16,24 @@ Shader "Soundings/Harbor Surface" Pass { CGPROGRAM + #pragma target 3.0 #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" + #include "OceanWaves.cginc" fixed4 _Color; - float _Roughness, _Metal, _Emissive, _Weather; + float _Roughness, _Metal, _Emissive, _Weather, _Finish, _Waterline; + float _SoundingsSeaWeather, _SoundingsSeaSailing, _SoundingsSeaTime; struct Input { float4 vertex : POSITION; float3 normal : NORMAL; }; - struct Output { float4 clip : SV_POSITION; float3 normal : TEXCOORD0; float3 world : TEXCOORD1; }; + struct Output + { + float4 clip : SV_POSITION; + float3 normal : TEXCOORD0; + float3 world : TEXCOORD1; + float3 local : TEXCOORD2; + float3 localNormal : TEXCOORD3; + }; Output vert(Input input) { @@ -29,33 +41,122 @@ Shader "Soundings/Harbor Surface" output.clip = UnityObjectToClipPos(input.vertex); output.normal = UnityObjectToWorldNormal(input.normal); output.world = mul(unity_ObjectToWorld, input.vertex).xyz; + output.local = input.vertex.xyz; + output.localNormal = input.normal; return output; } + float PanelShade(float2 cell) + { + float3 p = frac(cell.xyx * .1031); + p += dot(p, p.yzx + 33.33); + return frac((p.x + p.y) * p.z); + } + + // 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); + tone = 1 + plank * .16 * Detail(across) + grain * .052 - seams * lerp(.12, .27, horizontal); + } + 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); + } + 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; + } + else if (_Finish == 5) + { + float along = p.x + p.z * .42; + float runoff = sin(along * 9.1 + sin(along * 2.1)) * sin(along * 2.9 - .2 * p.y); + float plates = Groove(p.y * .86, .005) + Groove(along * .23 + floor(p.y * .86) * .5, .0038); + float salt = 1 - smoothstep(-.04, .82, p.y); + tone = 1 + salt * .11 + (paint * .1 + runoff * .18 * Detail(along * 1.45) - plates * .16) * _Weather; + } + return tone; + } + fixed4 frag(Output input) : SV_Target { - float3 p = input.world; float3 normal = normalize(input.normal); - float3 eye = normalize(_WorldSpaceCameraPos.xyz - p); + if (_Finish == 6) + { + 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 + mul((float3x3)unity_ObjectToWorld, ripple) * .085); + } + float3 eye = unity_OrthoParams.w > .5 ? UNITY_MATRIX_V[2].xyz + : normalize(_WorldSpaceCameraPos.xyz - input.world); float3 sun = normalize(float3(-.69,.40,-.43)); float3 halfVector = normalize(sun + eye); float sunlight = saturate(dot(normal,sun)); float sky = saturate(normal.y * .5 + .5); float fresnel = pow(1 - saturate(dot(eye,normal)), 3.5); - float roughExponent = lerp(220, 9, _Roughness); - float specular = pow(saturate(dot(normal,halfVector)), roughExponent) * (1 - _Roughness * .65); + float roughExponent = lerp(280, 6, _Roughness * _Roughness); + float specular = pow(saturate(dot(normal,halfVector)), roughExponent) * (1 - _Roughness * .68); float3 reflected = reflect(-eye,normal); float sunsetStripe = smoothstep(-.08,.13,reflected.y) * (1 - smoothstep(.13,.42,reflected.y)); float3 skyReflection = lerp(float3(.11,.19,.27), float3(.39,.48,.60), saturate(reflected.y)) + sunsetStripe * float3(.20,.12,.061); - float3 light = lerp(float3(.25,.34,.46),float3(.61,.68,.77),sky) + sunlight * float3(.62,.44,.30); - float micro = sin(p.x * 13.7 + p.y * 19.3) * sin(p.z * 15.4 - p.x * 8); - float abrasion = sin(p.x * .82 + p.z * 1.7) * sin(p.y * 3.5 + p.z * 4.8); - float surfaceGrain = 1 + _Weather * (.055 * micro + .10 * abrasion); - float3 diffuse = _Color.rgb * light * surfaceGrain; - float3 shine = skyReflection * (.07 + fresnel * .24 + _Metal * .21) * (1 - _Roughness * .48) - + specular * float3(.72,.51,.34) * (.14 + .59 * _Metal); - return fixed4(saturate(diffuse + shine + _Color.rgb * _Emissive * .60), 1); + float overcast = _SoundingsSeaWeather * _SoundingsSeaSailing; + 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; + float3 diffuse = _Color.rgb * light * SurfaceTone(input.local, normalize(input.localNormal)); + if (_Waterline > .5 && input.world.y < 2.15) + { + // The ocean is drawn as a screen-wide pass, so mask submerged paint against the same wave field. + float level = _SoundingsSeaSailing > .5 + ? OceanWave(input.world.xz, _SoundingsSeaTime, _SoundingsSeaWeather).x : 0; + float aboveWater = input.world.y - level; + clip(aboveWater); + diffuse *= lerp(.73, 1, smoothstep(0, .62, aboveWater)); + } + if (_Finish == 2) + { + float horizon = 1 - smoothstep(.005, .067 + _Roughness * .12, abs(reflected.y - .025)); + float3 glazing = skyReflection * (.30 + fresnel * .62) + float3(.21,.32,.36) * horizon * .28; + 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 == 6) + return fixed4(saturate(diffuse * .81 + skyReflection * (.24 + fresnel * .61) + specular * .44), 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); } ENDCG } diff --git a/Assets/Soundings/Resources/HarborWater.shader b/Assets/Soundings/Resources/HarborWater.shader index 52da4e5..84198fb 100644 --- a/Assets/Soundings/Resources/HarborWater.shader +++ b/Assets/Soundings/Resources/HarborWater.shader @@ -43,26 +43,27 @@ Shader "Soundings/Harbor Water" float3 SkyGradient(float3 ray) { float warmth = pow(saturate(.55 + dot(ray.xz, Sun.xz) * .55), 2.3); - float3 horizon = lerp(float3(.50,.63,.68), float3(.91,.66,.46), warmth * .88); - float elevation = pow(saturate(ray.y), .52); - float3 sky = lerp(horizon, float3(.084,.218,.347), elevation); - float3 squall = lerp(float3(.39,.48,.53), float3(.102,.156,.202), elevation); + float3 horizon = lerp(float3(.55,.69,.75), float3(.92,.71,.51), warmth * .84); + 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); return lerp(sky, squall, _WeatherSeverity); } float3 Sky(float3 ray, float time) { - float2 wind = float2(.0014,-.0010) * time; - float2 layers = ray.xz * (.76 / (max(0, ray.y) + .21)) + wind; - float cloud = tex2Dlod(_OceanDetail, float4(layers * .19, 0, 2)).b * .68 - + tex2Dlod(_OceanDetail, float4(layers * .40 + .38, 0, 2)).b * .32; - float coverage = smoothstep(.57 - .15 * _WeatherSeverity, .82, cloud); - coverage *= smoothstep(-.015,.16,ray.y) * (1 - smoothstep(.66, 1, ray.y)); - float facing = pow(saturate(dot(ray, Sun)), 5); + float2 wind = float2(.00095,-.00068) * time; + float2 layers = ray.xz * (.73 / (max(0, ray.y) + .18)); + float cloud = tex2Dlod(_OceanDetail, float4(layers * float2(.14,.22) + wind, 0, 2)).b * .74 + + tex2Dlod(_OceanDetail, float4(layers * .31 + wind * 1.41 + .38, 0, 2)).b * .26; + float coverage = smoothstep(.52 - .13 * _WeatherSeverity, .76, cloud); + coverage *= smoothstep(-.010,.097,ray.y) * (1 - smoothstep(.61, 1, ray.y)); + float sunlight = saturate(dot(ray, Sun)); float3 color = SkyGradient(ray); - float3 vapor = lerp(color * 1.14 + float3(.124,.106,.087) * facing, - color * .65 + float3(.038,.048,.056), _WeatherSeverity); - return lerp(color, vapor, coverage * (.65 + .3 * _WeatherSeverity)); + float3 vapor = lerp(color * 1.08 + float3(.134,.115,.095) * (.44 + .56 * pow(sunlight, 5)), + color * .63 + float3(.044,.056,.069), _WeatherSeverity); + float glow = .12 * pow(sunlight, 23) + .37 * smoothstep(.9989, .9997, sunlight); + return lerp(color, vapor, coverage) + float3(1,.85,.69) * glow * (1 - _WeatherSeverity) * (1 - coverage); } float2 HullPoint(float2 world) @@ -71,71 +72,105 @@ Shader "Soundings/Harbor Water" return float2(dot(relative, float2(_HullCourse.x, -_HullCourse.y)), dot(relative, _HullCourse.yx)); } - float HullShade(float2 hullPoint) + float HullEdge(float2 hull) { - float halfLength = _HullSpan.x * .5; - float along = abs(hullPoint.x / max(1, halfLength)); - float beam = _HullSpan.y * lerp(.24, 1, saturate(1 - pow(along, 3.2))); - return (1 - smoothstep(.1, 5.8, abs(hullPoint.y) - beam)) * (1 - smoothstep(.91, 1.105, along)); + // Match the outline near the waterline, where the stern stays wider than the bow. + float station = saturate(hull.x / _HullSpan.x + .5); + float stern = lerp(.52, 1, sin(saturate(station / .16) * 1.570796)); + float bow = cos(saturate((station - .69) / .31) * 1.570796); + float side = abs(hull.y) - .95 * _HullSpan.y * stern * bow; + float cap = abs(hull.x) - .495 * _HullSpan.x; + return length(max(float2(side, cap), 0)); } - float BowWhitewater(float2 hull, float breakup) + float2 BowWhitewater(float2 hull, float gap, float eddies, float grain) { - float beam = _HullSpan.y; - float fromStem = _HullSpan.x * .49 - hull.x; - float steer = sqrt(_HullCourse.z); - float bandWidth = 1.55 + max(0, fromStem) * .022; - float glass = abs(hull.y) - (1 + max(0, fromStem) * .37); - float wedge = 1 - smoothstep(.2, bandWidth, abs(glass)); - float stem = 1 - smoothstep(.4, 2.9 + steer * 2.8, length(float2(fromStem + .9, hull.y * .68))); - float flare = smoothstep(-1.9, 7, fromStem) * (1 - smoothstep(_HullSpan.x * .56, _HullSpan.x * 1.16, fromStem)); - float rip = .75 + .25 * sin(fromStem * 1.45 + hull.y + _SeaTime * 7); - float nearBeam = beam * lerp(.22, 1, smoothstep(0, _HullSpan.x * .33, fromStem)); - float hullWash = 1 - smoothstep(.18, 2.05, abs(abs(hull.y) - nearBeam)); - hullWash *= smoothstep(0, 8, fromStem) * (1 - smoothstep(_HullSpan.x * .88, _HullSpan.x, fromStem)); - return saturate((wedge * flare * .81 + stem * .89 + hullWash * .57) * rip * breakup) * (steer * .93); + float length = _HullSpan.x; + float speed = sqrt(_HullCourse.z); + float behind = length * .494 - hull.x; + float distance = max(0, behind); + float current = eddies - .5; + float wedge = abs(hull.y) - (1.1 + distance * .35 + current * (1 + distance * .04)); + float width = .85 + distance * .032; + float bowWave = 1 - smoothstep(.05, width, abs(wedge)); + bowWave *= smoothstep(-2.3, 5.2, behind) * (1 - smoothstep(length * .48, length * .93, behind)); + float stem = 1 - smoothstep(.1, 1.9 + speed * 2.1, abs(behind + .6) + abs(hull.y) * .80); + float wash = (1 - smoothstep(.16, 1.05 + speed + .75 * eddies, gap)) * + smoothstep(-1.0, 7, behind) * (1 - smoothstep(length * .78, length * .99, behind)); + float froth = saturate(.75 * bowWave + .98 * stem + .55 * wash); + float foamCells = smoothstep(.31, .75, eddies * .66 + grain * .34 + froth * .17); + return speed * float2(saturate(.64 * froth + .37 * wash), froth * (.15 + .78 * foamCells)); + } + + float2 WindSlope(float2 position, float eddies, float time) + { + // Short cross-seas add structure between the long swells and the texture ripples. + float2 wind = float2(.45, .89); + float2 swell = float2(-1.08, .67); + float drift = (eddies - .5) * 4.6; + float a = cos(dot(position, wind) - time * 2.15 + drift); + float b = cos(dot(position, swell) - time * 2.76 - drift * .9); + return wind * (.069 * a) + swell * (.043 * b); } float3 OpenSea(float3 origin, float3 ray, float2 screen) { float skyLine = smoothstep(-.0033, .0010, ray.y); float down = max(.00042, -ray.y); - float distance = min(5800, origin.y / down); + float distance = clamp(origin.y / down, 0, 5800); float2 position = origin.xz + ray.xz * distance; float3 waves = OceanWave(position, _SeaTime, _WeatherSeverity); float intersectionBlend = 1 - smoothstep(180, 600, distance); - position -= ray.xz * clamp(waves.x / down, -9, 9) * intersectionBlend; + float approach = max(down * .5, down + dot(waves.yz, ray.xz)); + distance = max(0, distance - clamp(waves.x / approach, -9, 9) * intersectionBlend); + position = origin.xz + ray.xz * distance; waves = OceanWave(position, _SeaTime, _WeatherSeverity); - float2 rotated = float2(position.x * .82 - position.y * .57, position.x * .57 + position.y * .82); - float mip = clamp(log2(max(1, distance) / 76), 0, 7); - float3 chop = tex2Dlod(_OceanDetail, float4(position * .041 + float2(-.022,.013) * _SeaTime, 0, mip)).rgb; - float3 ripples = tex2Dlod(_OceanDetail, float4(rotated * .107 + float2(.032,.020) * _SeaTime, 0, mip + .65)).rgb; - float detail = 1 - smoothstep(85, 670, distance); - float swellDetail = 1 - smoothstep(180, 690, distance); - float roughness = lerp(.43, .96, _WeatherSeverity); - float2 slope = waves.yz * swellDetail - + ((chop.rg - .5) * .47 + (ripples.rg - .5) * .25) * detail * roughness; + float2 rotated = float2(dot(position, float2(.835, -.550)), dot(position, float2(.550, .835))); + float2 crossed = float2(dot(position, float2(.939, .344)), dot(position, float2(-.344, .939))); + float3 chop = tex2D(_OceanDetail, position * .028 + float2(-.018,.012) * _SeaTime).rgb; + float3 ripples = tex2D(_OceanDetail, rotated * .076 + float2(.026,.019) * _SeaTime).rgb; + float3 surface = tex2D(_OceanDetail, crossed * .179 + float2(-.042,.036) * _SeaTime).rgb; + float2 rippleSlope = ripples.rg - .5; + rippleSlope = float2(dot(rippleSlope, float2(.835, .550)), dot(rippleSlope, float2(-.550, .835))); + float2 surfaceSlope = surface.rg - .5; + surfaceSlope = float2(dot(surfaceSlope, float2(.939, -.344)), dot(surfaceSlope, float2(.344, .939))); + float swellDetail = 1 - smoothstep(175, 700, distance); + float textureDetail = 1 - smoothstep(68, 525, distance); + float surfaceDetail = 1 - smoothstep(23, 175, distance); + float roughness = lerp(.60, 1.18, _WeatherSeverity); + float2 slope = waves.yz * swellDetail + WindSlope(position, chop.b, _SeaTime) * textureDetail * roughness + + ((chop.rg - .5) * .34 + rippleSlope * .29) * textureDetail * roughness + + surfaceSlope * (.115 * surfaceDetail * roughness); float3 normal = normalize(float3(-slope.x, 1, -slope.y)); - float rough = ((chop.b - .5) * .045 + (ripples.b - .5) * .015) * detail; - float light = saturate(dot(normal, Sun)); - float3 fromBelow = lerp(float3(.031,.159,.220), float3(.064,.205,.274), .23 + .53 * light + rough * 7); - fromBelow = lerp(fromBelow, fromBelow * .60 + float3(.019,.028,.030), _WeatherSeverity * .82); - float reflection = .19 + .64 * pow(1 - saturate(dot(-ray, normal)), 4); float3 reflected = reflect(ray, normal); - float3 color = lerp(fromBelow, SkyGradient(reflected) * .75, reflection); - float glint = pow(saturate(dot(reflected, Sun)), lerp(78, 29, _WeatherSeverity)); - color += glint * float3(.48,.38,.24) * (1 - .86 * _WeatherSeverity); - float nightFoam = smoothstep(.74,.96, chop.b * .67 + ripples.b * .33 + slope.x * .39); - color = lerp(color, float3(.53,.67,.69), nightFoam * detail * (.22 + _WeatherSeverity * .57)); + float facing = 1 - saturate(dot(-ray, normal)); + float reflection = .095 + .81 * facing * facing * facing * facing * facing; + 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); + float3 color = lerp(fromBelow, SkyGradient(reflected) * .83, reflection); + float sunHit = saturate(dot(reflected, Sun)); + float nearSun = pow(sunHit, lerp(162, 60, _WeatherSeverity)); + float reflectedLight = pow(sunHit, lerp(28, 15, _WeatherSeverity)); + color += (nearSun * .43 + reflectedLight * .13) * float3(1,.86,.65) * (1 - _WeatherSeverity * .88); + + float crest = waves.x / lerp(.35, 1.46, _WeatherSeverity * _WeatherSeverity); + float churn = .55 * chop.b + .28 * ripples.b + .17 * surface.b; + float capFoam = smoothstep(.65, .85, churn + crest * .19 + length(slope) * .17); + color = lerp(color, float3(.64,.74,.76), capFoam * textureDetail * (.035 + _WeatherSeverity * .58)); if (_HullSpan.x > 1) { float2 hull = HullPoint(position); - color *= 1 - HullShade(hull) * .35; - float breakup = .63 + smoothstep(.28,.73, chop.b + ripples.b * .33) * .55; - float foam = BowWhitewater(hull, breakup); - color = lerp(color, float3(.79,.89,.89), foam); + if (abs(hull.x) < _HullSpan.x * .5 + 6 && abs(hull.y) < _HullSpan.x * .34 + 6) + { + float gap = HullEdge(hull); + color *= 1 - (1 - smoothstep(.18, 5.3, gap)) * .31; + float2 foam = BowWhitewater(hull, gap, .67 * ripples.b + .33 * chop.b, surface.b); + color = lerp(color, float3(.32,.57,.61), foam.x * .52); + color = lerp(color, float3(.88,.94,.94), foam.y); + } } float mist = 1 - exp(-distance * (.00040 + .00077 * _WeatherSeverity)); @@ -169,11 +204,15 @@ Shader "Soundings/Harbor Water" float waterMask = 1 - smoothstep(.55, .69, uv.y); float distance = min(2600, max(0, -origin.y / min(ray.y, -.0001))); float2 world = origin.xz + ray.xz * distance; - float textureWave = sin(world.y * 1.94 + world.x * .30 + sin(world.x * .44 - _Time.y * .30)) * .0015; - uv += waterMask * float2(textureWave, textureWave * .14); + float wave = sin(dot(world, float2(.52,1.27)) - _Time.y * 1.3); + float crossWave = sin(dot(world, float2(-.85,.41)) - _Time.y * 1.6); + uv += waterMask * float2(.00089 * wave + .00045 * crossWave, .00028 * crossWave); float3 color = tex2D(_Backdrop, uv).rgb; + float3 harborRipples = tex2D(_OceanDetail, world * .072 + float2(.009,-.014) * _Time.y).rgb; + float glimmer = (harborRipples.r - .5) * (.63 + .37 * wave) + (harborRipples.b - .5) * .22; + color += waterMask * (1 - smoothstep(28, 200, distance)) * glimmer * float3(.019,.028,.035); if (_HullSpan.x > 1) - color *= 1 - HullShade(HullPoint(world)) * .33 * waterMask; + color *= 1 - (1 - smoothstep(.18, 5.3, HullEdge(HullPoint(world)))) * .29 * waterMask; return fixed4(color, 1); } ENDCG diff --git a/Assets/Soundings/Resources/PassageWake.shader b/Assets/Soundings/Resources/PassageWake.shader index 43faac2..70913cc 100644 --- a/Assets/Soundings/Resources/PassageWake.shader +++ b/Assets/Soundings/Resources/PassageWake.shader @@ -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 } diff --git a/Assets/Soundings/Runtime/DeckPassengers.cs b/Assets/Soundings/Runtime/DeckPassengers.cs index 6fc4cc1..f44baa1 100644 --- a/Assets/Soundings/Runtime/DeckPassengers.cs +++ b/Assets/Soundings/Runtime/DeckPassengers.cs @@ -270,8 +270,15 @@ namespace Soundings for (int i = 0; i < outline.Length; i++) { Vector2 a = outline[i], b = outline[(i + 1) % outline.Length]; - structure.Mesh(1).Rod(HarborMesh.Point(a, y + .52f), HarborMesh.Point(b, y + .52f), .031f); - structure.Mesh(1).Rod(HarborMesh.Point(a, y), HarborMesh.Point(a, y + .52f), .035f); + structure.Mesh(Joinery).Rod(HarborMesh.Point(a, y + .98f), HarborMesh.Point(b, y + .98f), .033f); + structure.Mesh(Alloy).Rod(HarborMesh.Point(a, y + .65f), HarborMesh.Point(b, y + .65f), .017f); + structure.Mesh(Alloy).Rod(HarborMesh.Point(a, y + .33f), HarborMesh.Point(b, y + .33f), .015f); + int posts = Mathf.Max(1, Mathf.CeilToInt(Vector2.Distance(a, b) / 2.25f)); + for (int post = 0; post < posts; post++) + { + Vector2 p = Vector2.Lerp(a, b, (float)post / posts); + structure.Mesh(Alloy).Rod(HarborMesh.Point(p, y), HarborMesh.Point(p, y + .98f), .026f); + } } float usableLength = fore - aft; @@ -938,6 +945,17 @@ namespace Soundings if (id != WindowGlass) { bool metal = id is 4 or Alloy or Gasket; + Harbor.SurfaceFinish surfaceFinish = id switch + { + 0 => Harbor.SurfaceFinish.Hull, + 2 or Joinery => Harbor.SurfaceFinish.Timber, + Carpet or BridgeFloor or Upholstery or 11 => Harbor.SurfaceFinish.Fabric, + Alloy => Harbor.SurfaceFinish.Alloy, + _ => Harbor.SurfaceFinish.Paint + }; + material.SetFloat("_Finish", (float)surfaceFinish); + if (id == 0) + material.SetFloat("_Waterline", 1); material.SetFloat("_Roughness", metal ? .39f : .76f); material.SetFloat("_Metal", metal ? .45f : .04f); material.SetFloat("_Weather", id is Carpet or BridgeFloor or Upholstery ? .57f : .12f); diff --git a/Assets/Soundings/Runtime/Harbor.cs b/Assets/Soundings/Runtime/Harbor.cs index 1776820..aeef166 100644 --- a/Assets/Soundings/Runtime/Harbor.cs +++ b/Assets/Soundings/Runtime/Harbor.cs @@ -21,10 +21,11 @@ namespace Soundings private string currentBackplate; private ulong lastLayout; private const float DefaultYaw = 37f, DefaultPitch = 17.5f; + private const float OrbitNearClip = .25f, OrbitClearance = .90f; private float yaw = DefaultYaw, pitch = DefaultPitch, zoom = 1f; private float targetYaw = DefaultYaw, targetPitch = DefaultPitch, targetZoom = 1f; + private Vector3 orbitOffset, targetOrbitOffset; private float seaTime, seaSeverity, passageDistance; - private Vector2 seaCenter; private Vector3 hullMotion, hullMotionVelocity; private bool sailing; private Bounds hullBounds; @@ -40,12 +41,18 @@ namespace Soundings private ShipWalkSpace walkSpace; private enum CameraMode { Orbit, DeckWalk, Bridge, Service } + internal enum SurfaceFinish { Paint, Timber, Glass, Fabric, Alloy, Hull, Pool } public RenderTexture Frame { get; private set; } internal Vector3 PassageWorldPosition => vessel != null ? vessel.position : Vector3.zero; internal bool PassageUsesPerspective => sailing && cameraMode == CameraMode.Orbit && !viewCamera.orthographic; internal Vector3 FirstPersonPosition => freePosition; internal bool FirstPersonPositionIsClear => walkSpace != null && walkSpace.CanStand(freePosition); + internal Vector3 OrbitTarget => OrbitFocus(orbitOffset); + internal float OrbitVerticalSpan => viewCamera.orthographic ? viewCamera.orthographicSize * 2f + : 2f * Vector3.Distance(OrbitTarget, viewCamera.transform.position) * HalfFieldOfView(viewCamera.fieldOfView); + internal bool OrbitCameraIsClear => vessel == null || + !OrbitVolume().Contains(vessel.InverseTransformPoint(viewCamera.transform.position)); public void Initialize() { @@ -106,14 +113,37 @@ namespace Soundings freeYaw = Mathf.Repeat(freeYaw + degrees, 360); } - public void Zoom(float delta) + public void Zoom(float delta, Vector2? viewportPoint = null) { if (cameraMode != CameraMode.Orbit) { freeFov = Mathf.Clamp(freeFov * Mathf.Exp(delta * .035f), 25f, 78f); return; } - targetZoom = Mathf.Clamp(targetZoom * Mathf.Exp(delta * .050f), sailing ? .62f : .64f, sailing ? 1.82f : 1.51f); + float aspect = ViewAspect; + float overview = OverviewZoom; + float next = Mathf.Clamp(targetZoom * Mathf.Exp(delta * .082f), MinimumZoom(aspect), sailing ? 1.82f : 1.51f); + if (next < targetZoom && next < overview && viewportPoint is { } point && IsShipAt(point)) + { + // Keep the point under the pointer on the orbit's focal plane while it grows on screen. + float distanceOnFilm = OverviewHalfHeight(aspect) * (Mathf.Min(overview, targetZoom) - next); + targetOrbitOffset = BoundOrbitOffset(targetOrbitOffset + FilmToShip((point - Vector2.one * .5f) * 2f, + aspect, distanceOnFilm)); + } + else if (next > targetZoom && targetZoom < overview) + { + targetOrbitOffset *= Mathf.Clamp01((overview - next) / (overview - targetZoom)); + } + targetZoom = next; + } + + public void Pan(Vector2 viewportDrag) + { + if (cameraMode != CameraMode.Orbit || vessel == null || targetZoom >= OverviewZoom) + return; + float aspect = ViewAspect; + targetOrbitOffset = BoundOrbitOffset(targetOrbitOffset - FilmToShip(viewportDrag * 2f, + aspect, OverviewHalfHeight(aspect) * targetZoom)); } public void ResetView(bool immediate = false) @@ -142,12 +172,14 @@ namespace Soundings walkSpace = null; targetYaw = deckIndex >= 0 ? 17f : sailing ? 24f : DefaultYaw; targetPitch = deckIndex >= 0 ? 57f : sailing ? 13f : DefaultPitch; - targetZoom = deckIndex >= 0 ? .92f : 1f; + targetZoom = OverviewZoom; + targetOrbitOffset = Vector3.zero; if (!immediate) return; yaw = targetYaw; pitch = targetPitch; zoom = targetZoom; + orbitOffset = Vector3.zero; ComposeCamera(); } @@ -245,7 +277,10 @@ namespace Soundings public bool IsShipAt(Vector2 viewportPoint) { - return vessel != null && hullBounds.IntersectRay(viewCamera.ViewportPointToRay(viewportPoint)); + if (vessel == null) + return false; + Ray ray = viewCamera.ViewportPointToRay(viewportPoint); + return OrbitVolume().IntersectRay(new Ray(vessel.InverseTransformPoint(ray.origin), vessel.InverseTransformDirection(ray.direction))); } public void BeginPassage(WeatherCondition weather = WeatherCondition.Calm, float duration = 180f) @@ -272,7 +307,6 @@ namespace Soundings float sine = Mathf.Sin(headingRadians); float cosine = Mathf.Cos(headingRadians); var center = new Vector2(routePosition.x, -routePosition.y) * passageDistance; - seaCenter = center; if (vessel != null && delta > 0) { // Use wave heights along the waterline to drive a damped heave, pitch and roll. @@ -312,7 +346,6 @@ namespace Soundings public void EndPassage() { sailing = false; - seaCenter = Vector2.zero; waterSurface.localPosition = Vector3.zero; wake.Reset(); Shader.SetGlobalFloat("_SoundingsSeaSailing", 0); @@ -340,24 +373,98 @@ namespace Soundings } float easing = 1 - Mathf.Exp(-Time.unscaledDeltaTime * (sailing ? 12f : 11f)); if (!sailing && Mathf.Abs(yaw - targetYaw) < .005f && Mathf.Abs(pitch - targetPitch) < .005f && - Mathf.Abs(zoom - targetZoom) < .0001f) + Mathf.Abs(zoom - targetZoom) < .0001f && (orbitOffset - targetOrbitOffset).sqrMagnitude < .00001f) return; yaw = Mathf.Repeat(yaw + Mathf.DeltaAngle(yaw, targetYaw) * easing + 180f, 360f) - 180f; pitch = Mathf.Lerp(pitch, targetPitch, easing); zoom = Mathf.Lerp(zoom, targetZoom, easing); + orbitOffset = Vector3.Lerp(orbitOffset, targetOrbitOffset, easing); ComposeCamera(); } - private Vector3 OrbitFocus() + private float ViewAspect => Frame == null ? 16f / 9f : (float)Frame.width / Frame.height; + private float OverviewZoom => deckIndex >= 0 ? .92f : 1f; + private float OverviewFieldOfView => deckIndex >= 0 ? 45f : 38f; + private static float HalfFieldOfView(float fieldOfView) => Mathf.Tan(fieldOfView * Mathf.Deg2Rad * .5f); + private float OverviewDistance(float aspect) => vesselLength * Mathf.Max(1.29f, 2.16f / aspect); + private float OverviewHalfHeight(float aspect) => sailing ? OverviewDistance(aspect) * HalfFieldOfView(OverviewFieldOfView) + : Mathf.Max(17.6f, vesselLength * .71f / aspect); + private float MinimumZoom(float aspect) => (deckIndex >= 0 ? 2.65f : 3.10f) / OverviewHalfHeight(aspect); + + private Vector3 OverviewFocus() { float level = deckIndex >= 0 && decks != null ? decks.FloorHeight(deckIndex) + .5f : vesselTop * .39f; - var center = new Vector3(deckIndex >= 0 ? -2f : 2.1f, level, 0); - if (sailing) + return new Vector3(deckIndex >= 0 ? -2f : 2.1f, level, 0); + } + + private Vector3 OrbitFocus(Vector3 offset) + { + Vector3 local = OverviewFocus() + offset; + return vessel != null ? vessel.TransformPoint(local) : local; + } + + private Vector3 FilmToShip(Vector2 filmOffset, float aspect, float height) + { + Quaternion orbit = Quaternion.Euler(targetPitch, -targetYaw, 0); + Vector3 world = orbit * new Vector3(filmOffset.x * aspect, filmOffset.y, 0) * height; + if (deckIndex >= 0) { - center.x += seaCenter.x; - center.z = seaCenter.y; + Vector3 back = orbit * Vector3.back; + float rise = Vector3.Dot(back, vessel.up); + if (rise > .20f) + world -= back * (Vector3.Dot(world, vessel.up) / rise); } - return center; + return vessel.InverseTransformDirection(world); + } + + private Vector3 BoundOrbitOffset(Vector3 offset) + { + Vector3 home = OverviewFocus(); + Vector3 focus = home + offset; + if (deckIndex >= 0) + { + float length = VesselExterior.DeckLength(vesselLength, deckIndex); + float center = VesselExterior.DeckOffset(vesselLength, deckIndex); + float halfBeam = VesselExterior.DeckHalfBeam(vesselBeam, deckIndex); + focus.x = Mathf.Clamp(focus.x, center - length * .45f, center + length * .40f); + focus.y = home.y; + focus.z = Mathf.Clamp(focus.z, -halfBeam, halfBeam); + } + else + { + focus.x = Mathf.Clamp(focus.x, -vesselLength * .48f, vesselLength * .48f); + focus.y = Mathf.Clamp(focus.y, 2.25f, vesselTop - 1.8f); + focus.z = Mathf.Clamp(focus.z, -vesselBeam, vesselBeam); + } + return focus - home; + } + + private Bounds OrbitVolume() + { + if (deckIndex < 0 || decks == null) + return hullBounds; + Bounds cutaway = hullBounds; + Vector3 top = cutaway.max; + top.y = decks.FloorHeight(deckIndex) + 2.55f; + cutaway.max = top; + return cutaway; + } + + private float ClearOrbitDistance(Vector3 focus, Vector3 direction) + { + float waterDistance = (1.96f - focus.y) / Mathf.Max(.01f, direction.y); + if (vessel == null) + return waterDistance; + + // Cast back toward the focus to find the outer face even when the focus is inside the ship. + Bounds volume = OrbitVolume(); + volume.Expand(OrbitNearClip * 3f); + Vector3 local = vessel.InverseTransformPoint(focus); + Vector3 outward = vessel.InverseTransformDirection(direction); + float probe = volume.size.magnitude + (local - volume.center).magnitude; + var ray = new Ray(local + outward * probe, -outward); + return volume.IntersectRay(ray, out float hit) ? Mathf.Max(waterDistance, probe - hit + OrbitClearance) + : waterDistance; } private void ComposeCamera() @@ -365,12 +472,21 @@ namespace Soundings if (cameraMode == CameraMode.Orbit) { viewCamera.orthographic = !sailing; - viewCamera.nearClipPlane = .25f; - viewCamera.fieldOfView = deckIndex >= 0 ? 45f : 38f; - float aspect = Frame == null ? 16f / 9f : (float)Frame.width / Frame.height; - float distance = sailing ? vesselLength * Mathf.Max(1.29f, 2.16f / aspect) * zoom : 244f; + viewCamera.nearClipPlane = OrbitNearClip; + viewCamera.fieldOfView = OverviewFieldOfView; Quaternion orbit = Quaternion.Euler(pitch, -yaw, 0); - viewCamera.transform.SetPositionAndRotation(OrbitFocus() + orbit * (Vector3.back * distance), orbit); + Vector3 focus = OrbitTarget; + Vector3 back = orbit * Vector3.back; + float distance = 244f; + if (sailing) + { + float dolly = OverviewDistance(ViewAspect) * zoom; + distance = Mathf.Max(dolly, ClearOrbitDistance(focus, back)); + // When the hull blocks the dolly, keep the same framing with the lens. + if (distance > dolly) + viewCamera.fieldOfView = Mathf.Atan(OverviewHalfHeight(ViewAspect) * zoom / distance) * 2f * Mathf.Rad2Deg; + } + viewCamera.transform.SetPositionAndRotation(focus + back * distance, orbit); } else { @@ -414,18 +530,29 @@ namespace Soundings descriptor.msaaSamples = Mathf.Max(1, SystemInfo.GetRenderTextureSupportedMSAASampleCount(descriptor)); Frame = new RenderTexture(descriptor) { name = "Harbor viewport" }; viewCamera.targetTexture = Frame; - FitViewport(); + KeepOrbitInRange(); + ComposeCamera(); + } + + private void KeepOrbitInRange() + { + float minimum = MinimumZoom(ViewAspect); + zoom = Mathf.Max(zoom, minimum); + targetZoom = Mathf.Max(targetZoom, minimum); + orbitOffset = BoundOrbitOffset(orbitOffset); + targetOrbitOffset = BoundOrbitOffset(targetOrbitOffset); } private void FitViewport() { if (Frame == null) return; - float aspect = (float)Frame.width / Frame.height; + float aspect = ViewAspect; viewCamera.aspect = aspect; - viewCamera.orthographicSize = Mathf.Max(17.6f, vesselLength * .71f / aspect) * zoom; + if (viewCamera.orthographic) + viewCamera.orthographicSize = OverviewHalfHeight(aspect) * zoom; Transform view = viewCamera.transform; - float viewHeight = viewCamera.orthographic ? viewCamera.orthographicSize : Mathf.Tan(viewCamera.fieldOfView * Mathf.Deg2Rad * .5f); + float viewHeight = viewCamera.orthographic ? viewCamera.orthographicSize : HalfFieldOfView(viewCamera.fieldOfView); water.SetVector("_ViewOrigin", view.position); water.SetVector("_ViewForward", view.forward); water.SetVector("_ViewRight", view.right); @@ -433,12 +560,15 @@ namespace Soundings water.SetVector("_ViewSize", new Vector4(viewHeight * aspect, viewHeight, viewCamera.orthographic ? 1 : 0, 0)); if (backplateRatio <= 0 || sailing) return; - float cropX = Mathf.Min(1, aspect / backplateRatio) * .95f; - float cropY = Mathf.Min(1, backplateRatio / aspect) * .95f; + float backdropScale = Mathf.Lerp(.86f, 1, Mathf.Clamp01(zoom)); + float cropX = Mathf.Min(1, aspect / backplateRatio) * .95f * backdropScale; + float cropY = Mathf.Min(1, backplateRatio / aspect) * .95f * backdropScale; float panoramaYaw = cameraMode == CameraMode.Orbit ? Mathf.DeltaAngle(DefaultYaw, yaw) : Mathf.DeltaAngle(-DefaultYaw, freeYaw); - float shiftX = Mathf.Clamp(panoramaYaw * .00225f, -.47f * (1 - cropX), .47f * (1 - cropX)); + float shiftX = Mathf.Clamp(panoramaYaw * .00225f + Vector3.Dot(view.right, orbitOffset) * .002f, + -.47f * (1 - cropX), .47f * (1 - cropX)); float panoramaPitch = cameraMode == CameraMode.Orbit ? pitch : freePitch; - float shiftY = Mathf.Clamp((panoramaPitch - DefaultPitch) * .002f, -.47f * (1 - cropY), .47f * (1 - cropY)); + float shiftY = Mathf.Clamp((panoramaPitch - DefaultPitch) * .002f + Vector3.Dot(view.up, orbitOffset) * .002f, + -.47f * (1 - cropY), .47f * (1 - cropY)); water.SetVector("_BackdropCrop", new Vector4(cropX, cropY, shiftX, shiftY)); } @@ -481,8 +611,7 @@ namespace Soundings float beam = vesselBeam = ship.Hull.Beam * .5f; vesselTop = VesselExterior.DeckBase + deckCount * VesselExterior.DeckSpacing + 5.95f; water.SetVector("_HullSpan", new Vector4(vesselLength, beam, 0, 0)); - hullBounds = new Bounds(new Vector3(0, (vesselTop - 2.65f) * .5f, 0), new Vector3(vesselLength, vesselTop + 2.65f, beam * 2.1f)); - FitViewport(); + hullBounds = new Bounds(new Vector3(0, (vesselTop - 2.65f) * .5f, 0), new Vector3(vesselLength * 1.05f, vesselTop + 2.65f, beam * 2.26f)); var exterior = new VesselExterior(ship, vesselLength, beam); foreach (var (paint, batch) in exterior.Meshes()) @@ -504,6 +633,8 @@ namespace Soundings deckIndex = -1; decks.Select(-1); } + KeepOrbitInRange(); + ComposeCamera(); } private void Batch(Mesh mesh, Material material) @@ -535,6 +666,10 @@ namespace Soundings VesselExterior.Paint.LitGlass => ("BB7643", .23f, .25f, .78f, .04f), VesselExterior.Paint.Lounge => ("CC9570", .25f, .20f, .62f, .04f), VesselExterior.Paint.Lifeboat => ("BD542D", .41f, .15f, 0f, .15f), + VesselExterior.Paint.Antifouling => ("734938", .76f, .02f, 0f, .42f), + VesselExterior.Paint.DeckCanvas => ("315263", .91f, 0f, 0f, .15f), + VesselExterior.Paint.PortLight => ("D84738", .25f, .05f, .90f, 0f), + VesselExterior.Paint.StarboardLight => ("4DCA8E", .25f, .05f, .90f, 0f), _ => ("318994", .16f, .40f, .05f, .13f) }; ColorUtility.TryParseHtmlString("#" + hex, out Color color); @@ -543,6 +678,20 @@ namespace Soundings material.SetFloat("_Metal", metal); material.SetFloat("_Emissive", emissive); material.SetFloat("_Weather", weather); + material.SetFloat("_Waterline", paint is VesselExterior.Paint.Navy or VesselExterior.Paint.Antifouling + or VesselExterior.Paint.Black ? 1f : 0f); + SurfaceFinish finish = paint switch + { + VesselExterior.Paint.Teak => SurfaceFinish.Timber, + VesselExterior.Paint.Glass or VesselExterior.Paint.BlueGlass or VesselExterior.Paint.LitGlass + or VesselExterior.Paint.Lounge => SurfaceFinish.Glass, + VesselExterior.Paint.DeckCanvas => SurfaceFinish.Fabric, + VesselExterior.Paint.Steel or VesselExterior.Paint.Gold => SurfaceFinish.Alloy, + VesselExterior.Paint.Navy or VesselExterior.Paint.Antifouling => SurfaceFinish.Hull, + VesselExterior.Paint.Pool => SurfaceFinish.Pool, + _ => SurfaceFinish.Paint + }; + material.SetFloat("_Finish", (float)finish); var reflected = new Material(reflection) { color = color, name = paint + " reflection" }; materials.Add(paint, material); reflections.Add(paint, reflected); diff --git a/Assets/Soundings/Runtime/HarborMesh.cs b/Assets/Soundings/Runtime/HarborMesh.cs index a165eba..bba5f83 100644 --- a/Assets/Soundings/Runtime/HarborMesh.cs +++ b/Assets/Soundings/Runtime/HarborMesh.cs @@ -29,23 +29,37 @@ namespace Soundings Face(start, start + 1, start + 2, start + 3); } - public void Box(Vector3 center, Vector3 size) - { - Vector3 a = center - size * .5f; - Vector3 b = center + size * .5f; - var shape = new[] - { - new Vector2(a.x, a.z), new Vector2(b.x, a.z), new Vector2(b.x, b.z), new Vector2(a.x, b.z) - }; + public void Box(Vector3 center, Vector3 size) => Box(center, size, Vector3.right); - for (int i = 0; i < shape.Length; i++) + public void Box(Vector3 center, Vector3 size, Vector3 along) + { + Vector3 x = along * (size.x * .5f); + Vector3 z = Vector3.Cross(along, Vector3.up) * (size.z * .5f); + Vector3 height = Vector3.up * size.y; + Vector3 low = center - height * .5f; + Vector3 a = low - x - z; + Vector3 b = low + x - z; + Vector3 c = low + x + z; + Vector3 d = low - x + z; + + Quad(b, a, a + height, b + height); + Quad(c, b, b + height, c + height); + Quad(d, c, c + height, d + height); + Quad(a, d, d + height, a + height); + Quad(a + height, d + height, c + height, b + height); + Quad(a, b, c, d); + } + + public void Disc(Vector3 center, Vector3 horizontal, Vector3 vertical, int sides) + { + int start = vertices.Count; + vertices.Add(center); + for (int i = 0; i < sides; i++) { - Vector2 p = shape[i]; - Vector2 q = shape[(i + 1) % shape.Length]; - Quad(Point(q, a.y), Point(p, a.y), Point(p, b.y), Point(q, b.y)); + float angle = i * Mathf.PI * 2 / sides; + vertices.Add(center + horizontal * Mathf.Cos(angle) + vertical * Mathf.Sin(angle)); + AddTriangle(start, start + i + 1, start + (i + 1) % sides + 1); } - Quad(Point(shape[0], b.y), Point(shape[3], b.y), Point(shape[2], b.y), Point(shape[1], b.y)); - Quad(Point(shape[0], a.y), Point(shape[1], a.y), Point(shape[2], a.y), Point(shape[3], a.y)); } public void Loft(Vector2[] outline, Vector2 center, bool lid, params Vector3[] sections) @@ -80,7 +94,7 @@ namespace Soundings AddTriangle(cap + i, cap + points, cap + (i + 1) % points); } - public void Rod(Vector3 from, Vector3 to, float radius, int sides = 6) + public void Rod(Vector3 from, Vector3 to, float radius, int sides = 6, bool capped = false) { Vector3 axis = (to - from).normalized; Vector3 cross = Vector3.Cross(axis, Vector3.up); @@ -102,6 +116,11 @@ namespace Soundings int b = start + ((i + 1) % sides) * 2; Face(a, b, b + 1, a + 1); } + if (capped) + { + Disc(from, u, -v, sides); + Disc(to, u, v, sides); + } } public void Radome(Vector3 center, float radius) diff --git a/Assets/Soundings/Runtime/PassageInterface.cs b/Assets/Soundings/Runtime/PassageInterface.cs index 968b887..915238d 100644 --- a/Assets/Soundings/Runtime/PassageInterface.cs +++ b/Assets/Soundings/Runtime/PassageInterface.cs @@ -120,7 +120,7 @@ namespace Soundings AddText(camera, "CAMERA", "voyage-caption"); string cameraHelp = passageBridge && passageHelm.Manual ? "Right-drag to look · Q / E to turn" : passageBridge || passageExploring ? "WASD to walk · Q / E to turn" - : "Drag or Q / E to orbit · Wheel to zoom"; + : "Drag or Q / E to orbit · Wheel to zoom · Middle-drag to pan"; AddText(camera, cameraHelp, "voyage-camera-help"); rail.Add(Action("Skip to arrival", FinishVoyage, "voyage-view-button voyage-skip", "dock-now")); DrawHelmControls(overlay); diff --git a/Assets/Soundings/Runtime/PassageWake.cs b/Assets/Soundings/Runtime/PassageWake.cs index 154df90..4f64a41 100644 --- a/Assets/Soundings/Runtime/PassageWake.cs +++ b/Assets/Soundings/Runtime/PassageWake.cs @@ -124,6 +124,7 @@ namespace Soundings mesh.bounds = bounds; finish.SetFloat("_SeaTime", time); finish.SetFloat("_WeatherSeverity", storm); + finish.SetFloat("_TrailLength", distance); if (!root.activeSelf) root.SetActive(true); diff --git a/Assets/Soundings/Runtime/SoundingsApp.cs b/Assets/Soundings/Runtime/SoundingsApp.cs index f167093..eb5add4 100644 --- a/Assets/Soundings/Runtime/SoundingsApp.cs +++ b/Assets/Soundings/Runtime/SoundingsApp.cs @@ -395,7 +395,7 @@ namespace Soundings GameIcon(plan, "chart"); commands.Add(plan); var camera = Add(commands, "camera-legend"); - AddText(camera, "Drag to orbit / Scroll to zoom", "camera-copy"); + AddText(camera, "Drag to orbit / Scroll to zoom / Middle-drag to pan", "camera-copy"); Button reset = Action("Reset", () => harbor.ResetView(), "camera-reset", "reset-camera"); reset.tooltip = "Reset harbor camera (Home)"; camera.Add(reset); @@ -469,15 +469,16 @@ namespace Soundings private void AttachCamera(VisualElement world) { int pointerId = -1; - bool freeLook = false; + bool freeLook = false, pan = false; Vector2 start = Vector2.zero, last = Vector2.zero; bool dragging = false; world.RegisterCallback(evt => { - if (paused || pointerId >= 0 || (evt.button != 0 && evt.button != 1)) + if (paused || pointerId >= 0 || evt.button < 0 || evt.button > 2) return; pointerId = evt.pointerId; freeLook = underway != null && evt.button == 1 && (passageBridge || passageExploring); + pan = evt.button == 2; SetPassageFreeLook(freeLook); start = last = evt.localPosition; dragging = false; @@ -492,7 +493,12 @@ namespace Soundings if (dragging || (position - start).sqrMagnitude > 16) { dragging = true; - if (!freeLook) + if (pan) + { + Vector2 delta = position - last; + harbor.Pan(new Vector2(delta.x / world.layout.width, -delta.y / world.layout.height)); + } + else if (!freeLook) harbor.Orbit(position - last); else if (!passageCursorLocked) harbor.Look(position - last); @@ -531,7 +537,8 @@ namespace Soundings { if (paused) return; - harbor.Zoom(evt.delta.y); + Vector2 point = world.WorldToLocal(evt.mousePosition); + harbor.Zoom(evt.delta.y, new Vector2(point.x / world.layout.width, 1f - point.y / world.layout.height)); evt.StopPropagation(); }); } diff --git a/Assets/Soundings/Runtime/VesselExterior.cs b/Assets/Soundings/Runtime/VesselExterior.cs index 5140cb2..dcc2dea 100644 --- a/Assets/Soundings/Runtime/VesselExterior.cs +++ b/Assets/Soundings/Runtime/VesselExterior.cs @@ -6,7 +6,12 @@ namespace Soundings internal sealed class VesselExterior { internal const float DeckBase = 5.38f, DeckSpacing = 2.62f; - internal enum Paint { Navy, Ivory, Pearl, Gold, Teak, TeakSeam, Steel, Black, Glass, BlueGlass, LitGlass, Lounge, Lifeboat, Pool } + private const int HullStations = 36, DeckStations = 28, BridgeStations = 20; + internal enum Paint + { + Navy, Ivory, Pearl, Gold, Teak, TeakSeam, Steel, Black, Glass, BlueGlass, LitGlass, Lounge, + Lifeboat, Pool, Antifouling, DeckCanvas, PortLight, StarboardLight + } private readonly Dictionary batches = new Dictionary(); private readonly Ship ship; @@ -40,43 +45,81 @@ namespace Soundings private void BuildHull() { - Vector2[] outline = Outline(length, beam, 0); + Vector2[] outline = Outline(length, beam, 0, HullStations); Vector2 center = Vector2.zero; - Coat(Paint.Navy).Loft(outline, center, false, new Vector3(.88f, -2.65f, .55f), - new Vector3(.967f, -.83f, .87f), new Vector3(.99f, .28f, .97f), - new Vector3(1, 2.34f, 1), new Vector3(1.01f, 4.65f, 1.03f)); + Coat(Paint.Antifouling).Loft(outline, center, false, new Vector3(.875f, -2.65f, .53f), + new Vector3(.936f, -1.78f, .73f), new Vector3(.967f, -.83f, .87f), + new Vector3(.984f, -.13f, .933f)); + Coat(Paint.Black).Loft(outline, center, false, new Vector3(.984f, -.13f, .933f), + new Vector3(.991f, .27f, .969f)); + Coat(Paint.Navy).Loft(outline, center, false, new Vector3(.991f, .27f, .969f), + new Vector3(.996f, 1.22f, .988f), new Vector3(1, 2.39f, 1), + new Vector3(1.01f, 4.65f, 1.03f)); Coat(Paint.Gold).Loft(outline, center, false, new Vector3(1.013f, 3.54f, 1.025f), - new Vector3(1.013f, 3.69f, 1.026f)); + new Vector3(1.013f, 3.61f, 1.026f)); Coat(Paint.Ivory).Loft(outline, center, true, new Vector3(.998f, 4.47f, 1.015f), new Vector3(1.013f, 5.14f, 1.027f), new Vector3(1.003f, 5.32f, 1.015f)); - Vector2[] promenade = Outline(length * .971f, beam * .979f, 0); + Vector2[] promenade = Outline(length * .971f, beam * .979f, 0, HullStations); Coat(Paint.Teak).Loft(promenade, center, true, new Vector3(.997f, 5.32f, 1), new Vector3(1, DeckBase, 1)); - Rails(promenade, 5.39f, 5.99f, 2.7f); + Rails(promenade, DeckBase, DeckBase + .77f, 2.1f); for (int side = -1; side <= 1; side += 2) { - for (int i = 0; i < 24; i++) + int portholes = 25 + ship.HullIndex * 7; + for (int i = 0; i < portholes; i++) { - float x = -length * .40f + i * length * .0285f; - float z = side * beam * 1.024f * SideWidth(x / length + .50f); - Coat(Paint.Black).Box(new Vector3(x, 2.7f, z), new Vector3(.46f, .56f, .18f)); - Paint pane = (i + 3 * side) % 5 == 0 ? Paint.LitGlass : Paint.BlueGlass; - Coat(pane).Box(new Vector3(x, 2.72f, z + side * .09f), new Vector3(.31f, .38f, .09f)); + float station = Mathf.Lerp(.105f, .837f, i / (float)(portholes - 1)); + var (at, along, outward) = SideFrame(station, 2.76f, length * 1.002f, + beam * 1.006f, 0, side, HullStations); + Coat(Paint.Steel).Disc(at + outward * .043f, along * (side * .22f), Vector3.up * .238f, 12); + Coat(Paint.Black).Disc(at + outward * .048f, along * (side * .178f), Vector3.up * .194f, 12); + Paint pane = (i + 5 * side) % 7 == 0 ? Paint.Lounge : Paint.Glass; + Coat(pane).Disc(at + outward * .052f, along * (side * .145f), Vector3.up * .161f, 12); } + + var (door, hinge, face) = SideFrame(.56f, 3.22f, length * 1.004f, beam * 1.016f, 0, side, + HullStations); + SidePanel(Coat(Paint.Black), door + face * .027f, hinge, side, 2.22f, 1.66f); + SidePanel(Coat(Paint.Navy), door + face * .032f, hinge, side, 2.10f, 1.53f); + SidePanel(Coat(Paint.Steel), door + face * .04f + hinge * .82f, hinge, side, .21f, .08f); } - float fore = length * .397f; - Coat(Paint.Steel).Rod(new Vector3(fore, 5.35f, 0), new Vector3(fore, 7.24f, 0), .13f); - Coat(Paint.Gold).Rod(new Vector3(fore, 6.48f, -.82f), new Vector3(fore, 6.48f, .82f), .048f); + BuildForecastle(); + } + + private void BuildForecastle() + { + float mast = length * .416f; + Coat(Paint.Pearl).Rod(new Vector3(mast, DeckBase, 0), new Vector3(mast, DeckBase + 2.25f, 0), .095f, 9, true); + Coat(Paint.Steel).Rod(new Vector3(mast, DeckBase + 1.24f, -.72f), + new Vector3(mast, DeckBase + 1.24f, .72f), .043f); + Coat(Paint.LitGlass).Rod(new Vector3(mast, DeckBase + 2.04f, 0), + new Vector3(mast, DeckBase + 2.24f, 0), .114f, 9, true); + + float winch = length * .336f; + Coat(Paint.Steel).Box(new Vector3(winch, DeckBase + .13f, 0), new Vector3(1.77f, .26f, 1.57f)); + Coat(Paint.Navy).Box(new Vector3(winch, DeckBase + .40f, 0), new Vector3(1.09f, .50f, .64f)); for (int side = -1; side <= 1; side += 2) + { + Vector3 spool = new Vector3(winch, DeckBase + .55f, side * .74f); + Coat(Paint.Black).Rod(spool - Vector3.forward * .41f, spool + Vector3.forward * .41f, .30f, 12, true); + Coat(Paint.Steel).Rod(spool - Vector3.forward * .21f, spool + Vector3.forward * .21f, .34f, 12, true); + Vector3 fairlead = new Vector3(length * .397f, DeckBase + .055f, side * beam * .27f); + Coat(Paint.Black).Rod(spool + new Vector3(.16f, -.19f, side * .10f), fairlead, .049f, 8); + Coat(Paint.Steel).Box(fairlead, new Vector3(.58f, .13f, .41f)); + Coat(Paint.Black).Rod(fairlead, fairlead + Vector3.up * .20f, .12f, 8, true); + for (int i = 0; i < 3; i++) { - float x = length * (.32f + i * .032f); - float z = side * beam * (.52f - i * .135f); - Coat(Paint.Black).Rod(new Vector3(x, 5.37f, z), new Vector3(x, 5.74f, z), .15f); - Coat(Paint.Steel).Box(new Vector3(x, 5.73f, z), new Vector3(.50f, .085f, .32f)); + float x = length * (.326f + i * .042f); + float z = side * beam * (.58f - i * .185f); + Vector3 bollard = new Vector3(x, DeckBase, z); + Coat(Paint.Steel).Box(bollard + Vector3.up * .055f, new Vector3(.71f, .11f, .33f)); + Coat(Paint.Black).Rod(bollard + new Vector3(-.18f, .08f, 0), bollard + new Vector3(-.18f, .29f, 0), .097f, 8, true); + Coat(Paint.Black).Rod(bollard + new Vector3(.18f, .08f, 0), bollard + new Vector3(.18f, .29f, 0), .097f, 8, true); } + } } private void BuildPassengerDeck(int deck) @@ -85,51 +128,107 @@ namespace Soundings float roof = y + DeckSpacing; var (deckLength, deckBeam, offset) = DeckFootprint(deck); Vector2 center = new Vector2(offset, 0); - Vector2[] outline = Outline(deckLength, deckBeam, offset); + Vector2[] outline = Outline(deckLength, deckBeam, offset, DeckStations); Coat(Paint.Ivory).Loft(outline, center, false, new Vector3(.97f, y, .77f), - new Vector3(.99f, y + .25f, .83f), new Vector3(.99f, roof - .39f, .83f)); - Coat(Paint.Pearl).Loft(outline, center, true, new Vector3(.993f, roof - .39f, .96f), - new Vector3(1.017f, roof - .31f, 1.01f), new Vector3(1.017f, roof - .15f, 1.015f), - new Vector3(1, roof - .06f, 1)); + new Vector3(.99f, y + .24f, .83f), new Vector3(.99f, roof - .37f, .83f)); + Coat(Paint.Black).Loft(outline, center, false, new Vector3(.992f, roof - .39f, .835f), + new Vector3(.995f, roof - .34f, .946f)); + Coat(Paint.Pearl).Loft(outline, center, false, new Vector3(.995f, roof - .34f, .946f), + new Vector3(1.008f, roof - .26f, 1.005f), new Vector3(1.008f, roof - .11f, 1.008f), + new Vector3(.994f, roof - .06f, .992f)); Coat(Paint.Teak).Loft(outline, center, true, new Vector3(.992f, roof - .06f, .989f), new Vector3(.994f, roof, .992f)); - Rails(outline, roof, roof + .73f, 2.4f); + Rails(outline, roof, roof + .78f, 2.1f); - float width = .70f * deckLength / balconies; + float width = .72f * deckLength / balconies; for (int i = 0; i < balconies; i++) { - float x = offset + Mathf.Lerp(-.39f, .31f, (float)i / (balconies - 1)) * deckLength; - float cross = SideWidth((x - offset) / deckLength + .5f); + float station = Mathf.Lerp(.101f, .821f, (i + .5f) / balconies); int column = i * ship.Hull.Columns / balconies; - for (int side = -1; side <= 1; side += 2) { int row = side < 0 ? 0 : ship.Hull.Rows - 1; Facility facility = ship.Decks[deck].Cells[row * ship.Hull.Columns + column]; - float z = side * deckBeam * cross; - Vector3 glass = new Vector3(x, y + 1.27f, z * .846f); - Coat(Paint.Black).Box(glass, new Vector3(width * 1.01f, 1.80f, .17f)); - float divider = width * .21f; - Paint illumination = facility switch + var (floor, along, outward) = SideFrame(station, y, deckLength * .99f, deckBeam * .83f, offset, + side, DeckStations); + switch (facility) { - Facility.Dining => Paint.LitGlass, - Facility.Entertainment => Paint.Lounge, - Facility.Cabin when (i + deck * 5 + row * 3) % 7 < 4 => Paint.LitGlass, - Facility.Tank => Paint.Black, - _ => Paint.Glass - }; - for (int pane = -1; pane <= 1; pane += 2) - Coat(pane < 0 ? illumination : Paint.BlueGlass).Box(glass + new Vector3(pane * divider, .025f, side * .09f), - new Vector3(width * .38f, 1.54f, .09f)); - - if (facility == Facility.Tank) - continue; - Coat(Paint.Teak).Box(new Vector3(x, y + .28f, z * .935f), new Vector3(width * 1.10f, .12f, Mathf.Abs(z) * .19f)); - Coat(Paint.BlueGlass).Box(new Vector3(x, y + .63f, z * 1.016f), new Vector3(width * .96f, .48f, .05f)); - Coat(Paint.Pearl).Box(new Vector3(x, y + .92f, z * 1.02f), new Vector3(width * 1.045f, .047f, .055f)); - Coat(Paint.Pearl).Box(new Vector3(x + width * .52f, y + .65f, z * 1.02f), new Vector3(.055f, .52f, .075f)); + case Facility.Cabin: + bool occupied = (i * 3 + deck * 5 + row * 7) % 11 < 3; + BuildWindow(floor, along, outward, side, width * .76f, 1.03f, 1.73f, 2, + occupied ? Paint.Lounge : Paint.Glass); + BuildBalcony(floor, along, outward, width, Mathf.Abs(floor.z) * .23f); + break; + case Facility.Dining: + case Facility.Entertainment: + case Facility.Bar: + case Facility.Amenity: + BuildWindow(floor, along, outward, side, width * .88f, 1.35f, 1.23f, 3, + (i + deck * 2) % 6 == 0 ? Paint.Lounge : Paint.Glass); + break; + case Facility.Empty: + BuildWindow(floor, along, outward, side, width * .49f, 1.42f, .76f, 2, Paint.Glass); + break; + default: + if (i % 2 == 0) + BuildVent(floor + outward * .065f + Vector3.up * 1.63f, along, outward, + side, width * .43f); + break; + } } } + + for (int side = -1; side <= 1; side += 2) + { + for (int i = 0; i < 3; i++) + { + var (floor, along, outward) = SideFrame(.845f + i * .039f, y, deckLength * .99f, + deckBeam * .83f, offset, side, DeckStations); + BuildWindow(floor, along, outward, side, width * .70f, 1.32f, 1.14f, 2, Paint.Glass); + } + } + } + + private void BuildWindow(Vector3 floor, Vector3 along, Vector3 outward, int side, float width, float height, + float opening, int panes, Paint illumination) + { + Vector3 at = floor + Vector3.up * height + outward * .055f; + SidePanel(Coat(Paint.Black), at, along, side, width, opening); + float pane = (width - .10f) / panes; + for (int i = 0; i < panes; i++) + { + Vector3 center = at + outward * .007f + along * ((i + .5f - panes * .5f) * pane); + SidePanel(Coat(i == 0 ? illumination : Paint.Glass), center, along, side, pane - .037f, opening - .112f); + } + Coat(Paint.Pearl).Box(at - Vector3.up * (opening * .5f) + outward * .041f, + new Vector3(width + .09f, .047f, .14f), along); + } + + private void BuildBalcony(Vector3 floor, Vector3 along, Vector3 outward, float width, float depth) + { + Coat(Paint.Teak).Box(floor + outward * (.52f * depth) + Vector3.up * .057f, + new Vector3(width * .94f, .106f, depth * 1.08f), along); + Vector3 rail = floor + outward * depth; + float span = width * .93f; + HarborMesh frame = Coat(Paint.Steel); + frame.Box(rail + Vector3.up * .12f, new Vector3(span, .09f, .085f), along); + frame.Box(rail + Vector3.up * .51f, new Vector3(span, .032f, .044f), along); + Coat(Paint.Teak).Box(rail + Vector3.up * .89f, new Vector3(span, .055f, .087f), along); + for (int i = -1; i <= 1; i++) + { + Vector3 post = rail + along * (i * span * .48f); + frame.Box(post + Vector3.up * .48f, new Vector3(.035f, .80f, .052f), along); + } + Coat(Paint.Ivory).Box(floor + along * (span * .50f) + outward * (depth * .46f) + Vector3.up * .59f, + new Vector3(.048f, 1.07f, depth * .81f), along); + } + + private void BuildVent(Vector3 center, Vector3 along, Vector3 outward, int side, float width) + { + SidePanel(Coat(Paint.Steel), center, along, side, width, .37f); + for (int slat = -2; slat <= 2; slat++) + SidePanel(Coat(Paint.Black), center + outward * .003f + Vector3.up * (slat * .059f), + along, side, width - .092f, .027f); } private void BuildBridgeAndRoof() @@ -139,35 +238,46 @@ namespace Soundings float top = DeckBase + ship.Decks.Count * DeckSpacing; float bridge = BridgeCenter(length, ship.Decks.Count); Vector2 center = new Vector2(bridge, 0); - Vector2[] capsule = Outline(9.15f, beam * .67f, bridge); + Vector2[] capsule = Outline(9.15f, beam * .67f, bridge, BridgeStations); Coat(Paint.Ivory).Loft(capsule, center, false, new Vector3(.91f, top, .91f), new Vector3(1, top + .88f, 1)); + Coat(Paint.Black).Loft(capsule, center, false, new Vector3(1.002f, top + .80f, 1.006f), + new Vector3(1.002f, top + .91f, 1.006f)); Coat(Paint.Glass).Loft(capsule, center, false, new Vector3(1, top + .88f, 1), new Vector3(.90f, top + 2.62f, .95f)); Coat(Paint.Pearl).Loft(capsule, center, true, new Vector3(.905f, top + 2.59f, .955f), - new Vector3(.975f, top + 2.72f, 1.025f), new Vector3(.82f, top + 2.91f, .90f)); - foreach (Vector2 point in capsule) - if (point.x > bridge - .5f) - Coat(Paint.Steel).Rod(HarborMesh.Point(point, top + .89f), - HarborMesh.Point(center + Vector2.Scale(point - center, new Vector2(.90f, .95f)), top + 2.61f), .031f); + new Vector3(.985f, top + 2.68f, 1.037f), new Vector3(.975f, top + 2.78f, 1.025f), + new Vector3(.87f, top + 2.94f, .91f)); + for (int i = 0; i < capsule.Length; i += 2) + { + Vector2 frame = (capsule[i] - center) * 1.005f; + Coat(Paint.Pearl).Rod(HarborMesh.Point(center + frame, top + .88f), + HarborMesh.Point(center + Vector2.Scale(frame, new Vector2(.90f, .95f)), top + 2.62f), .039f); + } float mast = bridge + 1.15f; - Coat(Paint.Ivory).Rod(new Vector3(mast, top + 2.88f, 0), new Vector3(mast - .48f, top + 5.72f, 0), .135f, 8); + Coat(Paint.Pearl).Box(new Vector3(mast - .20f, top + 3.03f, 0), new Vector3(1.35f, .24f, 1.11f)); + Coat(Paint.Ivory).Rod(new Vector3(mast, top + 3.11f, 0), new Vector3(mast - .48f, top + 5.72f, 0), .145f, 8, true); for (int i = 0; i < 3; i++) { float y = top + 3.35f + i * .66f; float span = 1.98f - i * .36f; Coat(Paint.Pearl).Rod(new Vector3(mast - .27f, y, -span), new Vector3(mast - .27f, y, span), .055f); - Coat(Paint.Black).Rod(new Vector3(mast - .24f, y, span * .84f), new Vector3(mast - .24f, y + .40f, span * .84f), .022f); + for (int side = -1; side <= 1; side += 2) + Coat(Paint.Black).Rod(new Vector3(mast - .24f, y, span * .84f * side), + new Vector3(mast - .24f, y + .40f, span * .84f * side), .022f, 6, true); } Coat(Paint.LitGlass).Radome(new Vector3(mast - .48f, top + 5.77f, 0), .13f); + Coat(Paint.Pearl).Box(new Vector3(mast - .31f, top + 4.03f, 0), new Vector3(.26f, .14f, 2.41f)); + Coat(Paint.Black).Box(new Vector3(mast - .16f, top + 4.03f, 0), new Vector3(.07f, .066f, 2.30f)); float stack = offset - deckLength * .24f; for (int side = -1; side <= 1; side += 2) { - float z = side * deckBeam * .26f; + BuildBridgeWing(bridge, top, side); + float z = side * deckBeam * .23f; Vector2 foot = new Vector2(stack, z); - Vector2[] funnel = Outline(3.85f, .94f, stack, z); + Vector2[] funnel = Outline(3.85f, .94f, stack, 14, z); Coat(Paint.Ivory).Loft(funnel, foot, false, new Vector3(1.13f, top, 1.12f), new Vector3(.99f, top + .82f, .985f)); Coat(Paint.Navy).Loft(funnel, foot, false, new Vector3(.99f, top + .82f, .985f), @@ -176,23 +286,118 @@ namespace Soundings new Vector3(.90f, top + 2.91f, .80f)); Coat(Paint.Black).Loft(funnel, foot, true, new Vector3(.90f, top + 2.91f, .80f), new Vector3(.87f, top + 3.23f, .77f)); - - Coat(Paint.Steel).Rod(new Vector3(stack + 7.8f, top, z * 2), new Vector3(stack + 7.8f, top + .59f, z * 2), .16f); - Coat(Paint.Pearl).Radome(new Vector3(stack + 7.8f, top + .93f, z * 2), .49f); + for (int exhaust = -1; exhaust <= 1; exhaust++) + { + Vector3 pipe = new Vector3(stack + exhaust * .65f, top + 3.22f, z); + Coat(Paint.Steel).Rod(pipe, pipe + Vector3.up * .21f, .185f, 10); + Coat(Paint.Black).Disc(pipe + Vector3.up * .142f, Vector3.right * .17f, Vector3.back * .17f, 10); + } + var (vent, along, outward) = SideFrame(.29f, top + 1.45f, 3.67f, .82f, stack, side, 14); + BuildVent(vent + Vector3.forward * z + outward * .027f, along, outward, side, .64f); + Vector3 radome = new Vector3(stack + 6.10f, top, side * deckBeam * .50f); + Coat(Paint.Steel).Rod(radome, radome + Vector3.up * .68f, .16f, 9, true); + Coat(Paint.Pearl).Radome(radome + Vector3.up * .90f, .54f); } - float pool = offset + deckLength * .01f; - Coat(Paint.Pearl).Box(new Vector3(pool, top + .075f, 0), new Vector3(5.67f, .17f, 3.32f)); - Coat(Paint.Pool).Box(new Vector3(pool, top + .17f, 0), new Vector3(5.21f, .073f, 2.89f)); - for (int i = 0; i < 8; i++) + BuildSunDeck(offset + deckLength * .01f, top, deckBeam); + } + + private void BuildBridgeWing(float bridge, float top, int side) + { + Vector3 root = new Vector3(bridge + .72f, top, side * beam * .766f); + Vector3 outward = Vector3.forward * side; + float span = beam * .26f; + Coat(Paint.Ivory).Box(root + Vector3.up * .30f, new Vector3(3.41f, .60f, span)); + Coat(Paint.Black).Box(root + Vector3.up * .79f, new Vector3(3.32f, .41f, span * .96f)); + Coat(Paint.Glass).Box(root + Vector3.up * 1.32f, new Vector3(3.21f, .87f, span * .93f)); + Coat(Paint.Pearl).Box(root + Vector3.up * 1.83f, new Vector3(3.47f, .16f, span * 1.04f)); + for (int i = -1; i <= 1; i++) + Coat(Paint.Pearl).Box(root + outward * (span * .468f) + new Vector3(i * 1.008f, 1.31f, 0), + new Vector3(.063f, .88f, .055f)); + Vector3 lamp = root + outward * (span * .51f) + new Vector3(.89f, .24f, 0); + Coat(Paint.Black).Box(lamp, new Vector3(.43f, .24f, .21f)); + Coat(side < 0 ? Paint.PortLight : Paint.StarboardLight).Box(lamp + outward * .117f, + new Vector3(.27f, .12f, .052f)); + } + + private void BuildSunDeck(float pool, float top, float deckBeam) + { + Vector2 center = new Vector2(pool, 0); + Vector2[] coping = RoundedRectangle(center, 2.88f, 1.70f, .41f); + Coat(Paint.Pearl).Loft(coping, center, true, new Vector3(1, top, 1), + new Vector3(1, top + .18f, 1), new Vector3(.989f, top + .23f, .987f)); + Coat(Paint.BlueGlass).Loft(RoundedRectangle(center, 2.68f, 1.50f, .32f), center, true, + new Vector3(1, top + .234f, 1)); + Coat(Paint.Pool).Loft(RoundedRectangle(center, 2.61f, 1.43f, .27f), center, true, + new Vector3(1, top + .24f, 1)); + + for (int side = -1; side <= 1; side += 2) { - Coat(Paint.TeakSeam).Box(new Vector3(pool, top + .032f, (i - 3.5f) * .69f), new Vector3(10, .014f, .032f)); - float x = pool - 3.4f + i * .94f; - Coat(Paint.Pearl).Box(new Vector3(x, top + .19f, deckBeam * .67f), new Vector3(.56f, .13f, .92f)); - Coat(Paint.Steel).Box(new Vector3(x, top + .34f, deckBeam * .67f + .31f), new Vector3(.52f, .17f, .26f)); + float railZ = side * 1.58f; + for (int rail = -1; rail <= 1; rail += 2) + { + var foot = new Vector3(pool - 2.08f + rail * .24f, top + .035f, railZ + side * .37f); + var elbow = foot + new Vector3(0, .68f, side * -.05f); + var end = foot + new Vector3(0, .32f, side * -.64f); + Coat(Paint.Steel).Rod(foot, elbow, .026f, 8, true); + Coat(Paint.Steel).Rod(elbow, end, .026f, 8, true); + } + for (int i = 0; i < 8; i++) + { + float x = pool - 3.00f + i * .94f; + BuildLounger(x, top, deckBeam * .67f, side); + } + BuildParasol(new Vector3(pool + 3.81f, top, side * deckBeam * .55f), side > 0); } } + private void BuildLounger(float x, float top, float sideDistance, int side) + { + Vector3 seat = new Vector3(x, top + .32f, side * sideDistance); + Vector3 head = seat + new Vector3(0, .38f, side * .57f); + Coat(Paint.DeckCanvas).Box(seat + Vector3.back * (side * .14f), new Vector3(.54f, .077f, .88f)); + Vector3 halfWidth = Vector3.right * .262f; + Vector3 hinge = seat + Vector3.forward * (side * .30f); + Coat(Paint.DeckCanvas).Quad(hinge - halfWidth, side > 0 ? head - halfWidth : hinge + halfWidth, + head + halfWidth, side > 0 ? hinge + halfWidth : head - halfWidth); + HarborMesh frame = Coat(Paint.Pearl); + for (int rail = -1; rail <= 1; rail += 2) + { + Vector3 edge = Vector3.right * (rail * .29f); + frame.Rod(seat + edge + Vector3.forward * (side * -.56f), hinge + edge, .026f); + frame.Rod(hinge + edge, head + edge, .026f); + frame.Rod(seat + edge + Vector3.back * (side * .37f), seat + edge + new Vector3(0, -.32f, side * -.46f), .026f); + frame.Rod(hinge + edge, hinge + edge + new Vector3(0, -.32f, side * .10f), .026f); + } + frame.Rod(head - halfWidth, head + halfWidth, .023f); + } + + private void BuildParasol(Vector3 foot, bool accent) + { + Coat(Paint.Steel).Rod(foot, foot + Vector3.up * 2.24f, .036f, 8, true); + Coat(Paint.Black).Rod(foot, foot + Vector3.up * .095f, .21f, 12, true); + Vector3 top = foot + Vector3.up * 2.23f; + const int panels = 8; + for (int i = 0; i < panels; i++) + { + Vector3 edge = ParasolEdge(foot, i, panels); + Vector3 next = ParasolEdge(foot, i + 1, panels); + Vector3 crown = top + (edge - foot - Vector3.up * 1.86f) * .23f; + Vector3 nextCrown = top + (next - foot - Vector3.up * 1.86f) * .23f; + HarborMesh fabric = Coat((i + (accent ? 1 : 0)) % 4 == 0 ? Paint.DeckCanvas : Paint.Ivory); + fabric.Quad(next, edge, crown, nextCrown); + fabric.Quad(edge, next, nextCrown, crown); + Coat(Paint.Ivory).Rod(top, edge, .009f); + } + Coat(Paint.Ivory).Disc(top, Vector3.right * .295f, Vector3.back * .295f, panels); + } + + private static Vector3 ParasolEdge(Vector3 foot, int panel, int panelCount) + { + float angle = panel * Mathf.PI * 2 / panelCount; + return foot + new Vector3(Mathf.Cos(angle) * 1.24f, 1.86f, Mathf.Sin(angle) * 1.24f); + } + private void BuildLifeboats() { for (int i = 0; i < 5 + ship.HullIndex * 2; i++) @@ -201,12 +406,17 @@ namespace Soundings float x = -length * .31f + i * (ship.HullIndex == 0 ? 5.52f : 4.7f); float z = side * beam * .974f; Vector2 center = new Vector2(x, z); - Vector2[] capsule = Outline(4.31f, .60f, x, z); + Vector2[] capsule = Outline(4.31f, .60f, x, 12, z); Coat(Paint.Lifeboat).Loft(capsule, center, false, new Vector3(.86f, 6.27f, .59f), new Vector3(1, 6.49f, .99f), new Vector3(1, 6.65f, 1)); Coat(Paint.Pearl).Loft(capsule, center, true, new Vector3(1, 6.65f, 1), new Vector3(.875f, 6.94f, .82f), new Vector3(.78f, 7.04f, .65f)); - Coat(Paint.Glass).Box(new Vector3(x + .96f, 6.94f, z + side * .44f), new Vector3(.50f, .15f, .13f)); + for (int window = 0; window < 3; window++) + { + var (at, along, outward) = SideFrame(.42f + window * .115f, 6.91f, 3.63f, .50f, x, side, 12); + Vector3 pane = at + Vector3.forward * z + outward * .018f; + SidePanel(Coat(Paint.Glass), pane, along, side, .32f, .14f); + } for (int arm = -1; arm <= 1; arm += 2) { float mount = x + arm * 1.73f; @@ -223,12 +433,15 @@ namespace Soundings private void Rails(Vector2[] contour, float low, float high, float stride) { HarborMesh metal = Coat(Paint.Pearl); + float lower = low + .33f; + float upper = low + .55f; for (int i = 0; i < contour.Length; i++) { Vector2 a = contour[i]; Vector2 b = contour[(i + 1) % contour.Length]; - metal.Rod(HarborMesh.Point(a, high), HarborMesh.Point(b, high), .031f); - metal.Rod(HarborMesh.Point(a, (high + low) * .5f), HarborMesh.Point(b, (high + low) * .5f), .021f); + Coat(Paint.Teak).Rod(HarborMesh.Point(a, high), HarborMesh.Point(b, high), .036f); + metal.Rod(HarborMesh.Point(a, lower), HarborMesh.Point(b, lower), .018f, 4); + metal.Rod(HarborMesh.Point(a, upper), HarborMesh.Point(b, upper), .018f, 4); int studs = Mathf.Max(1, Mathf.CeilToInt(Vector2.Distance(a, b) / stride)); for (int stud = 0; stud < studs; stud++) { @@ -251,6 +464,26 @@ namespace Soundings private (float Length, float Beam, float Offset) DeckFootprint(int deck) => (DeckLength(length, deck), DeckHalfBeam(beam, deck), DeckOffset(length, deck)); + private static (Vector3 Position, Vector3 Along, Vector3 Outward) SideFrame(float station, float y, + float length, float halfBeam, float offset, int side, int samples) + { + float sample = station * samples; + int first = Mathf.Min(samples - 1, Mathf.FloorToInt(sample)); + float startWidth = SideWidth(first / (float)samples); + float endWidth = SideWidth((first + 1f) / samples); + float z = side * halfBeam * Mathf.Lerp(startWidth, endWidth, sample - first); + Vector3 along = new Vector3(length / samples, 0, side * halfBeam * (endWidth - startWidth)).normalized; + return (new Vector3(offset + (station - .5f) * length, y, z), along, + Vector3.Cross(along, Vector3.up) * side); + } + + private static void SidePanel(HarborMesh mesh, Vector3 center, Vector3 along, int side, float width, float height) + { + Vector3 across = along * (width * side * .5f); + Vector3 up = Vector3.up * (height * .5f); + mesh.Quad(center - across - up, center + across - up, center + across + up, center - across + up); + } + private static float SideWidth(float t) { if (t < .16f) @@ -260,9 +493,8 @@ namespace Soundings return Mathf.Cos(Mathf.Clamp01((t - .69f) / .31f) * Mathf.PI * .5f); } - private static Vector2[] Outline(float length, float beam, float x, float z = 0) + private static Vector2[] Outline(float length, float beam, float x, int intervals, float z = 0) { - const int intervals = 20; var outline = new Vector2[intervals * 2 + 1]; for (int i = 0; i < intervals; i++) { @@ -275,5 +507,24 @@ namespace Soundings outline[intervals] = new Vector2(length * .5f + x, z); return outline; } + + private static Vector2[] RoundedRectangle(Vector2 center, float halfLength, float halfWidth, float radius) + { + const int cornerPoints = 5; + var contour = new Vector2[4 * cornerPoints]; + for (int corner = 0; corner < 4; corner++) + { + float x = corner is 0 or 3 ? halfLength - radius : radius - halfLength; + float z = corner < 2 ? halfWidth - radius : radius - halfWidth; + Vector2 arcCenter = center + new Vector2(x, z); + for (int point = 0; point < cornerPoints; point++) + { + float angle = (corner + point / (float)(cornerPoints - 1)) * Mathf.PI * .5f; + contour[corner * cornerPoints + point] = + arcCenter + new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius; + } + } + return contour; + } } } diff --git a/Assets/Soundings/Runtime/VisualSmoke.cs b/Assets/Soundings/Runtime/VisualSmoke.cs index dd89193..ef15c8e 100644 --- a/Assets/Soundings/Runtime/VisualSmoke.cs +++ b/Assets/Soundings/Runtime/VisualSmoke.cs @@ -37,6 +37,23 @@ namespace Soundings || !CheckSmoke(Ship?.Name == "MV Meridian" && guideContext == GuideStep.SetCourse, "Guided used start")) yield break; yield return CaptureSmoke(directory, "02-harbor"); + float harborOverview = harbor.OrbitVerticalSpan; + Vector3 harborCenter = harbor.OrbitTarget; + harbor.Zoom(-90, new Vector2(.56f, .54f)); + yield return new WaitForSecondsRealtime(.65f); + if (!CheckSmoke(harbor.OrbitVerticalSpan < harborOverview * .22f && harbor.OrbitCameraIsClear + && Vector3.Distance(harborCenter, harbor.OrbitTarget) > 2f, "Harbor wheel reaches close inspection and follows the pointer")) + yield break; + harbor.Zoom(90); + yield return new WaitForSecondsRealtime(.65f); + if (!CheckSmoke(harbor.OrbitVerticalSpan > harborOverview * .97f + && Vector3.Distance(harborCenter, harbor.OrbitTarget) < .4f, "Zooming back out restores the harbor framing")) + yield break; + harbor.ResetView(true); + harbor.Zoom(-13, new Vector2(.49f, .56f)); + yield return new WaitForSecondsRealtime(.55f); + yield return CaptureSmoke(directory, "02a-harbor-close-up"); + harbor.ResetView(true); if (!SubmitSmoke("plan-voyage") || !CheckSmoke(page == 3 && destination == 1 && guideContext == GuideStep.Fare, "Set course and fare guide")) yield break; yield return CaptureSmoke(directory, "03-passage-chart"); @@ -105,6 +122,17 @@ namespace Soundings PresentVessel(.1f); } yield return CaptureSmoke(directory, "04-underway"); + float passageOverview = harbor.OrbitVerticalSpan; + harbor.Zoom(-90, new Vector2(.57f, .54f)); + yield return new WaitForSecondsRealtime(.65f); + if (!CheckSmoke(harbor.PassageUsesPerspective && harbor.OrbitCameraIsClear + && harbor.OrbitVerticalSpan < passageOverview * .22f, "Underway exterior zoom keeps a clear perspective view at deck level")) + yield break; + harbor.ResetView(true); + harbor.Zoom(-13, new Vector2(.46f, .57f)); + yield return new WaitForSecondsRealtime(.55f); + yield return CaptureSmoke(directory, "04b-underway-close-up"); + harbor.ResetView(true); harbor.RotateView(112f); yield return new WaitForSecondsRealtime(.38f); yield return CaptureSmoke(directory, "04a-underway-wake"); @@ -114,6 +142,16 @@ namespace Soundings if (!SubmitSmoke("passage-deck-1") || !CheckSmoke(passageDeck == 1, "Inspect the second guest deck")) yield break; yield return CaptureSmoke(directory, "06-guest-deck"); + float deckOverview = harbor.OrbitVerticalSpan; + harbor.Zoom(-90, new Vector2(.57f, .46f)); + yield return new WaitForSecondsRealtime(.65f); + if (!CheckSmoke(harbor.OrbitCameraIsClear && harbor.OrbitVerticalSpan < deckOverview * .22f, + "Cutaway zoom gives a clear view into individual rooms")) + yield break; + harbor.ResetView(true); + harbor.Zoom(-19, new Vector2(.43f, .49f)); + yield return new WaitForSecondsRealtime(.55f); + yield return CaptureSmoke(directory, "06-guest-deck-close-up"); if (!SubmitSmoke("passage-bridge") || !CheckSmoke(passageBridge && harbor.FirstPersonPositionIsClear, "Enter the first-person bridge")) yield break; yield return CaptureSmoke(directory, "06a-bridge"); @@ -326,6 +364,11 @@ namespace Soundings || !SubmitSmoke("passage-deck-7") || !CheckSmoke(passageDeck == 7, "Select the eighth deck during the voyage")) yield break; yield return CaptureSmoke(directory, "17-ocean-class-cutaway"); + harbor.Zoom(-90, new Vector2(.48f, .53f)); + yield return new WaitForSecondsRealtime(.65f); + if (!CheckSmoke(harbor.OrbitCameraIsClear && harbor.OrbitVerticalSpan < 12f, + "The eighth deck can also zoom to room scale without clipping")) + yield break; if (!SubmitSmoke("passage-explore") || !CheckSmoke(harbor.FirstPersonPositionIsClear, "Walk safely on the eighth deck")) yield break; Debug.Log($"Soundings player smoke passed at {Screen.width} × {Screen.height}."); diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 3f85562..f54374d 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -149,7 +149,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 0.6.0 + bundleVersion: 0.6.1 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/README.md b/README.md index 231edb7..61b8377 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The campaign has 22 ports. Start in Florida and the Caribbean, then extend your 1. Open this folder in Unity Hub with **Unity 6000.6.8f1**. 2. Open `Assets/Soundings/Scenes/Soundings.unity` and press Play. 3. Choose **Take the helm** to begin in Miami aboard MV Meridian. It has cabins, dining, entertainment, and enough fuel for Nassau. Choose **Start from the shipyard** to begin with a loan and commission your own ship. -4. In Harbor, drag to orbit the ship, scroll to zoom, or press **Home** to reset the camera. Choose **Set course** to review bookings, fuel and weather. Open **Port orders** to buy a specific quantity of food at the local rate or keep the recommended amount. Run the shipboard program, book local musicians, or contract a headline revue. +4. In Harbor, drag to orbit the ship, scroll over a part of the ship to zoom in on it, or press **Home** to reset the camera. Choose **Set course** to review bookings, fuel and weather. Open **Port orders** to buy a specific quantity of food at the local rate or keep the recommended amount. Run the shipboard program, book local musicians, or contract a headline revue. 5. Manage the ship during the crossing. Open **Onboard service** for happiness, health, cabin bookings, and service demand. Change prices, offer specials, and respond to events. The Logbook records the outcome at arrival. Use the hotbar or press **1** for Harbor, **2** for Chart, **3** for Deck Plans, **4** for Shipyard, and **5** for Logbook. Click a deck berth to place the selected facility, including bars and amenities. Each deck saves its own layout. Use **Fleet** to switch ships. In the Logbook, **Company accounts** opens the balance sheet and credit controls. Press **Esc** for the pause menu. @@ -20,7 +20,7 @@ The optional **First voyage guide** starts enabled for both careers. It highligh - For a multi-stop voyage, open **Itinerary** on the Chart and append connected ports in order. Each leg has its own forecast, local fuel and provisions, and arrival statement. After docking, choose **Plan next leg** in the Logbook to review and prepare for the next call. The ship's itinerary stays in the save at each berth. - Short routes take about two minutes at **1×**. Longer crossings take up to six minutes. Use **2×**, **4×**, or **Skip to arrival** to advance faster. Planning, the passage clock, and service activity pause together with **Esc**. -- Drag or use **Q/E** to orbit the ship. Scroll to zoom and press **Home** to reset the camera. Use **0** for the exterior and **1–8** to select available decks. +- Drag or use **Q/E** to orbit the ship. Scroll over a deck or room to inspect it up close, middle-drag to pan while zoomed in, and press **Home** to reset the camera. Use **0** for the exterior and **1–8** to select available decks. - Choose **Bridge** (**B**) for the forward view or **Explore** (**V**) to walk the selected deck. Walk with **WASD**, hold the right mouse button to look, or turn with **Q/E**. Walls and furniture block movement, and open doorways connect the rooms. **Service deck** opens the engine room, galley, stores, maintenance shop, freshwater plant, and sewage treatment. - Approach and face a counter, wheel, or working station and press **F** when the prompt appears. You can order extra meals, run happy hour, call a booked act early, help with cabin service, or operate machinery. The route bar shows timed crew calls and where to respond. Answered calls improve the guest survey and are recorded in the Logbook. - On the bridge, choose **Take the helm** (**H**). Use **A/D** for the rudder and **W/S** to step through throttle orders. The ship gathers speed, coasts, and takes time to turn. Press **H** again to resume autopilot. The exterior view lets you watch the ship respond while you steer.