A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: sea round 2, the far sea's texture, a surf line at every zoom and a wider beach (refs #388) (#402)
Eyal Golan57bf3b6bc2df
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 457db1ee7..bdd66ad3a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -195,6 +195,12 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB+0.9 ms at the gameplay zoom), not yet on an idle one.### Changed+- Sea round 2 (refs #388). The sea has texture at the gameplay and overview zooms, where it used to read as a flat+ surface: slow wind streaks, ripples from the waves' slope towards the camera (faded out as a pixel grows towards a+ wave's size), and sparse whitecaps on the streaks' bright side, close up only. All three sit behind a new `seatexture`+ visual toggle. The glint is stronger close up, the white surf line is at least 1.5 pixels wide at every zoom, the beach+ is wider (900 m) and paler, and the water's haze starts at 120 km, so the overview's sea pales towards the horizon. The+ water shader is the only shader changed. A slow pan and zoom at the overview showed no crawl.- Map: a boundary between two regions of the same border style (two Mandate sub-districts) draws one band of the promo'swidth, centred on the edge, instead of two full bands side by side; the Mandate frontier and a primary-secondary edgekeep the full band. Far off (a band under about 4 px, the overview) a band is a thin line of its colour, not a whitediff --git a/docs/visual-v1.md b/docs/visual-v1.mdindex 8be124a77..f90029e5d 100644--- a/docs/visual-v1.md+++ b/docs/visual-v1.md@@ -1378,6 +1378,117 @@ Water and shore together (the toggle now covers both):unmeasured.- diorama02: 0.13 ms, below the noise (spread 0.18 ms).- p95 is at or under 16.7 ms at both poses.++### Sea round 2 (branch `sea-round2`, refs #388)+At the gameplay and overview zooms the sea had faded to a smooth surface. The chop is gone by a 170 m pixel, and the+wave tilt and glint fade out by 120 m (Task 7, sea-fix), so gameplay03's 46 m pixels and diorama02's 190-300 m pixels saw+a flat gradient. Sea detail on main measured 0.013 against promo 03's 0.060, and 0.019 against promo 02's 0.063. Every+change is in `ScWaterShade` and `ScHazeWater` (`StatecraftMap.hlsl`), which only the water's own pass runs since #195,+plus `ScShore`'s two constants. `Sea.shader` is unchanged.+- **The far sea's texture**, all behind a new `seatexture` visual toggle (`_ScSeaTexture`), so the profile prices it as+ one feature:+ - wind streaks: a gradient-noise brightness variation (`ScMottleCellM` 2.5 km, 3x narrower across the wind, so 833 m+ there, with a finer octave of about 309 m, +-`ScMottleGain` 0.32) on the open Mediterranean, past the shallows, not on+ the rift lakes. Neither octave is faded by the footprint;+ - a ripple: the waves' slope towards or away from the camera, read as their sky reflection. Under a 50 m pixel it is+ +-0.54 (the tilted normal: swell and chop), faded out over 50-90 m; the 170 m chop's limit is 85 m. From 90 m it is+ +-0.28 (the 700 m swell's own slope), faded over 250-450 m. That leaves it at half strength at the swell's 350 m limit,+ and at 84-100% at diorama02's 190-300 m pixels (2.3-3.7 px a swell cell). It runs at 40% in the turquoise shallows,+ so they keep their pale band;+ - whitecaps: a fleck in some 120 m cells on the streaks' bright side, its brightness the share of the pixel it covers,+ gone by an 80 m pixel.+- **Glint:** 0.12 under a 40 m pixel, easing to Task 7's 0.06 by 60 m, so nothing changes from 60 m out.+- **Surf line:** the swash is never under 1.5 pixels wide (`max(ScSwashM, 1.5 x footprint)`). The breakers and their box+ filter are unchanged; at the breaker test's zoom the swash is still its own 180 m.+- **Beach:** `ScBeachM` from 650 to 900 m; `ScSandSrgb` (0.88, 0.76, 0.56) to (0.90, 0.80, 0.62), drier and paler.+- **Water haze:** the water's haze starts `ScWaterHazeLeadM` (80 km) nearer than the land's, at 120 km, so the+ overview's sea pales towards the horizon as promo 02's does. The gameplay zoom, under 100 km, has none.+- **The seam test** (reviewer-agreed option A). A 2.5 km streak pattern varies by itself between the seam test's points+ 5 km apart, so `TheSeaBeyondTheEdgeMatchesTheTerrainSea` pins `seatexture` off and keeps its bounds and cases. The new+ `SeaTests.TheFarSeaTextureHasNoStepAtTheMapEdge` checks the edge with the texture on. It renders the west edge straight+ down at the seam test's 110 m a pixel, over a 40 km strip, with the water's clock pinned, and runs two checks:+ - per row, the change between the two pixel columns either side of x = 0 against neighbouring columns elsewhere. The+ RMS excess at the edge must stay under 0.012;+ - the mean signed change across the edge, summed over r, g and b, must stay under 0.012.++ | run | RMS excess | mean change |+ |---|---|---|+ | green (final values) | -0.0032 | 0.0008 |+ | red: the skirt's map coordinates offset by one streak cell (a texture that does not continue; streaks at 0.25) | 0.101 | |+ | red: the skirt 4% brighter (an input step; streaks at 0.25) | | 0.0195 |++ Both red runs fail. Fitting a line to each side and extrapolating was tried first. Over the whole strip, a mismatched+ texture's steps cancel; per 880 m segment, the texture's own variation swamped the fit (0.049 with no seam, 0.059 with+ one).++- **`MapEdgeTests.PanningIntoACornerShowsNoSkirtSeamOrFlatFill` pins the water's clock.** It compares a render with the+ skirt against one without, and the water moved between the two. A few pixels of the north-west corner's coast changed at+ random: 0-14 a run, with the texture on or off, and main has the same exposure. The far sea's ripple made a failure+ likelier (5 and 1 pixels in two branch runs). Pinned, it passed 3 of 3 runs with 0 pixels at every corner.++Measured: WebGL `?shot` at main `db99f3a` (with towns round 2, land round 2 and #399's lighter far tilt-shift), then the+branch on it (art-log rows `main-db99f3a` and `sea-round2-r`). The sea crops are those of #388, plus gameplay03's focus+band (outside the tilt-shift's bands). Detail is the std of luma minus a 4 px blur, with the crop resized to 480 wide.+Spread is luma p90 - p10.++| | main | round 2 | promo | target |+|---|---|---|---|---|+| gameplay03 sea, #388 crop: detail / spread | 0.014 / 0.089 | **0.045** / **0.160** | 0.060 / 0.20 | >= 0.035 / >= 0.15 |+| gameplay03 sea, focus band: detail / spread | 0.017 / 0.088 | **0.055** / **0.185** | 0.075 / 0.32 | >= 0.035 / >= 0.15 |+| diorama02 sea: detail / spread | 0.019 / 0.038 | 0.026 / 0.069 | 0.063 / 0.11 | - / >= 0.07 |+| gameplay03 palette distance | 0.361 | **0.347** | - | no worse |+| diorama02 palette distance | 0.563 | **0.534** | - | no worse |+| diorama02 warmth / saturation | 0.109 / 0.406 | 0.111 / 0.400 | 0.145 / 0.43 | [0.087, 0.145] / <= 0.48 |++diorama02's spread misses its target by 0.001. Strengthening the streaks barely moves it (0.25 to 0.32 added 0.003). A+stronger far ripple could close it, but the far ripple already runs at 84-100% at diorama02, at 2.3-3.7 px a swell cell.+More contrast at that sampling would push it towards aliasing, so it was not raised. In the editor (web tier) the same+spread is 0.079. The sea's faint hex lines (`GridWaterOpacity` 0.10, a measured grid ruling) are harder to see against+the textured sea; that belongs to the grid, not here.++**In motion** (review of #402: the far ripple and the streaks' fine octave sit near or under their sampling limit at+diorama02). A temporary editor probe rendered diorama02 (web tier, tilt-shift on) during a slow pan (60 m east and 30 m+north a frame, about 0.25 px) and a slow zoom (0.25% a frame), 24 frames each, with the water's clock at 1/60 s a frame.+It was run for main `b10e95e`, the branch, and the branch with the far ripple faded over 175-350 m. For each 64 px+open-sea patch and each pair of consecutive frames, the patch's sub-pixel shift was found by phase correlation and taken+out. What remained was compared with the patch's fine texture (luma minus a 3 px blur):++| sea band | main: fine texture / residual | branch | branch, far ripple at 175-350 m |+|---|---|---|---|+| in focus (y 30-60%), pan / zoom | residual 38% / 38% of 1.0 level | 19% / 19% of 4.7 levels | 20% / 18% |+| far (y 13-30%, in the tilt-shift's band), pan / zoom | 0.35 level, residual 0.24 / 0.35 level | 0.60 level, residual 0.44 / 0.57 level | - |++In focus the texture moves coherently: its residual is half main's share, at far more texture. In the far band, which is+already blurred by the tilt-shift, what is left is under one 8-bit level, and so is its frame-to-frame change. Moving the+far ripple's fade to 175-350 m changes neither. No shimmer or crawl was found, so the tuning stays.+++Frame time on the rebased head, against main `db99f3a`: one interleaved round, headless, under the exclusive lock (load+about 5); three earlier rounds, before the rebase, agree:++| pose | `all` main / branch | `-water` main / branch | `-seatexture` (branch) | `none` main / branch | p95 `all` main / branch |+|---|---|---|---|---|---|+| gameplay03 | 8.04 / 8.23 | 7.86 / 7.99 | 8.17 | 5.27 / 5.48 | 13 / 13 |+| diorama02 | 19.94 / 18.72 | 19.41 / 18.94 | 18.73 | 12.66 / 12.35 | 22 / 21 |++The texture costs 0.06 ms at gameplay03 and nothing measurable at diorama02. gameplay03's `all` rises 0.19 ms, as does its+`none` (0.21 ms) with every feature off: build-to-build noise, not the water.++Boot (against `4abb64f`, before the rebase; the change adds no boot work): `headed.py boot --runs 3 --cpu 4`, 3 rounds+interleaved, 9 cold loads each, medians. Every phase but one equals main's (`biome texture baked` 433 / 436 ms, `kits built` 696 / 690, `terrain water` 20 / 20). `terrain heights set` is+1395 / 1471 ms: the wasm build's own tier-up draw (see "Issue #195": every build lands near 1390 or 1490 ms). That gives+`map_build_ms` 3063 / 3131 and `first_frame_ms` 10958 / 11010. The change adds no boot work beyond one shader global and+a toggle registration.+The goldens and the smoke run are unchanged: `GOLDEN OK 1950 71e9904d...`, `GOLDEN OK 1952 62f8ec61...` and+`SMOKE OK 5 turns 1948-06-19 d3fdd459...`. EditMode 747/747 on the merged head, with 0 `warning CS`.++Still different from the promo:+- promo 03's sea has boats and building shadows in its dark tail (out of scope: no civilian boats);+- promo 02's sea sparkles finely at the overview, where ours is held back from aliasing;+- the open sea's turquoise near the coast reads a little paler against the brighter, textured open sea at diorama02. The+ shallow-to-open gradient is unchanged (19 levels on both), and the turquoise thins slightly (g - r 43 to 40, 12-24 px+ from the coast).+## Promo track: land use (issue #33, branch promo-land)The flat mustard/olive ground becomes the promo's patchwork. `tools/land_bake.py` (no network, about 20 s, deterministic:`test_the_committed_textures_are_the_bake` checks the committed PNGs against a fresh bake) decides where from real datadiff --git a/unity/Assets/Scripts/Map/MapShaderGlobals.cs b/unity/Assets/Scripts/Map/MapShaderGlobals.csindex e35bf38d4..7fb6785a6 100644--- a/unity/Assets/Scripts/Map/MapShaderGlobals.cs+++ b/unity/Assets/Scripts/Map/MapShaderGlobals.cs@@ -11,7 +11,8 @@ namespace Statecraft.Game.Mappublic static readonly int Map = Shader.PropertyToID("_ScMap"), MapOrigin = Shader.PropertyToID("_ScMapOrigin"),Biome = Shader.PropertyToID("_ScBiomeTex"), Haze = Shader.PropertyToID("_ScHaze"), HazeWater = Shader.PropertyToID("_ScHazeWater"),HazeRange = Shader.PropertyToID("_ScHazeRange"), WaterOn = Shader.PropertyToID("_ScWaterOn"), Grid = Shader.PropertyToID("_ScGrid"),- WaterTime = Shader.PropertyToID("_ScWaterTime"), LandOn = Shader.PropertyToID("_ScLandOn");+ WaterTime = Shader.PropertyToID("_ScWaterTime"), LandOn = Shader.PropertyToID("_ScLandOn"),+ SeaTexture = Shader.PropertyToID("_ScSeaTexture");/// <summary>Pins the water's clock (waves, surf) to the given seconds, or back to Unity's time with null: for tests and/// frame captures that must render chosen moments (promo-sea review I2, M5).</summary>@@ -62,6 +63,10 @@ namespace Statecraft.Game.Mapassets.OnTeardown(VisualToggles.Register("land", on => Shader.SetGlobalFloat(LandOn, on ? 1f : 0f)));Shader.SetGlobalFloat(WaterOn, 1f);assets.OnTeardown(VisualToggles.Register("water", on => Shader.SetGlobalFloat(WaterOn, on ? 1f : 0f)));+ // The far sea's texture (sea round 2, #388: StatecraftMap.hlsl's mottle, ripple and whitecaps); its own toggle, so+ // the profile prices it and the seam test can pin it off.+ Shader.SetGlobalFloat(SeaTexture, 1f);+ assets.OnTeardown(VisualToggles.Register("seatexture", on => Shader.SetGlobalFloat(SeaTexture, on ? 1f : 0f)));assets.OnTeardown(VisualToggles.Register("haze", on =>{Shader.SetGlobalVector(Haze, on ? haze : new Vector4(haze.x, haze.y, haze.z, 0f));diff --git a/unity/Assets/Shaders/StatecraftMap.hlsl b/unity/Assets/Shaders/StatecraftMap.hlslindex 92e044c68..f76b93d54 100644--- a/unity/Assets/Shaders/StatecraftMap.hlsl+++ b/unity/Assets/Shaders/StatecraftMap.hlsl@@ -59,17 +59,20 @@ static const float ScRiftHazeBoost = 0.6;// Aerial perspective, 0..1 before each surface's strength: none within the start distance, then 1 - exp(-(d - start) /// scale), and up to 1.6x low in the rift. It is applied after lighting on both surfaces (review I2): land outputs BaseColor x (1 - h) plus Emission =// haze colour x h, so Lit's result is lerp(lit ground, haze, h); water lerps its final colour (ScHazeWater).-float ScHazeAmount(float3 positionWS)+float ScHazeAmount(float3 positionWS, float lead = 0.0){float dist = length(_WorldSpaceCameraPos - positionWS);- float aerial = 1.0 - exp(-max(dist - _ScHazeRange.w, 0.0) / max(_ScHazeRange.z, 1.0));+ float aerial = 1.0 - exp(-max(dist - (_ScHazeRange.w - lead), 0.0) / max(_ScHazeRange.z, 1.0));float low = saturate((_ScHazeRange.x - positionWS.y) / max(_ScHazeRange.x - _ScHazeRange.y, 1.0));return saturate(aerial * (1.0 + ScRiftHazeBoost * low));}+// Sea round 2 (#388, S4): the water's haze starts ScWaterHazeLeadM nearer than the land's (from 120 km, not 200 km), so+// the overview's sea pales towards the horizon as promo 02's does; the gameplay zoom (under 100 km) still has none.+static const float ScWaterHazeLeadM = 80000.0;float3 ScHazeWater(float3 colour, float3 positionWS){- return lerp(colour, _ScHazeWater.rgb, _ScHazeWater.a * ScHazeAmount(positionWS));+ return lerp(colour, _ScHazeWater.rgb, _ScHazeWater.a * ScHazeAmount(positionWS, ScWaterHazeLeadM));}// 1 in water, 0 on land; coast is the signed distance texture (0.5 at the shore, tools/terrain_bake.py).@@ -103,6 +106,27 @@ static const float ScWaveTilt = 0.6; // wave normal// frame at the gameplay pose's ~45 m pixels and 60 fps). coast.png's 94 m levels are interpolated linearly between// texels, so a crest can sit up to ~47 m off its true place: about one gameplay pixel, under the phase noise.static const float ScSwashM = 180.0, ScSurfM = 900.0, ScBreakerSpacingM = 300.0, ScBreakerRate = 0.05;+// Sea round 2 (#388): the far sea's texture, which promo 02 and 03 show at the gameplay and overview zooms where the waves+// above have faded to a smooth surface (sea detail 0.013 against promo 03's 0.060 at gameplay03, 0.019 against 0.063 at+// diorama02). Three terms, all behind the "seatexture" toggle (_ScSeaTexture), so the profile prices them together and+// the seam test (SettlementTests.TheSeaBeyondTheEdgeMatchesTheTerrainSea) pins them off; its step test+// (TheFarSeaTextureHasNoStepAtTheMapEdge) checks the edge with them on.+// - The mottle: wind streaks, a slow gradient-noise brightness variation, ScMottleCellM cells, 3x narrower across the+// wind (ScMottleStretch: 833 m), with a finer octave (2.7x: about 309 m), +-ScMottleGain, on the open Mediterranean (not+// the shallows, the surf or the rift lakes). It is what the overview sees. Neither octave is faded by the footprint.+// - The ripple: the waves' slope towards or away from the camera, as their sky reflection. Under a 50 m pixel it uses the+// tilted normal (swell and chop), +-ScRippleGain, faded out over 50-90 m (the 170 m chop's limit is 85 m). From 90 m it+// uses the 700 m swell's own slope, +-ScRippleFarGain, faded over 250-450 m, so it is still at half strength at the+// swell's 350 m limit, and at 84-100% at diorama02's 190-300 m pixels (2.3-3.7 px a swell cell).+// Review of #402: a slow pan and zoom at diorama02 (motion-compensated, against main) showed no crawl. In focus, the+// texture moves coherently (a residual of 19% of its fine texture; main 38%). In the far band, under the tilt-shift,+// what is left is under one 8-bit level.+// - Whitecaps: a fleck in some ScFleckCellM cells on the streaks' bright side (none in the troughs), its brightness the+// share of the pixel it covers; gone by an 80 m pixel.+float _ScSeaTexture; // 1 = on, 0 = off (the "seatexture" toggle)+static const float ScMottleCellM = 2500.0, ScMottleGain = 0.32, ScMottleStretch = 3.0;+static const float ScRippleGain = 0.54, ScRippleScale = 5.0, ScRippleFarGain = 0.28, ScRippleFarScale = 4.0;+static const float ScFleckCellM = 120.0, ScFleckM = 18.0, ScFleckShare = 0.22;// Antiderivative of tri(x)^2, tri(x) = 1 - |2 frac(x) - 1| (period 1, mean 1/3).float ScTriSqIntegral(float x)@@ -159,6 +183,7 @@ float3 ScWaterShade(float coast, float elevM, float3 positionWS, float2 mapM, fl// (on an axis-aligned lattice), whose slope jumped at every cell edge; ScWaveSlopeGain scales the smooth slope to the// old layers' strength.float2 g = ScWaveSlopeGain * ScWaveSlope(mapM, 700.0, 0.6, float2(0.05, 0.02), time);+ float2 swellSlope = g; // the far ripple's (sea round 2)// The chop: a 170 m layer turned -0.9 rad and moving the other way, full while a pixel covers under 40 m, gone by// 170 m (the gameplay pose sees it, the overview averages it away).float chop = 1.0 - smoothstep(40.0, 170.0, footprintM);@@ -184,19 +209,45 @@ float3 ScWaterShade(float coast, float elevM, float3 positionWS, float2 mapM, fl// view-dependent gradient that read as a seam between samples 5 km apart either side of the map's edge. The glint is// the near zoom's sparkle: it fades out between 60 and 120 m pixels, where the calmer far sea turned it back into that// smooth warm gradient (sea-fix: up to 0.016 between the seam test's +-2.5 km patches with the gradient-noise waves).- float glint = 0.06 * (1.0 - smoothstep(60.0, 120.0, footprintM));+ // Sea round 2: 0.12 under a 40 m pixel (the gameplay zoom's sparkle), easing to Task 7's 0.06 by 60 m, so nothing+ // changes from 60 m out (the seam test's 120 km view).+ float glint = lerp(0.12, 0.06, smoothstep(40.0, 60.0, footprintM)) * (1.0 - smoothstep(60.0, 120.0, footprintM));lit += pow(saturate(dot(reflect(-l, n), v)), 80.0) * glint * lc * shadow;+ // The far sea's texture (sea round 2, above): on open sea water only.+ float open = _ScSeaTexture * (1.0 - salt) * (1.0 - fresh);+ float2 viewXZ = normalize(v.xz + 1e-5);+ float nearRipple = 1.0 - smoothstep(50.0, 90.0, footprintM);+ float ripple = ScRippleGain * nearRipple * clamp(dot(n.xz, viewXZ) * ScRippleScale, -1.0, 1.0)+ + ScRippleFarGain * (1.0 - nearRipple) * (1.0 - smoothstep(250.0, 450.0, footprintM)) * clamp(dot(swellSlope, viewXZ) * ScRippleFarScale, -1.0, 1.0);+ float ms, mc; sincos(0.3, ms, mc);+ float2 mp = mapM / ScMottleCellM;+ mp = float2(mc * mp.x - ms * mp.y, (ms * mp.x + mc * mp.y) * ScMottleStretch); // streaks along the wind+ float mottle = ScGradientNoiseD(mp + float2(0.002, 0.001) * time).x + 0.8 * ScGradientNoiseD(mp * 2.7 + float2(5.3, 1.7)).x;+ mottle = clamp(mottle / 1.1, -1.0, 1.0);+ float offshore = smoothstep(0.0, shallowEdge, offshoreM); // 0 in the turquoise shallows, 1 past them+ mottle *= offshore;+ // The shallows keep promo 03's pale turquoise: the ripple runs at 40% there (at full it darkened the band at 25 km).+ lit *= 1.0 + open * (ripple * lerp(0.4, 1.0, offshore) + ScMottleGain * mottle);+ float2 cell = floor(mapM / ScFleckCellM);+ float2 at = (cell + 0.35 + 0.3 * float2(ScHash(cell + 3.7), ScHash(cell + 9.1))) * ScFleckCellM;+ float reach = max(ScFleckM, 0.6 * footprintM);+ float fleck = step(ScHash(cell + 17.1), ScFleckShare * saturate(mottle * 1.5)) * (ScFleckM * ScFleckM) / (reach * reach)+ * (1.0 - smoothstep(0.5 * reach, reach, length(mapM - at)))+ * (1.0 - smoothstep(40.0, 80.0, footprintM)) * smoothstep(300.0, 900.0, offshoreM) * open;+// Surf: the swash line, then breakers (crests every ScBreakerSpacingM, rolling in: the phase grows with time towards// the shore; box-filtered over ScBreakers' width) whose crests break up along the coast (a 300 m noise, faded to its mean once a// pixel covers 75-150 m). Neither on the Dead Sea, which keeps its salt rim.- float swash = 1.0 - smoothstep(ScSwashM, ScSwashM * 1.8, offshoreM);+ // Sea round 2: the swash line is never under 1.5 pixels wide, so the white rim reads at the overview as well.+ float swashM = max(ScSwashM, 1.5 * footprintM);+ float swash = 1.0 - smoothstep(swashM, swashM * 1.8, offshoreM);float zone = 1.0 - smoothstep(ScSwashM, ScSurfM, offshoreM);float crest = ScTriSqBox(breakers.x, breakers.y);float broken = smoothstep(0.3, 0.7, ScNoise(mapM / 300.0 + float2(0.0, time * 0.02)));broken = lerp(0.5, broken, 1.0 - smoothstep(75.0, 150.0, footprintM));float rim = salt * (1.0 - smoothstep(0.0, 900.0, offshoreM));- float foam = saturate((swash * (0.8 + 0.2 * broken) + zone * crest * broken) * (1.0 - salt) + rim);+ float foam = saturate((swash * (0.8 + 0.2 * broken) + zone * crest * broken) * (1.0 - salt) + rim + fleck);return lerp(lit, SRGBToLinear(float3(0.93, 0.95, 0.94)), foam * 0.85);}@@ -206,8 +257,8 @@ float3 ScWaterShade(float coast, float elevM, float3 positionWS, float2 mapM, fl// Dead Sea (below -300 m). Both thresholds are 20 m ramps, so a shore slope crossing one leaves no hard contour. Steep// faces (the Carmel's and the kurkar cliffs) keep their rock. Off with the "water" toggle (so its cost is in the// toggle's).-static const float ScBeachM = 650.0;-static const float3 ScSandSrgb = float3(0.88, 0.76, 0.56), ScSaltSrgb = float3(0.92, 0.90, 0.85);+static const float ScBeachM = 900.0; // sea round 2 (#388): 650 m in promo-sea; promo 03's beach reads wider+static const float3 ScSandSrgb = float3(0.90, 0.80, 0.62), ScSaltSrgb = float3(0.92, 0.90, 0.85); // sea round 2: drier, palerfloat3 ScShore(float3 ground, float coast, float elevM, float3 n, float2 mapM){if (_ScWaterOn < 0.5) return ground;diff --git a/unity/Assets/Tests/EditMode/MapEdgeTests.cs b/unity/Assets/Tests/EditMode/MapEdgeTests.csindex a144f944a..c67aedaae 100644--- a/unity/Assets/Tests/EditMode/MapEdgeTests.cs+++ b/unity/Assets/Tests/EditMode/MapEdgeTests.cs@@ -42,6 +42,10 @@ public class MapEdgeTestsvar rt = new RenderTexture(W, H, 24);Directory.CreateDirectory(ShotDir);RenderSample.TiltShift(false); // a colour test: the blur spreads pixels across the frame+ // The water moves between the renders compared below (waves, breakers and, since sea round 2, the far sea's ripple),+ // which changed a few pixels of the north-west corner's coast at random (0-14 a run, skirt or not): its clock is+ // pinned, so the comparison sees only the skirt.+ MapShaderGlobals.PinWaterTime(100f);try{cam.targetTexture = rt; // the clamp measures the view at the render's aspect@@ -85,7 +89,7 @@ public class MapEdgeTests}finally{- RenderSample.TiltShift(true);+ RenderSample.TiltShift(true); MapShaderGlobals.PinWaterTime(null);skirt.enabled = true; map.Terrain.enabled = true;cam.targetTexture = null; rt.Release(); Object.DestroyImmediate(rt);}diff --git a/unity/Assets/Tests/EditMode/SeaTests.cs b/unity/Assets/Tests/EditMode/SeaTests.csindex 5a31cb9cc..822d45076 100644--- a/unity/Assets/Tests/EditMode/SeaTests.cs+++ b/unity/Assets/Tests/EditMode/SeaTests.cs@@ -458,6 +458,78 @@ public class SeaTestsfinally { Object.DestroyImmediate(go); }}+ /// <summary>Sea round 2 (#388): the far sea's texture (the "seatexture" toggle: StatecraftMap.hlsl's mottle, ripple and+ /// whitecaps) leaves no step where the terrain's water meets the skirt's sea at the map's west edge. The seam test+ /// (SettlementTests.TheSeaBeyondTheEdgeMatchesTheTerrainSea) compares points 5 km apart, across which a 2.5 km mottle+ /// varies by itself, so it pins the texture off; this one looks for a step, not a difference. Rendered straight down+ /// (orthographic) at the seam test's pixel size (110 m, so the ripple and whitecaps have faded and the mottle is what+ /// is on), over a 40 km strip of the edge with the water's clock pinned. Per row, the change between the two pixel+ /// columns either side of x = 0 is compared with the change between neighbouring columns elsewhere in the strip: the+ /// RMS across the edge may exceed the RMS elsewhere by at most the seam test's own pre-grade bound (0.012), which catches+ /// a texture that does not continue; and the mean change across the edge, summed over r, g and b, stays under the same+ /// bound, which catches a uniform step (an RMS adds a uniform step in quadrature with the texture's own change). (Fitting a+ /// line either side and extrapolating was tried: over the whole strip a mismatched texture's steps cancel, and per+ /// 880 m segment the texture's own variation swamped the fit, 0.049 with no seam against 0.059 with one.) The grade+ /// is a per-pixel LUT, so it can+ /// scale a step but not make one (the seam test's argument), and this test's own camera renders without it. The+ /// texture must be there to be tested: the strip's luma varies more with it on than off.</summary>+ [UnityTest]+ public IEnumerator TheFarSeaTextureHasNoStepAtTheMapEdge()+ {+ var map = OpenMap();+ yield return null;+ VisualToggles.Set("grid", false);+ MapShaderGlobals.PinWaterTime(100f);+ var size = map.Terrain.terrainData.size; var origin = map.Terrain.transform.position;+ const int w = 64, h = 364; const float metresPerPixel = 110f;+ var go = new GameObject("TopEdge"); var cam = go.AddComponent<Camera>();+ try+ {+ cam.orthographic = true; cam.orthographicSize = h * metresPerPixel / 2f; cam.aspect = (float)w / h;+ // Centred on the west edge (map x = 0), so the edge falls on the boundary between columns w/2 - 1 and w/2.+ cam.transform.position = new Vector3(origin.x, 20000f, origin.z + 0.55f * size.z); cam.transform.rotation = Quaternion.Euler(90, 0, 0);+ cam.nearClipPlane = 100f; cam.farClipPlane = 60000f;+ float Std(RenderSample r)+ {+ double sum = 0, sq = 0; int k = 0;+ for (int j = 0; j < h; j++) for (int i = 0; i < w; i++) { double l = Luma(r.At(i, j)); sum += l; sq += l * l; k++; }+ return (float)System.Math.Sqrt(sq / k - (sum / k) * (sum / k));+ }+ VisualToggles.Set("seatexture", false);+ float plain = Std(RenderSample.Render(cam, w, h));+ VisualToggles.Set("seatexture", true);+ var r = RenderSample.Render(cam, w, h);+ float textured = Std(r);+ // The change between neighbouring pixel columns, |dr| + |dg| + |db| per row: across the edge (columns w/2 - 1+ // and w/2, each 110 m wide, one either side of x = 0) and, as the control, between neighbours 4-12 columns out on+ // either side, inside one mesh. A continuous texture changes as little across the edge as anywhere else; a+ // mismatched one (or a step in the inputs) changes there by about its whole range. The RMS over the rows at the+ // edge may exceed the control's by at most the seam test's bound.+ double Pair(int i, int j) { var a = r.At(i, j); var b = r.At(i + 1, j); return Mathf.Abs(a.r - b.r) + Mathf.Abs(a.g - b.g) + Mathf.Abs(a.b - b.b); }+ double edgeSq = 0, controlSq = 0; int controlN = 0;+ var signedEdge = Vector3.zero; // the mean change across the edge per channel: a uniform step (an input mismatch)+ for (int j = 0; j < h; j++)+ {+ double e = Pair(w / 2 - 1, j); edgeSq += e * e;+ var ea = r.At(w / 2 - 1, j); var eb = r.At(w / 2, j); signedEdge += new Vector3(eb.r - ea.r, eb.g - ea.g, eb.b - ea.b) / h;+ for (int k = 4; k <= 12; k++)+ {+ double c1 = Pair(w / 2 - 1 - k, j), c2 = Pair(w / 2 - 1 + k, j);+ controlSq += c1 * c1 + c2 * c2; controlN += 2;+ }+ }+ float edgeRms = (float)System.Math.Sqrt(edgeSq / h), controlRms = (float)System.Math.Sqrt(controlSq / controlN);+ float step = edgeRms - controlRms;+ float offset = Mathf.Abs(signedEdge.x) + Mathf.Abs(signedEdge.y) + Mathf.Abs(signedEdge.z);+ const float bound = 0.012f;+ TestContext.WriteLine($"neighbour change: across the edge RMS {edgeRms:0.0000}, elsewhere {controlRms:0.0000}, excess {step:0.0000}; mean change across the edge {offset:0.0000} (bound {bound} each); strip luma std {textured:0.0000} with the texture, {plain:0.0000} without");+ Assert.Greater(textured, plain + 0.004f, "the far sea's texture shows at 110 m a pixel");+ Assert.Less(step, bound, "the texture does not continue across the edge (a mismatch between the terrain's water and the skirt's sea)");+ Assert.Less(offset, bound, "a uniform step where the terrain's water meets the skirt's sea");+ }+ finally { Object.DestroyImmediate(go); }+ }+/// <summary>Issue #195 review: the terrain water's depth pull follows an orthographic camera's parallel rays. Pulled/// towards the camera's position instead, the water slid towards the view's axis, and the terrain's black water showed/// between it and the shore. Straight down over the coast south of Tel Aviv, 30 km across with the axis 12 km offshore,diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs b/unity/Assets/Tests/EditMode/SettlementTests.csindex 6d8265aab..fe7f86a40 100644--- a/unity/Assets/Tests/EditMode/SettlementTests.cs+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs@@ -420,6 +420,9 @@ public class MapSceneTests// frame against 0.024 (the grade scales the sea's chroma by about 2). Tilt-shift off: a colour test whose close// strips lie in the blurred bands at some yaws (task-3 carry m6).RenderSample.TiltShift(false);+ // Sea round 2 (#388): the far sea's texture (a 2.5 km mottle) varies by itself between points 5 km apart, so it+ // is off here; SeaTests.TheFarSeaTextureHasNoStepAtTheMapEdge checks the edge with it on, as a step.+ VisualToggles.Set("seatexture", false);foreach (var graded in new[] { false, true })foreach (var grid in new[] { false, true }){@@ -453,7 +456,7 @@ public class MapSceneTests}}}- finally { VisualToggles.Set("grid", true); VisualToggles.Set("grade", true); RenderSample.TiltShift(true); }+ finally { VisualToggles.Set("grid", true); VisualToggles.Set("grade", true); VisualToggles.Set("seatexture", true); RenderSample.TiltShift(true); }}/// <summary>Playtest 1, item 3: with the top bar covering the top <c>TopInset</c> of the screen, the look-at point is