A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: the surf towards promo 03's lace, a wider surf zone and a lace net behind a foam toggle (refs #388) (#660)
Eyal Golan988ad4177a45
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0fffb57b7..1b8ce77a9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -440,6 +440,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB~30, wider blocks"; every other town's floor stays. All of it is in Tel Aviv's own kit mesh (no new draw), so a model thatreplaces the town (#507) hides it whole. Haifa's Hadar keeps its blocks, and `Kit.shader` is not changed. Presentationonly.+- Sea round 3, the surf towards lace (refs #388): beyond the swash line, at least one broken white breaker now stands+ clear in the surf at the gameplay zoom, where there was one swash line and a smooth band (promo 03 shows 2-4 broken+ lines; that gap is read again after #519's grade). The surf zone widens from 900 m to 1.8 km, the breakers stand 450 m+ apart (300 m before) and the foam is whiter; a 200 m lace net, behind a new `foam` toggle, breaks each crest on its own+ and fades to the old mean at the overview. All of it is in the water's own pass; the terrain function is unchanged.- The map's region files (the 1948 sub-districts, the 1949 armistice lines, the 1948-49 control areas) are readfrom baked runtime forms at boot instead of being parsed as YAML (`tools/regions_bake.py`, refs #321), as thelocalities and the route paths are. The sub-districts are read once, for the camps and the region layers. A stale,diff --git a/docs/visual-v1.md b/docs/visual-v1.mdindex 4549f48e5..91bd25301 100644--- a/docs/visual-v1.md+++ b/docs/visual-v1.md@@ -1343,16 +1343,18 @@ Review round 1 (staff review I1-I2, M1-M8) is folded in; the values below are thbudget (0.89 / 0.13 ms in promo-sea round 1); p95 with everything on is 10 / 14 ms, under 16.7 ms.- **Surf** (review I2).- A swash line, full to `ScSwashM` 180 m and gone by 324 m.- - Breakers through a `ScSurfM` 900 m zone. They are a squared triangle wave in the distance from the shore, spacing- `ScBreakerSpacingM` 300 m, rolling shoreward at `ScBreakerRate` 0.05 cycles/s (15 m/s, a quarter pixel a frame at- gameplay03 and 60 fps).+ - Breakers through a `ScSurfM` zone (900 m here; 1.8 km since sea round 3). They are a squared triangle wave in the+ distance from the shore, spacing `ScBreakerSpacingM` (300 m here; 450 m since sea round 3), rolling shoreward at+ `ScBreakerRate` 0.05 cycles/s (15 m/s here, a quarter pixel a frame at gameplay03 and 60 fps; 22.5 m/s, about half a+ pixel, since sea round 3).- The breakers are box-filtered in closed form (`ScTriSqBox`), so they never alias and tend to their mean (1/3) as thepixel grows. The previous `pow(tri, 5)` crest was about 21 m wide on 45 m pixels: hairline, dashed crests.- The box is `fwidth(phase)` x `ScBreakerFilterPx` 1.25, with the phase taken by `ScBreakers` outside the water branchin both callers (re-review N2). The phase's true gradient is not 1 / 300 m: its noise term adds up to 0.0025cycles/m and the 8-bit coast's slope varies up to 2x, so a width from the nominal spacing was up to 2x too narrow inplaces.- - The 300 m break-up noise fades to its mean between 75 and 150 m pixels.+ - The 300 m break-up noise fades to its mean between 75 and 150 m pixels. Since sea round 3, the `foam` toggle swaps+ it for a 200 m lace net at the gameplay zoom (below).- **Beach** (`ScShore`).- A sand strip along every sea-level coast (above -100 m): the Mediterranean and the Gulf of Eilat, both sand beaches,but not the rift lakes. `ScBeachM` is 650 m on average, +-40% on a 4 km noise. The width is symbolic, after the@@ -1715,6 +1717,28 @@ Boot (`headed.py boot --cpu 4 --runs 3`, one round each, before the rebase): mapon the branch, and `kits built` 828 against 785 ms in the last run. The branch is not slower: the boats' placement andone more mesh are not measurable against the run-to-run spread.+### Sea round 3: the surf as lace (branch `visual/c1-foam-lace`, refs #388)+Plan C1 part 2 (`.superpowers/plan-C1-beach.md`). The 2026-10-15 audit still saw one swash line and a smooth turquoise+band where promo 03 has 2-4 broken white lines. Everything is in the water's own pass (`ScWaterShade`); the terrain+function is unchanged.+- **Constants:** `ScSurfM` 900 m to 1.8 km, `ScBreakerSpacingM` 300 to 450 m (`ScBreakerRate` kept, so 22.5 m/s), and+ `ScFoamWhite` 0.95 (0.85 before) on the foam's lerp to white.+- **The `foam` toggle** (`_ScSeaFoam`, `MapShaderGlobals`): a 200 m value-noise net, kept under 0.62 with a fixed 0.25+ edge, replaces `broken` so each crest breaks on its own (one 300 m blob of `broken` covered two crests 450 m apart).+ - A footprint-scaled edge aliased: `TheBreakersAreFilteredToThePixel` p99 0.067 at 140 m. The fixed edge keeps it+ at 0.0113 against the unchanged 0.014 bound.+ - The net's mean is 0.676 against `broken`'s 0.5, so the breakers carry about 35% more foam at the gameplay zoom. Both+ fade to 0.5 at 75-150 m pixels, so the overview is unchanged and zooming out through that range dims the breakers+ by about a quarter.+- **Test:** `SeaTests.TheSurfShowsABrokenBreakerBeyondTheSwashAtTheGameplayZoom` guarantees the swash and at least one+ breaker past it, at 3 of 4 moments, west of Tel Aviv and south of Jaffa, with a foam share in [0.3, 0.7]. Promo 03's+ 2-4 lines are not yet met; they are read again after #519's grade.+- **Profile** (`?vprofile` headless, 1920x1080, exclusive lock, against main e6f98962): gameplay03 `all` 8.52 ms,+ `-foam` 8.48 (foam 0.04 ms, budget 0.5), `none` 7.41 (main 7.47), p95 11 (main 11); diorama02 `all` 16.47, `-foam`+ 16.52, p95 18 (main 18).+- **Bands** (gameplay03 `?shot`, south of Jaffa, before #519): foam band 9.0 to 20.6 px (promo 44, band 25-55), foam+ share 0.59 to 0.48 (promo 0.54), the strict lace-line median still 1 (promo 2); north foam 5.8 to 13.0 px.+## 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 d9459b937..222640826 100644--- a/unity/Assets/Scripts/Map/MapShaderGlobals.cs+++ b/unity/Assets/Scripts/Map/MapShaderGlobals.cs@@ -12,7 +12,8 @@ namespace Statecraft.Game.MapBiome = 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"),- SeaTexture = Shader.PropertyToID("_ScSeaTexture"), SeaCalm = Shader.PropertyToID("_ScSeaCalm");+ SeaTexture = Shader.PropertyToID("_ScSeaTexture"), SeaCalm = Shader.PropertyToID("_ScSeaCalm"),+ SeaFoam = Shader.PropertyToID("_ScSeaFoam");/// <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>@@ -71,6 +72,9 @@ namespace Statecraft.Game.Map// shelf at the overview; its own toggle, so the profile prices it and the tests can compare with it off.Shader.SetGlobalFloat(SeaCalm, 1f);assets.OnTeardown(VisualToggles.Register("seacalm", on => Shader.SetGlobalFloat(SeaCalm, on ? 1f : 0f)));+ // Sea round 3 (#388, StatecraftMap.hlsl): the surf's lace net; its own toggle, so the profile prices it.+ Shader.SetGlobalFloat(SeaFoam, 1f);+ assets.OnTeardown(VisualToggles.Register("foam", on => Shader.SetGlobalFloat(SeaFoam, 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 82cd3aea0..7b273847c 100644--- a/unity/Assets/Shaders/StatecraftMap.hlsl+++ b/unity/Assets/Shaders/StatecraftMap.hlsl@@ -102,10 +102,29 @@ static const float ScWaveTilt = 0.6; // wave normal// The surf: a swash line along the sand (full to ScSwashM) and breakers rolling shoreward through the surf zone// (ScSurfM), broken along the shore by noise. The breakers are a squared triangle wave in the distance from the shore,// box-filtered over the pixel's footprint in closed form, so they never alias and tend to their mean (1/3) as the pixel-// grows; ScBreakerRate cycles per second roll them in at ScBreakerSpacingM x ScBreakerRate = 15 m/s (a quarter pixel per+// grows; ScBreakerRate cycles per second roll them in at ScBreakerSpacingM x ScBreakerRate = 22.5 m/s (half a pixel per// 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 3 (#388): towards promo 03's lace (2-4 broken white lines over the turquoise; SeaTests guarantees the swash+// and at least one breaker, the rest waits for #519's grade). The surf zone from 900 to 1800 m (the+// promo's 29-52 px foam band at gameplay03's ~45 m pixels; at 1500 m the second crest faded under the foam's white before+// it reached the turquoise), the crests from 300 to 450 m apart (about 10 px, so they stand clear of each other;+// ScBreakerRate kept, so they roll in at 22.5 m/s, about half a pixel a frame), and the foam whiter (ScFoamWhite, 0.85+// before: the crests read turquoise-tinted).+// The lace (the "foam" toggle, _ScSeaFoam): the constants alone left whole crests out where the 300 m "broken" noise was+// low, since one blob of it covers two crests 450 m apart (SeaTests.TheSurfShowsABrokenBreakerBeyondTheSwashAtTheGameplayZoom+// at 31.95 N).+// With the toggle on, a finer net (ScLaceCellM cells, kept where it is under ScLaceCover) breaks each crest on its own.+// Its edge is a fixed ScLaceEdge wide in noise units, not the pixel's footprint: an edge that sharpens with resolution+// changes the net's mean between a pixel and its sub-pixels, and TheBreakersAreFilteredToThePixel saw it (p99 0.067 at a+// 140 m net with a footprint edge); a 200 m net with a 0.25 edge stays smooth over a 45 m pixel. The net keeps more than+// "broken" does: its mean is 0.676 (2M samples of ScNoise; P(noise < 0.62) = 0.69), "broken"'s 0.5, so the breakers+// carry about 35% more foam on average at the gameplay zoom. Like "broken", it fades to 0.5 at 75-150 m pixels, so the+// overview's mean foam is unchanged, and zooming out through that range dims the breakers by about a quarter+// (independent review of #660; kept rather than re-centred, which would change the overview).+float _ScSeaFoam; // 1 = on, 0 = off (the "foam" toggle)+static const float ScSwashM = 180.0, ScSurfM = 1800.0, ScBreakerSpacingM = 450.0, ScBreakerRate = 0.05, ScFoamWhite = 0.95;+static const float ScLaceCellM = 200.0, ScLaceCover = 0.62, ScLaceEdge = 0.25;// 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@@ -285,10 +304,13 @@ float3 ScWaterShade(float coast, float elevM, float3 positionWS, float2 mapM, flfloat 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)));+ float lace = ScNoise(mapM / ScLaceCellM + float2(5.1, 2.3) + float2(time * 0.03, 0.0));+ lace = 1.0 - smoothstep(ScLaceCover - ScLaceEdge, ScLaceCover + ScLaceEdge, lace); // kept where the net is under ScLaceCover+ broken = lerp(broken, lace, _ScSeaFoam);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 + fleck);- return lerp(lit, SRGBToLinear(float3(0.93, 0.95, 0.94)), foam * 0.85);+ return lerp(lit, SRGBToLinear(float3(0.93, 0.95, 0.94)), foam * ScFoamWhite);}// The shore on land (promo-sea): a sand strip along every sea-level coast (above -100 m: the Mediterranean and the Gulfdiff --git a/unity/Assets/Tests/EditMode/SeaTests.cs b/unity/Assets/Tests/EditMode/SeaTests.csindex d236dc72b..9b70705ae 100644--- a/unity/Assets/Tests/EditMode/SeaTests.cs+++ b/unity/Assets/Tests/EditMode/SeaTests.cs@@ -293,6 +293,71 @@ public class SeaTestsvar w = map.Frame.ToWorld(lon, lat, 0); w.y = map.Terrain.SampleHeight(w); return w;}+ /// <summary>Sea round 3 (#388): beyond the swash line, a broken white breaker stands clear in the surf at the gameplay+ /// zoom, and the surf is lace, not a solid band. What this guarantees is the swash plus at least one breaker; promo 03+ /// shows 2-4 broken lines, and that gap stays open until #519's grade is in. At TheBreakersAreFilteredToThePixel's pose+ /// (30 km at 960x540: about 45 m a pixel, as gameplay03), the water's clock pinned at four moments of a breaker cycle, a+ /// one-pixel line is walked across the coast from the shore out to 1.8 km, west of Tel Aviv (32.08 N) and south of Jaffa+ /// (31.95 N). A pixel is foam when its luma is at least 0.72 and its channels lie within 30/255 (white, not turquoise),+ /// and a line is a run of at least 2 foam pixels; the run that starts at the shore is the swash and is not counted as a+ /// breaker. On each line at 3 or more of the 4 moments: at least one breaker past the swash, and the median foam share+ /// of the stretch from the farthest foam pixel to the shore is within <see cref="LaceShare"/>. 3 of 4, not 4 of 4: the+ /// branch shows a breaker at all 4 moments, but at 32.08 N, t=110 it is 2 px wide, exactly the run minimum (the others+ /// are 4-9 px), so one moment may read as none on another GPU; main shows one at only 2 of the 4.</summary>+ [UnityTest]+ public IEnumerator TheSurfShowsABrokenBreakerBeyondTheSwashAtTheGameplayZoom()+ {+ var map = OpenMap();+ yield return null;+ VisualToggles.Set("grid", false);+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ var log = new System.Text.StringBuilder();+ foreach (var lat in new[] { 32.08f, 31.95f })+ {+ var (col, row) = ShoreTexel(lat);+ const float texelM = 161529f / 2048f; // a coast.png texel east-west+ Vector3 shore = TexelWorld(map, col, row), reach = TexelWorld(map, col - Mathf.RoundToInt(1800f / texelM), row);+ rig.LookAt = reach; rig.Distance = 30000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ int laced = 0; var shares = new System.Collections.Generic.List<float>();+ foreach (var t in new[] { 100f, 105f, 110f, 115f })+ {+ MapShaderGlobals.PinWaterTime(t);+ var px = new Vector2[2];+ var r = RenderSample.Render(cam, 960, 540, new[] { shore, reach }, px);+ int n = Mathf.CeilToInt(Mathf.Max(Mathf.Abs(px[1].x - px[0].x), Mathf.Abs(px[1].y - px[0].y)));+ var foam = new bool[n + 1]; // index 0 at the shore+ var trace = new System.Text.StringBuilder();+ for (int k = 0; k <= n; k++)+ {+ var p = Vector2.Lerp(px[0], px[1], k / (float)n);+ var c = r.At(Mathf.RoundToInt(p.x), Mathf.RoundToInt(p.y));+ foam[k] = Luma(c) >= 0.72f && Mathf.Max(c.r, c.g, c.b) - Mathf.Min(c.r, c.g, c.b) <= 30f / 255f;+ trace.Append(foam[k] ? '#' : '.');+ }+ int far = System.Array.LastIndexOf(foam, true), breakers = 0, run = 0, on = 0;+ for (int k = 0; k <= far + 1; k++)+ {+ if (k <= far && foam[k]) { run++; on++; }+ else { if (run >= 2 && k - run > 0) breakers++; run = 0; } // a run from index 0 is the swash+ }+ float share = far >= 0 ? on / (float)(far + 1) : 0f;+ if (breakers >= 1) laced++;+ shares.Add(share);+ log.AppendLine($"{lat:0.00} N t={t}: swash {(foam[0] ? "yes" : "no")}, {breakers} breakers past it, share {share:0.00} {trace}");+ }+ shares.Sort();+ float median = 0.5f * (shares[1] + shares[2]);+ TestContext.WriteLine(log.ToString());+ Assert.GreaterOrEqual(laced, 3, $"{lat} N: a breaker past the swash at 3 of the 4 moments");+ Assert.That(median, Is.InRange(LaceShare.x, LaceShare.y), $"{lat} N: the surf is lace, not a solid band");+ }+ }++ /// <summary>TheSurfShowsABrokenBreakerBeyondTheSwashAtTheGameplayZoom's foam share band (promo 03 south of Jaffa: a median+ /// share of 0.56, plan C1). The branch's median at 32.08 N is 0.67, close to the upper bound: another GPU or driver may+ /// read it a little differently.</summary>+ static readonly Vector2 LaceShare = new Vector2(0.3f, 0.7f);+/// <summary>promo-sea review I2 / M5 / N1: the breakers are box-filtered over the pixel, so they never alias. Around/// the surf zone west of Tel Aviv, at the gameplay footprint (30 km at 960x540: about 45 m a pixel, the same as/// gameplay03's 60 km at 1920x1080), where an unfiltered crest is sub-pixel but not yet faded, every water pixel of a