A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
merge: visual v1 track B (ground and water)
eyalgoland5037af8e709
diff --cc docs/visual-v1.mdindex f5f52f538,6ad56fac8..97c115cd9--- a/docs/visual-v1.md+++ b/docs/visual-v1.md@@@ -105,292 -77,174 +105,459 @@@ Notes- Superseded first recording (commit `33fb072`, before the CDP viewport): headless ran at `res=1920x937` and headed at`res=1728x860`, with a first-pose spread of 0.68 ms (headless) and one headed run that stalled; do not compare with it.+## Task 2: sun and shadows+Headless, viewport 1920x1080 at DPR 1 (`res=1920x1080 scale=0.80`), web tier (shadow map 2048, one cascade, cascade+border 0.1).++**Shadow fit (fix round 1, review I1).** URP fades shadows by straight-line distance from the camera, from+(1 - cascadeBorder) x shadowDistance out (URP 17.3 `Shadows.hlsl`, `ShadowUtils.GetScaleAndBiasForLinearDistanceFade`).+The first delivery fitted 1.75 x the rig distance from *view depth*, which left the top corners partly or wholly faded+(about 76% faded on the web tier at a 0.08 top inset). `ShadowFit` now takes, on every rig `Apply`, the farthest+straight-line distance from the camera to the ground hits of the four viewport corners (the current aspect and top inset+included; ground plane y = 0, the terrain's lowest point, so the fit is never short) and divides it by+(1 - cascadeBorder). It clamps to 3 km .. 1,000 km (the far clip). `LightingTests.TheShadowDistanceCoversTheWholeView`+checks 6/45/120/250 km x 16:9, 21:9, 4:3 x top insets 0, 0.08, 0.3, 0.5 x borders 0.1 and 0.2.++**Decision: web-tier cascade border 0.2 -> 0.1** (`Mobile_RPAsset` `m_CascadeBorder`). With one cascade, the border is+the fade band at the edge of the fitted range. A tenth keeps the fade off-screen while spending less of the 2048 map past+the view (the fitted distance is 1/0.9 rather than 1/0.8 of the farthest corner). PC keeps 0.108 (4 cascades).++| Run | Lines |+|---|---|+| headless, first delivery (`8b20507`, 1.75 x D view-depth fit, border 0.2) | `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.11 spread_ms=0.10 median_p95_ms=3.00`<br>`PROFILE summary visual=-shadows pose=gameplay03 runs=3 median_avg_ms=2.43 spread_ms=0.11 median_p95_ms=4.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=10.12 spread_ms=0.43 median_p95_ms=11.00`<br>`PROFILE summary visual=-shadows pose=diorama02 runs=3 median_avg_ms=7.39 spread_ms=0.17 median_p95_ms=8.00` |+| headless, fix round 1 (corner fit, border 0.1) | `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.03 spread_ms=0.09 median_p95_ms=3.00`<br>`PROFILE summary visual=-shadows pose=gameplay03 runs=3 median_avg_ms=2.42 spread_ms=0.08 median_p95_ms=4.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=9.87 spread_ms=0.46 median_p95_ms=11.00`<br>`PROFILE summary visual=-shadows pose=diorama02 runs=3 median_avg_ms=7.12 spread_ms=0.11 median_p95_ms=8.00` |++Budget check, fix round 1 (`median(all) - median(-shadows) <= 2.5 ms + the larger spread`):+- gameplay03: -0.39 ms against 2.59 ms: within.+- diorama02: 2.75 ms against 2.96 ms (2.5 + 0.46): within, with 0.21 ms to spare.++**For Task 10 (review M5).** At gameplay03, `all` is faster than `-shadows` by more than both spreads, in both deliveries.+Three runs understate the run-to-run noise, so the 0.2 ms headroom at diorama02 means little. Re-measure diorama02+shadows with more repeats (at least 7) and headed. If the tier review needs headroom, the levers are:+- terrain shadow LOD or pixel error (the whole terrain is drawn into the shadow map at about 400 km);+- a cheaper fit at the far zoom (fit to the map's extent rather than the frustum once the frustum is wider than the map);+- a web-tier shadow map of 1024 at the far zoom only.++**Rendered coverage (review I2, I3).** `ReliefCastsShadowsAtMapScale` runs at both tiers over the Dead Sea escarpment at+60 km. Every other registered visual except `water` is off and the settlement markers are hidden, so only relief casts.+Results: shadowed share **3.06% (web)** and **3.12% (PC)**; the control at the asset's own 50 m is **0.00%** at both.+Hiding the markers moved the web share from 3.03% to 3.06%, which is noise, so the cubes were never a material part of+it. The 2% floor stays: it allows a third of the measured share to be lost to the merge (Task 3's tilt-shift softening+edges, Task 4's grade compressing darks, Track B's haze lifting distant shadow), and the control's 0.00% shows the+separation is clean. If the merge squeezes it further, switch to a relative test (`lit < flat * 0.9`), not a lower floor.++**Ambient (review M4). Superseded by Task 4:** the explicit probe described here was never read. In Trilight mode Unity+replaces it with its own linear conversion of the colours, and Task 4 removed `MapLighting.AmbientProbe`. The evaluated+values below are that conversion, and they match the constants once converted to sRGB; see "Task 4: grade". The original+note follows. `MapLighting.AmbientProbe` builds the trilight from `AddAmbientLight` plus two+`AddDirectionalLight` lobes. The lobes add constant and linear terms in every direction, so the probe evaluates darker+than its constants, which are inputs, not the evaluated colours. Evaluated values, pinned in `LightingTests`: up+(0.216, 0.255, 0.326), horizon (0.184, 0.179, 0.171), down (0.119, 0.103, 0.080); the constants are sky (0.52, 0.60,+0.72), equator (0.48, 0.46, 0.42), ground (0.26, 0.22, 0.17). The images were judged on the evaluated values, and Track+B's thresholds were derived with them, so a least-squares refit would be a look change for Task 4, not a fix here.++## Task 3: tilt-shift+Two bands, blurred by a half-resolution render-graph pass (`TiltShiftFeature` on both renderers, `Statecraft/TiltShift`):+- the blur is a separable 9-tap Gaussian whose radius is `TiltShift.Weight(y) * MaxRadiusUv`;+- the focus sits at the middle of the map area below the top bar;+- the blur weakens to 35% between 60 km and the 250 km overview.++URP's far-only Gaussian DoF is retired. Toggle: `tiltshift`; the URL flag `notiltshift` (desktop: `-notiltshift`) boots with+it off.++**Constants (fix round 1, review I2).** HalfWidth 0.13, Feather 0.17 and MaxRadiusUv 14/1080 (was 0.17, 0.18 and+10/1080). Full blur now starts 0.30 from the focus. That is the bottom and top 20% with no bar; under the web tier's top+bar (8.8% of the screen) it is the bottom 15.5%, and 15.5% between the band and the bar. The promo has about 15% at the+bottom and 20% at the top.++**Edit-mode ratios** (gradient energy shifted / sharp, gameplay pose, 960x540, no bar):++| Tier | top 0.90–0.98 | bottom 0.02–0.10 | middle | top 0.81–0.87 | bottom 0.13–0.19 | top at 1920x1080 |+|---|---|---|---|---|---|---|+| Mobile | 0.16 | 0.24 | 1.00 | 0.17 | 0.22 | 0.14 |+| PC | 0.11 | 0.18 | 1.00 | 0.12 | 0.15 | 0.11 |++TopInset 0.3: focus band 1.00, upper band 0.13. (Before fix round 1: Mobile top 0.22 and bottom 0.31; PC 0.16 and 0.24.)++**WebGL band check, with the real top bar (review m3).** I compared the checkpoint's `gameplay03.png` with a+`?shot¬iltshift` shot from the same build, using columns 30–80% (clear of the info panel and minimap) and rows measured+from the top. The bar ends at 0.088.+- Ratios by row (from the top):++ | Rows | 0.10–0.275 | 0.30 | 0.325 | 0.35 | 0.375 | 0.425–0.675 | 0.70 | 0.725 | 0.75 | 0.775 | 0.80–1.00 |+ |---|---|---|---|---|---|---|---|---|---|---|---|+ | Ratio | 0.01 | 0.13 | 0.32 | 0.60 | 0.86 | 1.00 | 0.74 | 0.45 | 0.22 | 0.07 | 0.01 |++- The sharp band is centred at about 0.54 from the top. The focus is at (1 − 0.088)/2 = 0.456 from the bottom, so this is+ the right way up; a flipped composite would centre at 0.456 from the top.+- The review's check: rows 0.20–0.30 from the top (nearer the bar) keep **0.02** of their detail, and rows 0.70–0.80 keep+ **0.37**.+- **Coverage.** Fully blurred (ratio <= 0.05) from the bar to 0.30 (**21% of the screen at the top**) and from 0.80 to the+ bottom (**20% at the bottom**). The promo has about 20% at the top and 15% at the bottom. By the design weight (weight =+ 1), the coverage is 15.6% at each end.++**Profile** (1920x1080, DPR 1, render scale 0.80, 3 interleaved runs per configuration), fix round 1 build:+```+headless (web_check.py)+PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=1.96 spread_ms=0.13 median_p95_ms=3.00+PROFILE summary visual=-tiltshift pose=gameplay03 runs=3 median_avg_ms=2.21 spread_ms=0.79 median_p95_ms=4.00+PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=9.65 spread_ms=0.20 median_p95_ms=10.00+PROFILE summary visual=-tiltshift pose=diorama02 runs=3 median_avg_ms=9.72 spread_ms=0.26 median_p95_ms=11.00+headed (headed.py profile --dpr 1)+PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.01 spread_ms=0.39 median_p95_ms=3.00+PROFILE summary visual=-tiltshift pose=gameplay03 runs=3 median_avg_ms=1.89 spread_ms=0.35 median_p95_ms=3.00+PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=10.11 spread_ms=0.54 median_p95_ms=11.00+PROFILE summary visual=-tiltshift pose=diorama02 runs=3 median_avg_ms=10.55 spread_ms=0.59 median_p95_ms=11.00+```+Cost `median(all) - median(-tiltshift)`, all within the 1.5 ms budget and within the spreads:++| | gameplay03 | diorama02 |+|---|---|---|+| headless | −0.25 ms | −0.07 ms |+| headed | +0.12 ms | −0.44 ms |+| first build: headless | −0.08 ms | +0.48 ms |+| first build: headed | +0.01 ms | +0.07 ms |++## Task 4: grade+`MapGrade` adds the following to the rig's runtime `VolumeProfile`, all behind the `grade` toggle, with LDR grading on both tiers:+- a Neutral tonemapper;+- post exposure +0.15, contrast 14, saturation 16;+- white balance temperature **5** (the plan says 9; see the merge arithmetic below) and tint 2;+- split toning: teal shadows (0.36, 0.52, 0.60), amber highlights (0.96, 0.78, 0.55), balance −15;+- a dark-navy vignette: 0.26, smoothness 0.45.++**What was there before (measured).** The pipeline assets' own volume profile, `Settings/SampleSceneProfile` (the URP template's), already applied the following to every frame:+- Neutral tonemapping;+- bloom 0.25 above 1 (high quality);+- a 0.2 black vignette.++So the build was not "without a tonemapper". The `grade` toggle off falls back to that profile, not to a raw image. Two consequences:+- The control in `TheSunlitDesertDoesNotClip` sets the grade's tonemapper to None. That overrides the template's Neutral, and the graded Negev then clips 2.3% of its pixels, against 0.00% with Neutral.+- URP strips the tonemapper's uber variants unless some VolumeProfile *asset* has a Tonemapping component. The runtime profile is not an asset, so it does not count. `TheGradeIsWarmLandTealShadowsAndAGentleVignette` checks that such an asset exists. Today two assets carry one: the template's `SampleSceneProfile` and the global settings' `DefaultVolumeProfile`. The check fails only if both lose their Tonemapping component. If Task 10 drops the template profile (the bloom decision), it should add a project-owned VolumeProfile with Neutral, so the guarantee no longer rests on URP template leftovers.++Bloom is the template's, not this plan's; Task 10 should decide whether the web tier keeps it.++**Readability (review I9), from edit mode at 960x540, with the tilt-shift off for these detail checks.**+- ΔE76 between the selection band and the land 1 km inside the hex:++ | Pose | Graded | Ungraded |+ |---|---|---|+ | gameplay03 | 32.3 | 24.5 |+ | diorama02 | 48.6 | 36.6 |++- Colour-blind check (Machado 2009, gameplay pose):++ | Simulation | sea vs land | selection vs land | selection vs sea |+ |---|---|---|---|+ | Deuteranopia | 68.6 | 31.8 | 98.6 |+ | Protanopia | 67.8 | 31.5 | 97.6 |++- Saturation rises from 0.438 to 0.564.+- The vignette's corner/centre ratio drops from 0.603 to 0.483.+- In the checkpoint's deuteranopia and protanopia copies, the coast (blue against yellow) and the hex lines stay clear.++**Ambient (review M4, closed by measurement).**+- **How the probe actually works.** `MapLighting.AmbientProbe()` was never what the shaders read. In Trilight mode Unity replaces any assigned probe with its own conversion of the three colours, at once. It does this in the editor, and in the WebGL player too: a diagnostic build logged the getter at Apply, frame 120 and frame 600.+ - Editor renders with our probe, a least-squares refit and a black probe are identical to 3 decimals. Changing the trilight colours changes the image.+- **Why it looked like 40%.** Unity converts the sRGB colours to linear. The "40% of nominal" (horizon 0.18 against 0.48) compared linear values with sRGB constants. In sRGB the horizon is (0.466, 0.460, 0.450) against the equator's (0.48, 0.46, 0.42).+- **Decision: keep the look.** The dead explicit probe is removed, which changes nothing rendered. `LightingTests` now asserts the horizon is within 0.05 of the equator in sRGB.+- **Why no brighter refit.** A refit that brightens the ambient towards the constants (trilight colours raised so the probe's linear values reach the constants) does not help. Measured with the grade, in editor renders:++ | Pose | Warmth | Saturation | Luma | Contrast |+ |---|---|---|---|---|+ | gameplay03 | 0.142 → 0.082 | 0.572 → 0.518 | +0.03 | unchanged |+ | diorama02 | 0.154 → 0.090 | 0.526 → 0.458 | +0.03 | unchanged |++ That works against the merge's warmth target. It would also shift every Track B threshold, which were derived with the current ambient. Nothing Track B measures moves.++**Grade terms at diorama02 (editor, Mobile tier, no UI; each line takes one term out of the full grade).** With the full grade: warmth 0.154, saturation 0.526, contrast 0.110. With the grade off: warmth 0.120, saturation 0.419, contrast 0.088. The temperature here was 9.++| Term | Warmth | Saturation | Other |+|---|---|---|---|+| Saturation 16 | +0.027 | +0.084 | |+| White balance 9 | +0.030 | +0.014 | |+| Split toning | −0.039 (the teal shadows) | −0.041 | |+| Vignette | −0.018 | | |+| Contrast | | | +0.011 contrast |++**Merge arithmetic (diorama02 warmth, WebGL frame).**+- **Track A alone at Temperature 9:** t04 is 0.118 (t03 was 0.088).+- **Track B's contribution:** t06-terrain-r1 0.0384 − t01 0.0171 = **+0.021** before the grade.+- **How the grade scales it:** the grade's saturation (×1.16), contrast and exposure scale chroma by about 1.0–1.3, so Track B's +0.021 becomes +0.021 to +0.027.+- **At Temperature 9:** 0.118 + 0.021…0.027 = **0.139–0.145**. That is already at the promo's 0.145, before Track B's Task 7 haze and palette work.+- **Lowering the temperature:** one unit is about 0.003 of frame warmth: 0.030 for 9 units in the editor, × 0.88 for the WebGL frame's UI share. So Temperature 5 gives 0.118 − 4 × 0.003 = 0.106, and the checkpoint measured **0.106**.+- **Expected merged diorama02 warmth: 0.106 + 0.021…0.027 = 0.127–0.133.** That is at least 0.087 by 0.04, and leaves 0.012–0.018 for Track B's later warming.+- **Contrast:** t03 0.153 → t04 0.170, plus Track B's +0.014 (t06-r1 0.1731 − t01 0.1588), gives about **0.18–0.19** after the merge, moving towards the promo's 0.200.++| WebGL | Saturation | Contrast | Warmth | Promo (sat / contrast / warmth) |+|---|---|---|---|---|+| diorama02, t03 | 0.422 | 0.153 | 0.088 | 0.425 / 0.200 / 0.145 |+| diorama02, t04 (temp 9, `9603700`) | 0.52 | 0.169 | 0.118 | |+| diorama02, t04 (temp 5, `2ac7b6e`) | 0.51 | 0.170 | 0.106 | |+| gameplay03, t03 | 0.444 | 0.155 | 0.082 | 0.382 / 0.203 / 0.064 |+| gameplay03, t04 (temp 5) | 0.55 | 0.174 | 0.107 | |++**Over the promo (owner's call).**+- Saturation is now about 0.09 above the promo at diorama02 and 0.17 above it at gameplay03. The lever is `Saturation` (16 → 8 is about −0.04).+- Gameplay03 warmth is already above its promo (0.064) on Track A alone, and Track B adds about +0.03. The promo's gameplay frame has green fields and orchards, which is the art track's vegetation, and a global grade cannot fix that without cooling the diorama.++**Seam test.** `TheSeaBeyondTheEdgeMatchesTheTerrainSea` measures the seam twice:+- **Before the grade, against 0.012.** This isolates the grade, which is a per-pixel LUT plus a vignette that is flat this close to the centre, so it cannot open a seam.+- **On the shipped, graded frame, against 0.024.** The grade scales the sea's chroma by about 2: the sub-step mismatch between the terrain sea and the skirt shader goes from 0.008 to 0.016.++At the merge, Track B's patch-mean version should keep this graded/ungraded loop.++**Profile** (headless, 1920x1080, DPR 1, scale 0.80, 3 interleaved runs; build `9603700`. Temperature only changes LUT values, so the cost is the same at `2ac7b6e`):+```+PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=1.95 spread_ms=0.39 median_p95_ms=3.00+PROFILE summary visual=-grade pose=gameplay03 runs=3 median_avg_ms=1.93 spread_ms=0.37 median_p95_ms=3.00+PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=9.74 spread_ms=0.06 median_p95_ms=11.00+PROFILE summary visual=-grade pose=diorama02 runs=3 median_avg_ms=9.74 spread_ms=0.02 median_p95_ms=11.00+```+The grade costs +0.02 ms at gameplay03 and 0.00 ms at diorama02, inside the noise. The tonemapper and the vignette were already in the uber pass (the template profile), and the LUT pass ran before too.++ ## Baked textures (Task 5)+ `tools/terrain_bake.py` regenerates `unity/Assets/Textures/Map/terrain_bake.png` and `coast.png` from the committed+ heightmap in about 10 s. The output is deterministic per toolchain: re-running it with the pinned numpy 2.5.3 and+ pillow 12.3.0 on the same machine gives byte-identical PNGs. Another platform may differ in its zlib build or in+ 1-ulp `sin`/`arctan` results. Compare decoded pixels (`np.array_equal`), not file bytes; R and B may then differ by+ one level here and there.++ ## Task 6: terrain+ The Statecraft Terrain Lit Shader Graph (`tools/terrain_graph.py` + `StatecraftTerrain.hlsl`): one terrain layer (one+ pass) instead of seven, no basemap fallback. WebGL build (`-compression disabled`): `BUILD Succeeded WebGL ->+ Builds/Web-disabled: 73.4 MB on disk, 0 errors` (Task 1: 70.9 MB; +2.5 MB, the two baked textures), no `Shader error`.+ GLES3 check: `ShaderChecks.Gles3Errors` is empty for `Statecraft/StatecraftTerrain` (no `#extension ... : require`;+ `AllowedRequires` not needed).++ | Run | Lines |+ |---|---|+ | headless | `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=1.58 spread_ms=0.93 median_p95_ms=2.00`<br>`PROFILE summary visual=-haze pose=gameplay03 runs=3 median_avg_ms=1.88 spread_ms=0.87 median_p95_ms=4.00`<br>`PROFILE summary visual=none pose=gameplay03 runs=3 median_avg_ms=1.67 spread_ms=0.40 median_p95_ms=3.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=7.25 spread_ms=0.47 median_p95_ms=8.00`<br>`PROFILE summary visual=-haze pose=diorama02 runs=3 median_avg_ms=7.13 spread_ms=0.11 median_p95_ms=8.00`<br>`PROFILE summary visual=none pose=diorama02 runs=3 median_avg_ms=7.16 spread_ms=0.20 median_p95_ms=8.00` |+ | boot, `--cpu 1` | `BOOT map_build_ms median=509 runs=3 cpu=1`<br>`BOOT first_frame_ms median=3851 runs=3 cpu=1` (budgets 743 / 5321 ms: within) |++ Against the Task 1 baseline (`all`): gameplay03 2.29 -> 1.58 ms, diorama02 6.84 -> 7.25 ms (+0.41 ms, inside 2.5 ms plus+ the spread). Haze costs nothing measurable (`all` - `-haze`: -0.30 / +0.12 ms, both inside the spreads). The boot phase+ `biome texture baked` takes 94-106 ms (it replaces Task 1's `biome colours blended`).++ ### Task 6 fix round 1+ Haze retuned (review I1: start 200 km, scale 250 km, max 0.45, rift boost 0.6, colour sRGB (0.84, 0.74, 0.58)), ground+ palette x1.107 in sRGB, curvature gain 0.40, graph and nodes at Single precision, HDRP target dropped, trilinear map+ textures (bake aniso 2), the fine noise octave faded by its pixel footprint. The AO is its own uncompressed R8 texture+ (`ao.png`): measured against the source PNG, BC1 stepped it by 2+ levels on 404 of 681 broad Judean texels (59%); R8+ gives 0 of 681 (Judean slopes) and 0 of 6206 (Negev plateau). WebGL build: 76.9 MB (+3.5 MB for `ao.png`), no+ `Shader error`. GLES3 report (with vis-light `e8b1c48`'s serialized-subshader loop): 0 errors and no `require` for+ `Statecraft/StatecraftTerrain`, `Statecraft/HexSelection`, URP Lit (the sea on this branch) and URP Terrain Lit.++ | Run | Lines |+ |---|---|+ | headless | `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.41 spread_ms=0.88 median_p95_ms=4.00`<br>`PROFILE summary visual=-haze pose=gameplay03 runs=3 median_avg_ms=2.34 spread_ms=0.48 median_p95_ms=4.00`<br>`PROFILE summary visual=none pose=gameplay03 runs=3 median_avg_ms=2.46 spread_ms=0.07 median_p95_ms=4.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=7.29 spread_ms=0.07 median_p95_ms=8.00`<br>`PROFILE summary visual=-haze pose=diorama02 runs=3 median_avg_ms=7.31 spread_ms=0.10 median_p95_ms=8.00`<br>`PROFILE summary visual=none pose=diorama02 runs=3 median_avg_ms=7.34 spread_ms=0.09 median_p95_ms=8.00` |+ | boot, `--cpu 1` | `BOOT map_build_ms median=452 runs=3 cpu=1`<br>`BOOT first_frame_ms median=3559 runs=3 cpu=1` (budgets 743 / 5321 ms: within) |++ Art (WebGL, whole frame; vis-ground has no Task 2 light, so compare with t01): diorama02 warmth 0.017 (t01) / 0.007+ (t06) -> 0.038, saturation 0.36 -> 0.41, contrast 0.171 -> 0.173, palette distance 0.85 -> 0.78; map land alone (column+ x 0.45-0.6) R-B 0.158 -> 0.229, saturation 0.254 -> 0.363, luma 0.576 -> 0.572. gameplay03 warmth 0.009 (t01) / 0.017+ -> 0.040, contrast 0.163 -> 0.173, palette distance 0.69 -> 0.66. The checkpoint also shoots the 6 km hero zoom over the+ Judean slopes and the Negev (`PromoPose.CloseChecks`, haze off): no AO steps.++ ## Task 7: sea+ One water function (`StatecraftMap.hlsl` `ScWaterShade`) on both sides of the map's edge: the terrain graph outputs it as+ emission on a black, fully metallic, fully occluded surface, and the border skirt's `Sea.mat` (`Statecraft/Sea`, passes+ `Sea`, `DepthOnly`, `DepthNormals`) returns it directly. It is driven by Task 5's coast distance: a turquoise -> teal -> navy+ ramp over 12 km, foam within 350 m, the Dead Sea pale turquoise with a white salt rim. It samples the main light's shadows+ itself, takes the cooler water haze (`ScHazeWater`), and falls back to the flat sea colour under the `water` toggle. WebGL+ build: 77.1 MB, no `Shader error`. GLES3: `ShaderChecks.Gles3Errors` is empty for `Statecraft/Sea` and the terrain (no+ `require`).++ Deviations from the plan:+ - **Glint 0.06, not 0.25.** With `Map.unity`'s default 50-degree sun, the camera's 50-degree pitch at 120 km meets the+ reflection at yaw 180. There the 0.25 lobe lit a warm patch rising 0.08 in sRGB red over 6 km of open sea, and the seam+ test (samples 5 km apart) read it as a 0.031 seam. A profile across the edge showed no step at the edge itself, and the+ difference scaled with the glint. At 0.06, every seam line is <= 0.004.+ - **The held skirt is averaged along the edge.** Holding each edge vertex's own height for 20 km+ (`SkirtFall = {0, 0.05, 0.15, 0.45, 1}`) drew the edge's ridges out as long stripes across the Jordan skirt (checkpoint+ t07-sea, first run). Rings 1-4 now hold the edge height averaged over +-8 km (`MapBuilder.SkirtHoldSmoothingM`). Ring 0+ still meets the terrain exactly. New test `TheHeldSkirtCarriesThePlateauNotTheEdgesRidges`: the mean spoke-to-spoke step+ 20 km out is 8.5 m against 36.7 m at the edge (31.2 m before).++ | Run | Lines |+ |---|---|+ | headless | `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.38 spread_ms=0.42 median_p95_ms=4.00`<br>`PROFILE summary visual=-haze pose=gameplay03 runs=3 median_avg_ms=2.35 spread_ms=0.08 median_p95_ms=4.00`<br>`PROFILE summary visual=-water pose=gameplay03 runs=3 median_avg_ms=1.70 spread_ms=0.61 median_p95_ms=3.00`<br>`PROFILE summary visual=none pose=gameplay03 runs=3 median_avg_ms=1.72 spread_ms=0.27 median_p95_ms=2.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=7.64 spread_ms=1.56 median_p95_ms=9.00`<br>`PROFILE summary visual=-haze pose=diorama02 runs=3 median_avg_ms=7.67 spread_ms=0.29 median_p95_ms=8.00`<br>`PROFILE summary visual=-water pose=diorama02 runs=3 median_avg_ms=7.78 spread_ms=0.35 median_p95_ms=9.00`<br>`PROFILE summary visual=none pose=diorama02 runs=3 median_avg_ms=7.48 spread_ms=0.02 median_p95_ms=8.00` |+ | boot, `--cpu 1` | `BOOT map_build_ms median=472 runs=3 cpu=1`<br>`BOOT first_frame_ms median=3592 runs=3 cpu=1` (budgets 743 / 5321 ms: within) |++ Against Task 6 fix round 1 (`all`): gameplay03 2.41 -> 2.38 ms, diorama02 7.29 -> 7.64 ms (+0.35 ms, inside 2.5 ms plus the+ spread). Water costs 0.68 ms at gameplay03 (`all` - `-water`, against a 0.61 ms spread) and nothing measurable at+ diorama02 (-0.14 ms), well inside 2.5 ms. The profile ran on the build before the skirt averaging, which changes no+ shader. The boot lines are from the final build.++ Art (WebGL): diorama02 saturation 0.41 -> 0.39, contrast 0.173 -> 0.186, warmth 0.038 -> 0.058, palette distance 0.78 ->+ 0.76. gameplay03 contrast 0.173 -> 0.194, palette distance 0.66 -> 0.65. The sea grades from turquoise shallows with a+ foam line to navy, and the Dead Sea is pale turquoise with white salt rims. Coast streaks: none visible. A 12x high-pass of+ the gameplay03 coast shows only the foam band's waves and single-level output steps in the deep water, so the bake's+ distance needs no smoothing (Task 5 carry). Plateau edge (diorama02): the Jordanian plateau now continues past the east+ edge at the edge's broad height instead of sagging at once, as a flat muted band level with the map's eastern rim. A+ faint low-contrast banding remains there at grazing angles.++ ### Task 7 fix round 1+ - **Haze at full width (review I1, the Task 6 carry).**+ - At diorama02, the haze toggle moves the far band 0.047 and the near band 0.002 over the full width. Task 6 measured+ 0.023 / 0.026, with the sea and skirt unhazed. Restricted to the land column it was 0.069 / 0.026.+ - So `TheHazeThickensWithDistance` and `TheHazeStartsBeyondTheNearestDioramaLandAndGrowsWithDistance` sample x 0..1+ again. By distance: near 0.0019, mid 0.0212, far 0.0473.+ - `TheOpenSeaStaysBlueUnderTheHaze` now asserts that the water haze applies. The open sea at about 300 km moves 0.059+ in luma with the haze on, and 0.000 with `ScHazeWater` dropped on both sides (the red check).+ - **Seam test close pair (M1).**+ - The pair sits at +-600 m across the edge. Each side is the mean of five 7x7 patches, 2 km apart along the edge,+ because a single 1 km patch carries one wave cell or glint sparkle on its own (up to 0.012).+ - A step of 5% on the skirt sea only within 1.5 km of the edge passes the +-2.5 km pairs (0.000) and fails the close+ pair (0.015). All 16 lines are <= 0.004.+ - **Skirt hold (M4).**+ - The hold is now a running mean over the edge's own samples (prefix sums, +-8 km). It replaces the 17 taps 1 km apart.+ - East edge, spoke-to-spoke step 20 km out: 8.5 -> 5.2 m. What remains is the plateau's own trend along the edge.+ - The test bound is under 0.18 x the edge's step.+ - The faint grazing-angle banding in diorama02 is gone.+ - **Land skips the water shading (M3).** `[branch]` on `water > 0`.+ - gameplay03 `all` minus `-water`: 0.03 ms before, 0.01 ms after. Both are inside the spreads, so there is no+ measurable change on this GPU.+ - Before, on the build at `6757168`: `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.49 spread_ms=0.17`+ and `visual=-water ... median_avg_ms=2.46 spread_ms=0.06`.+ - After: `visual=all ... median_avg_ms=2.55 spread_ms=0.07`, `visual=-water ... median_avg_ms=2.54 spread_ms=0.02`;+ diorama02 `all` 7.34 ms (before 7.38 ms).+ - The earlier 0.68 ms water cost was run-to-run noise.+ - **Build and boot.** WebGL 77.1 MB, no `Shader error`. Boot `--cpu 1`: `map_build_ms` 469, `first_frame_ms` 3598+ (budgets 743 / 5321).++ ## Task 8: grid+ The hex grid is drawn by the terrain graph and by the skirt's `Sea.shader` from one distance field (`ScHexEdgeDistance`,+ tools/hexgrid.py's layout; `HexGrid` is the C# twin), anti-aliased with `fwidth`, 1.5 px wide, light on land (0.25) and+ water (0.35), fading to 0.6 of that from 40 km to 240 km camera distance. The `MeshTopology.Lines` overlay, its material,+ `OverlayClearanceM` and its boot phase are gone; the selected-hex band sits 30 m above the ground (was 140 m). Toggle+ `grid`, registered in `MapShaderGlobals.Apply` through `assets.OnTeardown`. All numbers here are pre-grade (Track A's grade+ and tilt-shift are not in this worktree).++ - **Rendered tests (EditMode).** Edge luma change 0.059 (hills, 30 km). Grid coverage: 3.08% at 20 km, 18.15% at+ 250 km (bound 0.05%-25%). Rift hex lines: Beit She'an 0.062, Jericho 0.058, Dead Sea shore / Arava 0.016 (light lines+ on the bright desert are faint; that test's bound is 0.012, the plan's 0.03 holds only off the desert).+ - **Seam.** Task 7's pairs and close strip, grid off: 16 lines, max 0.004. Grid on: 12 asserted lines, max 0.008; the+ close strip at yaw 90/270 is logged only (0.014 at yaw 270: the x = 0 hex line falls unequally into the two+ foreshortened patches). The plan's hex-centre pairs at x = +-4330 m were dropped: the middle-row pair differs by 0.027+ at yaw 180 with the grid off too (a warm sun glint on the terrain side), a pre-existing water effect.+ - **Profile (WebGL, 1920x1080).**+ - `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.42 spread_ms=0.74 median_p95_ms=4.00`+ - `PROFILE summary visual=-grid pose=gameplay03 runs=3 median_avg_ms=2.41 spread_ms=0.22 median_p95_ms=4.00`+ - `PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=7.30 spread_ms=0.12 median_p95_ms=8.00`+ - `PROFILE summary visual=-grid pose=diorama02 runs=3 median_avg_ms=7.28 spread_ms=0.34 median_p95_ms=8.00`+ - The grid costs 0.01-0.02 ms, inside the spreads; with the line mesh's draw call gone, gameplay03 `all` is 2.42 ms+ (Task 7 fix round 1: 2.55 ms).+ - **Build and boot.** WebGL 77 MB, no `Shader error`; no GLES derivative error (no `#pragma require derivatives`+ needed). Boot `--cpu 1`: `BOOT map_build_ms median=419`, `BOOT first_frame_ms median=3442` (Task 7: 469 / 3598).+ - **Look (t08-grid).** The sea lattice runs on past the map's edge with no step. At the 250 km overview the sea lattice is+ dense and reads strongly; land lines are faint, nearly invisible on the desert.++ ### Task 8 fix round 1+ - **Line anti-aliasing (review I1).** `fwidth` of the V-shaped edge distance collapsed on the line itself. The fix projects+ the derivatives of the continuous grid coordinate on the nearest edge's normal (metres per pixel across the edge) and+ box-filters: `saturate(0.5 * widthPx + 0.5 - d / aa)`.+ - New rendered test `GridLinesAreUnbrokenAndAboutTheirWidthAtGameplay03` (1920x1080, opacities forced to 1, linear luma).+ - Red at b409955: sea peak ratio 0.41 along one edge, FWHM 2.74 px.+ - Green: sea ratio 0.85, FWHM 1.66 px (1.51-1.95); land FWHM 1.62 px (1.37-1.97).+ - **Weights (review I2).** `GridWaterOpacity` 0.35 -> 0.10. The distance fade is now lerp(1, 0.35). Lines also fade out as a hex+ shrinks from 30 to 10 px on screen (circumradius over the pixel footprint). Land stays 0.25 until the grade merges.+ - Sea line in `gameplay03` (x 120-170, y 480-560): background 49, peak 83, +34, ratio 1.69, 2 px wide. Before: +86,+ 2.75, 4 px. Promo (x 470-520, y 550-580): background 109, peak 151, +43, ratio 1.39. Our ratio is higher only+ because our sea is darker (pre-grade).+ - diorama02 near sea line: +6 over 73 (before +50). Grid coverage at 1920x1080: 0.74% at 20 km, 0.76% at 250 km+ (was 3.1% / 18.2% at 960x540).+ - **Seam (M1).** The close strips sit on even hex rows (x = 0 a hex centre); all 32 lines (grid off and on, four yaws)+ are asserted, max 0.004.+ - **Rift.** Arava line change 0.015 (bound 0.012, land opacity unchanged).+ - **Profile** (machine load average about 7, spreads up to 1 ms):+ - `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=1.71 spread_ms=0.97 median_p95_ms=3.00`+ - `PROFILE summary visual=-grid pose=gameplay03 runs=3 median_avg_ms=2.22 spread_ms=0.99 median_p95_ms=4.00`+ - `PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=7.23 spread_ms=0.67 median_p95_ms=8.00`+ - `PROFILE summary visual=-grid pose=diorama02 runs=3 median_avg_ms=7.22 spread_ms=0.54 median_p95_ms=8.00`+ - **Build.** WebGL, no `Shader error`; golden values OK in the checkpoint run.+## Checkpoints| Task | Name | Images | Owner verdict ||---|---|---|---|| 1 | t01-before | captures/visual/t01-before/*-compare*.png | (owner) |+| 2 | t02-light | captures/visual/t02-light/*-compare*.png | (owner) Note: at the new 6 km hero zoom the view is filled by the 600-1,800 m placeholder marker cubes, so judge the zoom range, not the close-up art, until the settlement art track replaces them. |+| 3 | t03-tiltshift | captures/visual/t03-tiltshift/*-compare*.png (re-shot in fix round 1: bands 0.13/0.17, radius 14/1080) | (owner) Note: the map labels are still world-space text, so they blur with the map in the top and bottom bands until Task 9 moves them to UI Toolkit. |+| 4 | t04-grade | captures/visual/t04-grade/*-compare*.png (with -deuteranopia / -protanopia copies) | (owner) Note: saturation is above the promo (0.51/0.43 diorama, 0.55/0.38 gameplay); `MapGrade.Saturation` is the lever. |+ | 6 | t06-terrain | captures/visual/t06-terrain/*-compare*.png, editor/*-compare*.png | (owner) |+ | 6 (fix 1) | t06-terrain-r1 | captures/visual/t06-terrain-r1/*-compare*.png, hero06judea.png, hero06negev.png, editor/*-compare*.png | (owner) |+ | 7 | t07-sea | captures/visual/t07-sea/*-compare*.png, hero06judea.png, hero06negev.png, editor/*-compare*.png | (owner) |+ | 7 (fix 1) | t07-sea-r1 | captures/visual/t07-sea-r1/*-compare*.png, hero06judea.png, hero06negev.png, editor/*-compare*.png | (owner) |+ | 8 | t08-grid | captures/visual/t08-grid/*-compare*.png, hero06judea.png, hero06negev.png, editor/*-compare*.png | (owner) |+ | 8 (fix 1) | t08-grid-r1 | captures/visual/t08-grid-r1/*-compare*.png, hero06judea.png, hero06negev.png, editor/*-compare*.png | (owner) |+| 9 | t09-labels | captures/visual/t09-labels/*-compare*.png | (owner) |++## Task 9: labels++Settlement names are UI Toolkit pills (`MapLabelsPresenter`, EB Garamond SemiBold on navy with a gold edge) in the+click-through `map-labels` layer, placed in `GameRoot.LateUpdate` with an inline pixel `translate` and hidden while the+game loads. The world-space `TextMesh` labels are gone.++Frame time, headless, DPR 1, `res=1920x1080 scale=0.80` (`?vprofile`, `machine_lock.py --exclusive --wait-unity`):++| Pose | all | -labels | none | all - (-labels) | budget |+|---|---|---|---|---|---|+| gameplay03 | 2.30 (spread 0.15) | 2.36 (0.06) | 2.34 (0.04) | -0.06 ms | <= 1 + 0.15 ms: within |+| diorama02 | 6.82 (0.06) | 6.55 (0.02) | 6.61 (0.14) | +0.27 ms | <= 1 + 0.06 ms: within |++The profile holds the camera still, so after the first frames `Refresh` returns early (unchanged view-projection,+panel size and zoom); the cost measured is the drawing of the pills, not the per-frame placement while the camera moves.++Deviations from the plan text, each forced by a test:+- Projection: `RuntimePanelUtils.CameraTransformWorldToPanel` flips y with `Screen.height`, which is wrong when the camera+ draws to a texture of another size (edit-mode tests: 600 px off). The presenter maps the camera's viewport point+ through `camera.rect` onto the panel's own size instead.+- Declutter at the overview: the Tel Aviv - Lod cluster's markers sit 10-60 px apart there, and a town's pill could not+ avoid a neighbour's marker with any anchor (Rishon LeZion's pill ended 10 px under Jaffa's marker). A pill other than+ a city's is now also hidden when it comes within `NeighbourClearPx` (2 x LiftPx + MarginPx = 16 px) of another+ settlement's marker top. At 90 km this hides nothing (11 of 25 shown, as before); at the overview 10 of 25 are shown.+- City pills: 20 px text and 8 px side padding at first. Fix round 1 restores the plan's 22 px and 10 px (see below).+- `ThePillIsEbGaramondOnNavyWithAGoldEdgeAndHiddenWhileLoading` uses a 1920x1080 panel instead of `UiTestKit`'s: the+ batch-mode screen gives that panel about 0.39 px per point, and UI Toolkit rounds the 1 px border up to one physical+ pixel (2.57 points).++### Task 9 fix round 1 (review I1-I5, M1-M7)++- Panels: pills are culled against the cached rects of the top bar, the info panel, the minimap and the event card,+ marked dirty by GeometryChangedEvent; a pill must lie wholly on screen, and a marker under a panel is no one's+ neighbour. A container resize re-places the pills before the repaint (M4).+- Anchors: the USS anchor class is tried first, then lower right, lower left, lower centre and centred below the marker,+ as a pixel shift on the slot's translate. The legibility rule (more than 2 x own gap + MarginPx from every other+ visible marker top) applies to every pill; a city whose anchors all crowd a neighbour keeps the first that is clear of+ panels and pills. A pill hidden in the last refresh needs HysteresisPx = 2 more (M7).+- Shown sets (MapLabelTests): 90 km: tel_aviv jaffa lod ramla petah_tikva rishon_lezion rehovot netanya (every visible+ marker); overview: jerusalem tel_aviv lod gaza beersheba petah_tikva netanya; diorama02 with the top-bar inset also+ labels Hadera (checkpoint).+- City pills are back to the plan's 22 px and 10 px padding (towns 19 px), so cities read larger (M5). At the+ overview Tel Aviv's pill takes the lower-right anchor, over the sea.+- Refresh allocates nothing (`Is.Not.AllocatingGCMemory`). Editor Mono, 240 refreshes while turning and zooming:+ `LABELS refresh moving avg_us=27 p95_us=38`.+- `?vprofile&vmoving` (FrameProfile, additive): every run restarts at its pose and turns 0.5 degrees per frame.+ Headless, DPR 1, `res=1920x1080 scale=0.80`:++| Pose | all | -labels | none | all - (-labels) | budget |+|---|---|---|---|---|---|+| gameplay03-moving | 2.24 (spread 0.65) | 2.28 (0.78) | 2.44 (0.63) | -0.04 ms | <= 1 + 0.78 ms: within |+| diorama02-moving | 10.21 (0.10) | 10.20 (0.16) | 10.10 (0.34) | +0.01 ms | <= 1 + 0.16 ms: within |+| gameplay03 (still) | 2.47 (0.51) | 2.44 (0.04) | 2.35 (0.34) | +0.03 ms | within |+| diorama02 (still) | 6.76 (0.38) | 6.53 (0.29) | 6.58 (0.41) | +0.23 ms | within |++ diorama02 costs about 3.4 ms more while turning than still, with or without labels (the rest of the scene).++### Task 9 fix round 2 (re-review N1-N3, shown-set robustness)++- A GeometryChangedEvent on a panel (event card, info panel, minimap, top bar) re-places the pills at once, inside the+ layout pass, so a card that opens never covers a pill for a frame (N1). The pills' summed sizes are part of the+ early-out key, so a pill that grows with the camera still is re-placed (N2). `LABELS refresh moving avg_us=28 p95_us=38`.+- N3: WebGL `?smoke=5&navlog` (`SMOKE OK 5 turns 1948-06-19 d3fdd459...`) shows no layout or style warning in the+ console; the only non-game lines are the existing `WebGL: INVALID_ENUM: getInternalformatParameter` driver notices.+- `ShownPillsNeverOverlapAndEachReadsAsItsOwn` pins only unambiguous names (90 km: Tel Aviv, Petah Tikva; overview: Tel+ Aviv, Jerusalem, Gaza, Beersheba), at least 8 and 7 pills, Hadera or Netanya at the overview, and completeness: every+ visible marker not decluttered by zoom with no other visible marker within 2 pill heights + MarginPx is labelled.+ Disabling the anchor fallback turns it red (`overview: shown pills Expected: greater than or equal to 7 But was: 6`).+diff --cc tools/README.mdindex b36207895,07a05b14f..16e208530--- a/tools/README.md+++ b/tools/README.md@@@ -34,7 -40,7 +40,7 @@@ Run from the repo root; this installs euv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q```- Expected: `144 passed, 1 skipped` (the skipped one is the headed browser check; add `--headed` and `--with websockets==15.0.1` to run it). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.-Expected: `172 passed, 1 skipped` (the skipped one is the headed browser check; add `--headed` and `--with websockets==15.0.1` to run it). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.++Expected: `173 passed, 1 skipped` (the skipped one is the headed browser check; add `--headed` and `--with websockets==15.0.1` to run it). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.## Required attribution (Copernicus DEM licence, modified data)diff --cc unity/Assets/Tests/EditMode/SeaTests.csindex 000000000,be50d1856..ef94ed3d3mode 000000,100644..100644--- a/unity/Assets/Tests/EditMode/SeaTests.cs+++ b/unity/Assets/Tests/EditMode/SeaTests.cs@@@ -1,0 -1,172 +1,175 @@@+ #nullable enable+ using System.Collections;+ using System.IO;+ using NUnit.Framework;+ using Statecraft.Game.Map;+ using UnityEditor;+ using UnityEditor.SceneManagement;+ using UnityEngine;+ using UnityEngine.TestTools;++ /// <summary>Plan Task 7: the water, inside the map and past its edge, and the plateau skirt.</summary>+ public class SeaTests+ {+ const string SeaMatPath = "Assets/Materials/Sea.mat";++ [TearDown]- public void Reset() { EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }++ public void Reset() { RenderSample.TiltShift(true); EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }++ static MapScene OpenMap()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();++ // Every render here measures colour or local detail: Track A's tilt-shift blurs the top and bottom bands (task-3++ // carry m6, applied at the merge point), so it is off; the TearDown turns it back on.++ RenderSample.TiltShift(false);+ return map;+ }++ [Test]+ public void TheSkirtSeaUsesTheWaterShaderWithTheCoastTexture()+ {+ var sea = AssetDatabase.LoadAssetAtPath<Material>(SeaMatPath);+ Assert.AreEqual("Statecraft/Sea", sea.shader.name);+ Assert.IsFalse(ShaderUtil.ShaderHasError(sea.shader));+ Assert.AreEqual(AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Coast), sea.GetTexture("_ScCoastTex"));+ Assert.GreaterOrEqual(sea.FindPass("DepthOnly"), 0, "in the depth prepass, like the selection band (m3-fix N6)");+ Assert.GreaterOrEqual(sea.FindPass("DepthNormals"), 0);+ }++ [Test]+ public void TheWaterShadersCompileForWebGL2()+ {+ CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(Shader.Find("Statecraft/Sea")));+ CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/Terrain.mat").shader));+ }++ /// <summary>The controller's known gap: at the Jordanian plateau the land skirt holds the edge's height for 20 km (at+ /// least 80% of its height above the sea) and reaches sea level only at the last ring.</summary>+ [Test]+ public void TheLandSkirtHoldsThePlateauThenEasesToSeaLevel()+ {+ var map = OpenMap();+ var size = map.Terrain.terrainData.size;+ var verts = map.Terrain.transform.Find(MapScene.BorderSkirtName).GetComponent<MeshFilter>().sharedMesh.vertices;+ var meta = HeightmapLoader.Load(Statecraft.Game.Paths.StreamingMap).meta;+ float seaY = (0f - meta.elev_min_m) * MapBuilder.VerticalExaggeration;+ float zAmman = map.Frame.ToWorld(35.9, 31.95, 0).z;+ int best = -1;+ for (int i = 0; i < verts.Length; i++)+ if (Mathf.Abs(verts[i].x - size.x) < 0.5f && (best < 0 || Mathf.Abs(verts[i].z - zAmman) < Mathf.Abs(verts[best].z - zAmman))) best = i;+ Assert.GreaterOrEqual(best, 0, "an east-edge spoke");+ float edge = verts[best].y - seaY;+ Assert.Greater(edge, 1500f, "the plateau stands well above the sea (about 900 m, exaggerated 3x)");+ Assert.AreEqual(size.x + MapBuilder.SkirtRings[2], verts[best + 2].x, 1f, "ring 2 of the same spoke");+ Assert.GreaterOrEqual(verts[best + 2].y - seaY, 0.8f * edge, "held 20 km out");+ Assert.AreEqual(seaY, verts[best + MapBuilder.SkirtRings.Length - 1].y, 1f, "at sea level at the last ring");+ }++ /// <summary>Task 7 checkpoint finding: holding each edge vertex's own height for 20 km drew the edge's ridges out as long+ /// stripes across the Jordan skirt. Along the east edge, the held ring 2 is far smoother from spoke to spoke than the+ /// edge (ring 0, which meets the terrain exactly). Fix round 1 (review M4): the hold is a running mean over the edge's+ /// own samples, not 17 taps 1 km apart that undersampled ridges shorter than about 2 km: under 18% of the edge's step.+ /// What a +-8 km mean keeps is the plateau's own trend along the edge (about 400 m of exaggerated height over 16 km, over+ /// a 77-sample window: 5.2 m per spoke); the 17 taps added their aliasing on top (8.5 m).</summary>+ [Test]+ public void TheHeldSkirtCarriesThePlateauNotTheEdgesRidges()+ {+ var map = OpenMap();+ var size = map.Terrain.terrainData.size;+ var verts = map.Terrain.transform.Find(MapScene.BorderSkirtName).GetComponent<MeshFilter>().sharedMesh.vertices;+ int rings = MapBuilder.SkirtRings.Length;+ float edge = 0f, held = 0f; int pairs = 0, prev = -1;+ for (int i = 0; i + rings <= verts.Length; i += rings)+ {+ bool east = Mathf.Abs(verts[i].x - size.x) < 0.5f && verts[i].z > 0.3f * size.z && verts[i].z < 0.9f * size.z+ && Mathf.Abs(verts[i + 2].x - (size.x + MapBuilder.SkirtRings[2])) < 1f;+ if (!east) { prev = -1; continue; }+ if (prev >= 0) { edge += Mathf.Abs(verts[i].y - verts[prev].y); held += Mathf.Abs(verts[i + 2].y - verts[prev + 2].y); pairs++; }+ prev = i;+ }+ TestContext.WriteLine($"east edge: {pairs} spoke pairs, mean step at the edge {edge / pairs:0.0} m, held 20 km out {held / pairs:0.0} m");+ Assert.Greater(pairs, 500);+ Assert.Less(held, 0.18f * edge, "the held rings carry the plateau's broad height, not the edge's ridges (no aliasing)");+ }++ static float Luma(Color c) => RenderSample.Luma(c);++ /// <summary>Rendered west of Tel Aviv: just offshore (inside the 350 m foam band) is brighter than 1.2 km out, which is+ /// lighter and greener than the open sea 24 km out. The shore is found in coast.png itself.</summary>+ [UnityTest]+ public IEnumerator ShallowsAreLighterThanTheOpenSeaAndFoamLinesTheShore()+ {+ var map = OpenMap();+ yield return null;+ var coast = new Texture2D(2, 2);+ coast.LoadImage(File.ReadAllBytes(MapTexturePaths.Coast)); // readable copy; row 0 = south+ int row = Mathf.FloorToInt((32.08f - 29.45f) / (33.35f - 29.45f) * coast.height);+ int col = Mathf.FloorToInt((34.95f - 34.2f) / (35.9f - 34.2f) * coast.width);+ while (col > 0 && coast.GetPixel(col, row).r >= 0.5f) col--; // walk west to the first water texel+ Object.DestroyImmediate(coast);+ Vector3 At(int c)+ {+ double lon = 34.2 + (c + 0.5) / 2048.0 * (35.9 - 34.2), lat = 29.45 + (row + 0.5) / 2048.0 * (33.35 - 29.45);+ var w = map.Frame.ToWorld(lon, lat, 0); w.y = map.Terrain.SampleHeight(w); return w;+ }+ Vector3 foam = At(col - 2), shallow = At(col - 15), deep = At(col - 300);+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ rig.LookAt = shallow; rig.Distance = 30000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ var px = new Vector2[2];+ var near = RenderSample.Render(cam, 960, 540, new[] { foam, shallow }, px);+ Color f = near.Mean((int)px[0].x, (int)px[0].y, 1), s = near.Mean((int)px[1].x, (int)px[1].y, 1);+ rig.LookAt = deep; rig.Apply();+ var far = RenderSample.Render(cam, 960, 540, new[] { deep }, px);+ Color d = far.Mean((int)px[0].x, (int)px[0].y, 2);+ TestContext.WriteLine($"foam {f}, shallow {s}, deep {d}");+ Assert.Greater(Luma(f), Luma(s) + 0.02f, "foam at the shore");+ Assert.Greater(Luma(s), Luma(d) + 0.05f, "shallows lighter");+ Assert.Greater(s.g / s.b, d.g / d.b, "shallows greener");+ }++ /// <summary>Rendered: the Dead Sea is pale turquoise, much lighter than the open Mediterranean.</summary>+ [UnityTest]+ public IEnumerator TheDeadSeaIsPalerThanTheOpenSea()+ {+ var map = OpenMap();+ yield return null;+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ Color Sample(double lon, double lat)+ {+ var w = map.Frame.ToWorld(lon, lat, 0); w.y = map.Terrain.SampleHeight(w);+ rig.LookAt = w; rig.Distance = 40000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ var px = new Vector2[1];+ var r = RenderSample.Render(cam, 480, 270, new[] { w }, px);+ return r.Mean((int)px[0].x, (int)px[0].y, 2);+ }+ Color dead = Sample(35.50, 31.50), med = Sample(34.40, 32.00);+ TestContext.WriteLine($"Dead Sea {dead}, Mediterranean {med}");+ Assert.Greater(Luma(dead), Luma(med) + 0.1f);+ }++ /// <summary>Review I2: at the country-wide pose (about 300 km from the camera) the open sea stays saturated blue under the+ /// water haze: b > r + 0.15 (worked out in Step 4: about 0.21 before the grade). And the water toggle exists. Fix round+ /// 1 (review I1): the water haze applies at all: with the haze off the same sample moves by more than 0.01 in luma+ /// (about 0.18 x 0.33 of the way to the cool water haze at about 300 km).</summary>+ [UnityTest]+ public IEnumerator TheOpenSeaStaysBlueUnderTheHaze()+ {+ var map = OpenMap();+ yield return null;+ CollectionAssert.Contains(VisualToggles.Names, "water");+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ PromoPose.Diorama02.Apply(rig, map.Frame); rig.TopInset = 0; rig.Apply();+ var sea = map.Frame.ToWorld(34.40, 31.80, 0); sea.y = map.Terrain.SampleHeight(sea);+ var px = new Vector2[1];+ var s = RenderSample.Render(cam, 960, 540, new[] { sea }, px);+ var c = s.Mean((int)px[0].x, (int)px[0].y, 2);+ VisualToggles.Set("haze", false);+ var clear = RenderSample.Render(cam, 960, 540, new[] { sea }, px);+ VisualToggles.Set("haze", true);+ var c0 = clear.Mean((int)px[0].x, (int)px[0].y, 2);+ TestContext.WriteLine($"open sea at the diorama pose {c}, b - r = {c.b - c.r:0.000}; haze off {c0}, luma shift {Luma(c) - Luma(c0):0.000}");+ Assert.Greater(c.b, c.r + 0.15f);+ Assert.Greater(Mathf.Abs(Luma(c) - Luma(c0)), 0.01f, "the water haze moves the far open sea");+ }+ }diff --cc unity/Assets/Tests/EditMode/SettlementTests.csindex a8582b0e1,9c301b3dd..6d8265aab--- a/unity/Assets/Tests/EditMode/SettlementTests.cs+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs@@@ -357,7 -372,7 +372,6 @@@ public class MapSceneTestint seen = 0;foreach (Transform box in root){-- if (box.name.EndsWith("_label") || box.GetComponent<MeshRenderer>() == null) continue;var ground = map.Terrain.SampleHeight(box.position);var realElevation = ground / MapBuilder.VerticalExaggeration + HeightmapLoader.Load(Paths.StreamingMap).meta.elev_min_m;if (realElevation > -10f) continue;@@@ -382,37 -399,52 +401,59 @@@EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);var map = Object.FindFirstObjectByType<MapScene>();map.Build();- // Visual v1 Task 4: the grade roughly doubles the sea's sub-step mismatch between the two shaders (0.008 -> 0.016- // here). Track B's patch-mean version of this test should keep the graded/ungraded loop at the merge.+ yield return null;var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();var size = map.Terrain.terrainData.size;- var rt = new RenderTexture(1600, 900, 24);- var tex = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);+ // Visual v1 Task 8 (review I3): both sides draw the same hex grid; the lattice runs on past the edge and is+ // mirror-symmetric about it. Every pair is checked with the grid off and on, at four yaws. Task 8 fix round 1 (M1):+ // the close strips are centred on even hex rows, where x = 0 is a hex centre, so their +-600 m patches (five, 2 km+ // apart along the edge) all lie over 2.2 km from any line; on an odd row the x = 0 hex line itself fell unequally+ // into the two foreshortened patches at yaw 90/270.+ float rowM = 1.5f * map.Hexes.hex_size_km * 1000f;+ float EvenRowZ(float fromNorthM) => size.z - 2f * Mathf.Round(fromNorthM / rowM / 2f) * rowM;+ float midZ = EvenRowZ(0.45f * size.z), northZ = EvenRowZ(2f * rowM);+ // (The plan's one-row hex-centre pairs at x = +-4330 m were tried and dropped: at yaw 180 the middle-row pair differs+ // by 0.027 with the grid off too, a warm view-dependent sun glint on the terrain side, not a grid or seam effect.)try{++ // Visual v1 Task 4 (kept at the merge point): measured before the grade against 0.012 and on the shipped, graded++ // 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);+ foreach (var graded in new[] { false, true })- foreach (var (look, inside, beyond) in new[] {- (new Vector3(3000, 0, size.z * 0.55f), new Vector3(2500, 0, size.z * 0.55f), new Vector3(-2500, 0, size.z * 0.55f)),- (new Vector3(3000, 0, size.z - 3000), new Vector3(2500, 0, size.z - 2500), new Vector3(-2500, 0, size.z + 2500)) })+ foreach (var grid in new[] { false, true }){+ VisualToggles.Set("grade", graded);- rig.LookAt = look; rig.Distance = 120000f; rig.Yaw = 0; rig.Apply();- cam.targetTexture = rt;- yield return null;- cam.Render();- RenderTexture.active = rt;- tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); tex.Apply();- // Project while the camera still renders into the texture, so the points are in its pixels.- Color Px(Vector3 w) { var p = cam.WorldToScreenPoint(w); return tex.GetPixel((int)p.x, (int)p.y); }- var a = Px(new Vector3(inside.x, map.Terrain.SampleHeight(inside), inside.z));- var b = Px(new Vector3(beyond.x, map.Terrain.SampleHeight(inside), beyond.z));- RenderTexture.active = null; cam.targetTexture = null;- var diff = Mathf.Abs(a.r - b.r) + Mathf.Abs(a.g - b.g) + Mathf.Abs(a.b - b.b);- TestContext.WriteLine($"seam at {look}, graded={graded}: terrain sea {a}, beyond {b}, difference {diff:0.000}");- Assert.Less(diff, graded ? 0.024f : 0.012f, $"seam at {look}, graded={graded}: terrain sea {a}, beyond {b}");+ VisualToggles.Set("grid", grid);+ var cases = new[] {+ (new Vector3(3000, 0, size.z * 0.55f), new Vector3(2500, 0, size.z * 0.55f), new Vector3(-2500, 0, size.z * 0.55f)),+ (new Vector3(3000, 0, size.z - 3000), new Vector3(2500, 0, size.z - 2500), new Vector3(-2500, 0, size.z + 2500)),+ (new Vector3(3000, 0, midZ), new Vector3(600, 0, midZ), new Vector3(-600, 0, midZ)),+ (new Vector3(3000, 0, northZ), new Vector3(600, 0, northZ), new Vector3(-600, 0, northZ)) };+ foreach (var yaw in new[] { 0f, 90f, 180f, 270f })+ foreach (var (look, inside, beyond) in cases)+ {+ rig.LookAt = look; rig.Distance = 120000f; rig.Yaw = yaw; rig.TopInset = 0; rig.Apply();+ var y = map.Terrain.SampleHeight(inside);+ bool close = Mathf.Abs(inside.x) < 1000f;+ int rows = close ? 5 : 1;+ var world = new Vector3[2 * rows]; var px = new Vector2[2 * rows];+ for (int r = 0; r < rows; r++)+ {+ float dz = (r - (rows - 1) / 2f) * 2000f;+ world[2 * r] = new Vector3(inside.x, y, inside.z + dz); world[2 * r + 1] = new Vector3(beyond.x, y, beyond.z + dz);+ }+ var s = RenderSample.Render(cam, 1600, 900, world, px);+ Color a = Color.clear, b = Color.clear;+ for (int r = 0; r < rows; r++) { a += s.Mean((int)px[2 * r].x, (int)px[2 * r].y, 3) / rows; b += s.Mean((int)px[2 * r + 1].x, (int)px[2 * r + 1].y, 3) / rows; }+ var diff = Mathf.Abs(a.r - b.r) + Mathf.Abs(a.g - b.g) + Mathf.Abs(a.b - b.b);- TestContext.WriteLine($"seam grid={grid} at {look}, x +-{inside.x:0} m, yaw {yaw}: terrain sea {a}, beyond {b}, difference {diff:0.000}");- Assert.Less(diff, 0.012f, $"seam grid={grid} at {look}, x +-{inside.x:0} m, yaw {yaw}: terrain sea {a}, beyond {b}");++ float bound = graded ? 0.024f : 0.012f;++ TestContext.WriteLine($"seam graded={graded} grid={grid} at {look}, x +-{inside.x:0} m, yaw {yaw}: terrain sea {a}, beyond {b}, difference {diff:0.000} (bound {bound})");++ Assert.Less(diff, bound, $"seam graded={graded} grid={grid} at {look}, x +-{inside.x:0} m, yaw {yaw}: terrain sea {a}, beyond {b}");+ }}}- finally { rt.Release(); Object.DestroyImmediate(rt); Object.DestroyImmediate(tex); }- finally { VisualToggles.Set("grid", true); }++ finally { VisualToggles.Set("grid", true); VisualToggles.Set("grade", 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 isdiff --cc unity/Assets/Tests/EditMode/TerrainShaderTests.csindex 000000000,49503bcd9..8046cf18dmode 000000,100644..100644--- a/unity/Assets/Tests/EditMode/TerrainShaderTests.cs+++ b/unity/Assets/Tests/EditMode/TerrainShaderTests.cs@@@ -1,0 -1,278 +1,281 @@@+ #nullable enable+ using System.Collections;+ using System.Linq;+ using NUnit.Framework;+ using Statecraft.Game;+ using Statecraft.Game.Map;+ using UnityEditor;+ using UnityEditor.SceneManagement;+ using UnityEngine;+ using UnityEngine.TestTools;++ /// <summary>Plan Task 6: the Statecraft terrain graph, its baked inputs and what they do on screen.</summary>+ public class TerrainShaderTests+ {+ const string TerrainMatPath = "Assets/Materials/Terrain.mat";++ [TearDown]- public void Reset() { EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }++ public void Reset() { RenderSample.TiltShift(true); EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }++ static MapScene OpenMap()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();++ // Every render here measures colour or local detail: Track A's tilt-shift blurs the top and bottom bands (task-3++ // carry m6, applied at the merge point), so it is off; the TearDown turns it back on.++ RenderSample.TiltShift(false);+ return map;+ }++ /// <summary>Review C1, the positive half of the Task 6 gate: the generated passes include StatecraftTerrain.hlsl (the Custom+ /// Function is in File mode), and the HLSL really paints the terrain: with a magenta biome texture a flat coastal-plain+ /// pixel comes out magenta, not black or the sea colour.</summary>+ [UnityTest]+ public IEnumerator TheCustomFunctionDrivesTheTerrain()+ {+ var shader = AssetDatabase.LoadAssetAtPath<Material>(TerrainMatPath).shader;+ var data = ShaderUtil.GetShaderData(shader);+ int including = 0;+ for (int s = 0; s < data.SubshaderCount; s++)+ {+ var sub = data.GetSerializedSubshader(s);+ for (int p = 0; p < sub.PassCount; p++) if (sub.GetPass(p).SourceCode.Contains("StatecraftTerrain.hlsl")) including++;+ }+ Assert.Greater(including, 0, "no generated pass includes StatecraftTerrain.hlsl: the Custom Function is not in File mode");+ // Review I2: no node may compute at the template's half precision (mediump on GLES3 phones: ~210 m UV steps).+ for (int s = 0; s < data.SubshaderCount; s++)+ {+ var sub = data.GetSerializedSubshader(s);+ for (int p = 0; p < sub.PassCount; p++)+ Assert.IsFalse(System.Text.RegularExpressions.Regex.IsMatch(sub.GetPass(p).SourceCode, @"\bhalf[234]? _UV_"),+ $"pass '{sub.GetPass(p).Name}' computes the terrain UV at half precision");+ }+ var map = OpenMap();+ yield return null;+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ // A flat coastal-plain point (review N7): no rock blend and no stone tint can stand between the texture and the screen.+ var plain = map.Frame.ToWorld(34.90, 31.95, 0); plain.y = map.Terrain.SampleHeight(plain);+ rig.LookAt = plain; rig.Distance = 30000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ var magenta = new Texture2D(1, 1, TextureFormat.RGBA32, false); magenta.SetPixel(0, 0, Color.magenta); magenta.Apply();+ var real = Shader.GetGlobalTexture(MapShaderGlobals.Biome);+ try+ {+ Shader.SetGlobalTexture(MapShaderGlobals.Biome, magenta);+ var px = new Vector2[1];+ var s = RenderSample.Render(cam, 480, 270, new[] { plain }, px);+ var c = s.Mean((int)px[0].x, (int)px[0].y, 2);+ TestContext.WriteLine($"land with a magenta biome texture: {c}");+ Assert.Greater(c.r + c.g + c.b, 0.15f, "not black");+ Assert.Greater(Mathf.Min(c.r, c.b), c.g + 0.1f, "magenta: the biome texture reaches the screen through the HLSL");+ }+ finally { Shader.SetGlobalTexture(MapShaderGlobals.Biome, real); Object.DestroyImmediate(magenta); }+ }++ [Test]+ public void TheTerrainUsesTheStatecraftGraphWithItsBakedTextures()+ {+ var mat = AssetDatabase.LoadAssetAtPath<Material>(TerrainMatPath);+ Assert.AreEqual("Statecraft/StatecraftTerrain", mat.shader.name);+ Assert.IsFalse(ShaderUtil.ShaderHasError(mat.shader), string.Join("\n", ShaderUtil.GetShaderMessages(mat.shader).Select(m => m.message)));+ Assert.AreEqual(AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Bake), mat.GetTexture("_ScBakeTex"));+ Assert.AreEqual(AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Coast), mat.GetTexture("_ScCoastTex"));+ Assert.AreEqual(AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Ao), mat.GetTexture("_ScAoTex"));+ CollectionAssert.AreEquivalent(MapBuilder.BiomeColours.Keys, MapPalette.Ground.Keys, "a ground colour for every biome");+ }++ [Test]+ public void TheTerrainShaderCompilesForWebGL2() =>+ CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(AssetDatabase.LoadAssetAtPath<Material>(TerrainMatPath).shader));++ [Test]+ public void TheBakedTexturesImportAsLinearClampedData()+ {+ var bake = AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Bake);+ var coast = AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Coast);+ var ao = AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Ao);+ foreach (var t in new[] { bake, coast, ao })+ {+ Assert.AreEqual(2048, t.width, t.name); Assert.AreEqual(2048, t.height, t.name);+ Assert.IsFalse(t.isDataSRGB, t.name + " is data, not colour");+ Assert.AreEqual(TextureWrapMode.Clamp, t.wrapMode, t.name);+ Assert.Greater(t.mipmapCount, 1, t.name);+ Assert.AreEqual(FilterMode.Trilinear, t.filterMode, t.name + ": no mip seams across the pitched view (review M5)");+ }+ Assert.AreEqual(2, bake.anisoLevel, "the bake is seen at a grazing angle");+ Assert.AreEqual(TextureFormat.R8, coast.format, "one uncompressed channel: compression blocks would show in the foam band");+ Assert.AreEqual(TextureFormat.R8, ao.format, "one uncompressed channel: BC1 banded the AO on broad slopes");+ }++ [Test]+ public void TheTerrainDrawsInOnePassAndNeverFallsBackToItsBasemap()+ {+ var terrain = OpenMap().Terrain;+ Assert.AreEqual(1, terrain.terrainData.terrainLayers.Length, "one layer: one pass (7 layers drew every pixel twice)");+ Assert.GreaterOrEqual(terrain.basemapDistance, 1e6f, "the camera is always farther than the 1 km default");+ }++ [Test]+ public void TheBiomeTextureIsOwnedByTheMapAndSetForTheShaders()+ {+ var map = OpenMap();+ var biome = Shader.GetGlobalTexture(MapShaderGlobals.Biome);+ Assert.IsNotNull(biome); Assert.AreEqual(MapBuilder.BiomeTextureResolution, biome.width);+ Assert.IsFalse(biome.isReadable, "no CPU copy of the 1024² texture stays on the heap (review M4)");+ Assert.AreEqual(FilterMode.Trilinear, biome.filterMode, "no mip seams across the pitched view (review M5)");+ var m = Shader.GetGlobalVector(MapShaderGlobals.Map);+ Assert.AreEqual(map.Terrain.terrainData.size.x, m.x, 1f); Assert.AreEqual(map.Terrain.terrainData.size.z, m.y, 1f);+ Assert.AreEqual(map.Hexes.hex_size_km * 1000f, Shader.GetGlobalVector(MapShaderGlobals.MapOrigin).w, 1e-3f);+ CollectionAssert.Contains(VisualToggles.Names, "haze");+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ Assert.IsTrue(biome == null, "destroyed with the map");+ }++ /// <summary>Rendered by Tel Aviv: 10 km offshore is the sea colour, 10 km inland the ground colour.</summary>+ [UnityTest]+ public IEnumerator TheCoastSeparatesLandFromSea()+ {+ var map = OpenMap();+ yield return null;+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ rig.LookAt = map.Frame.ToWorld(34.78, 32.08, 0); rig.Distance = 60000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ var sea = map.Frame.ToWorld(34.66, 32.08, 0); var land = map.Frame.ToWorld(34.89, 32.08, 0);+ sea.y = map.Terrain.SampleHeight(sea); land.y = map.Terrain.SampleHeight(land);+ var px = new Vector2[2];+ var s = RenderSample.Render(cam, 960, 540, new[] { sea, land }, px);+ Color a = s.Mean((int)px[0].x, (int)px[0].y, 3), b = s.Mean((int)px[1].x, (int)px[1].y, 3);+ TestContext.WriteLine($"sea {a}, land {b}");+ Assert.Greater(a.b, a.r + 0.15f, "sea"); Assert.Greater(b.r, b.b + 0.05f, "land");+ }++ /// <summary>Rendered over the Judean hills: the bakes (AO, curvature, sky-view) raise the relief's local contrast+ /// (RenderSample.GradientEnergy) by at least 8% against a neutral bake (AO 1, curvature 0.5, sky 1). Local, not the+ /// frame's luma spread: this view takes in the Dead Sea (about 7% of the frame), whose land-to-sea step is about a+ /// quarter to a third of the frame's variance and shrinks as the AO darkens the land, cancelling the relief's gain+ /// (LumaStd measured 0.0830 -> 0.0827 while the gradient rose 13%).+ /// Terrain.mat is changed in memory only and restored.</summary>+ [UnityTest]+ public IEnumerator TheBakesCarveTheRelief()+ {+ var map = OpenMap();+ yield return null;+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ rig.LookAt = map.Frame.ToWorld(35.25, 31.70, 0); rig.Distance = 45000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();+ var mat = AssetDatabase.LoadAssetAtPath<Material>(TerrainMatPath);+ var real = mat.GetTexture("_ScBakeTex"); var realAo = mat.GetTexture("_ScAoTex");+ var neutral = new Texture2D(1, 1, TextureFormat.RGBA32, false, true);+ neutral.SetPixel(0, 0, new Color(1f, 0.5f, 1f, 1f)); neutral.Apply();+ try+ {+ var carved = RenderSample.Render(cam, 480, 270);+ mat.SetTexture("_ScBakeTex", neutral); mat.SetTexture("_ScAoTex", Texture2D.whiteTexture);+ var plain = RenderSample.Render(cam, 480, 270);+ TestContext.WriteLine($"relief gradient {plain.GradientEnergy(0f, 1f):0.0000} -> {carved.GradientEnergy(0f, 1f):0.0000}");+ Assert.Greater(carved.GradientEnergy(0f, 1f), plain.GradientEnergy(0f, 1f) * 1.08f);+ }+ finally { mat.SetTexture("_ScBakeTex", real); mat.SetTexture("_ScAoTex", realAo); Object.DestroyImmediate(neutral); }+ }++ /// <summary>Rendered at the country-wide pose: the haze moves the far (top) band more than the near (bottom) band, across+ /// the full width. Task 6 sampled only the land column x 0.45..0.6, because then only the land carried haze and the far+ /// band's sea and border skirt hid the effect (full width: far 0.023, near 0.026). Since Task 7 the sea on both sides+ /// takes the water haze, so the full width is measured again (Task 7 fix round 1).</summary>+ [UnityTest]+ public IEnumerator TheHazeThickensWithDistance()+ {+ var map = OpenMap();+ yield return null;+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ PromoPose.Diorama02.Apply(rig, map.Frame); rig.TopInset = 0; rig.Apply();+ VisualToggles.Set("haze", false); var clear = RenderSample.Render(cam, 480, 270);+ VisualToggles.Set("haze", true); var hazy = RenderSample.Render(cam, 480, 270);+ const float x0 = 0f, x1 = 1f;+ float far = Mathf.Abs(hazy.MeanLuma(x0, 0.8f, x1, 0.95f) - clear.MeanLuma(x0, 0.8f, x1, 0.95f));+ float near = Mathf.Abs(hazy.MeanLuma(x0, 0.05f, x1, 0.2f) - clear.MeanLuma(x0, 0.05f, x1, 0.2f));+ TestContext.WriteLine($"haze shift far {far:0.000}, near {near:0.000}");+ Assert.Greater(far, near + 0.005f);+ }++ /// <summary>Review I1: the haze is a depth cue, not a veil. At the country-wide pose the nearest land (bottom band,+ /// about 205 km away) is inside the haze's start distance and barely moves; the middle and far bands move more and+ /// more. Full width, as in TheHazeThickensWithDistance (Task 7 fix round 1: the sea is hazed too).</summary>+ [UnityTest]+ public IEnumerator TheHazeStartsBeyondTheNearestDioramaLandAndGrowsWithDistance()+ {+ var map = OpenMap();+ yield return null;+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ PromoPose.Diorama02.Apply(rig, map.Frame); rig.TopInset = 0; rig.Apply();+ VisualToggles.Set("haze", false); var clear = RenderSample.Render(cam, 480, 270);+ VisualToggles.Set("haze", true); var hazy = RenderSample.Render(cam, 480, 270);+ float Shift(float y0, float y1) => Mathf.Abs(hazy.MeanLuma(0f, y0, 1f, y1) - clear.MeanLuma(0f, y0, 1f, y1));+ float near = Shift(0.05f, 0.2f), mid = Shift(0.425f, 0.575f), far = Shift(0.8f, 0.95f);+ TestContext.WriteLine($"haze by distance near {near:0.0000}, mid {mid:0.0000}, far {far:0.0000}");+ Assert.Less(near, 0.008f, "about no haze at the nearest land");+ Assert.Greater(mid, near); Assert.Greater(far, mid + 0.005f);+ }++ /// <summary>Task 5 carry 3 / review A3: the AO the shader samples (ao.png) shows no compression banding. On broad+ /// slopes (texels whose source steps by at most one 8-bit level to the east and north neighbours) the GPU-decoded+ /// texture must not step by two levels or more between those neighbours on more than 2% of them, over the Judean+ /// slopes and the Negev plateau. Measured on the BC1 terrain_bake.png R channel this failed (Judean slopes: 404 of 681+ /// texels, 59%), so the AO is its own uncompressed R8 texture.</summary>+ [Test]+ public void TheCompressedAoShowsNoBandingOnBroadSlopes()+ {+ var ao = AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Ao);+ int n = ao.width;+ var rt = RenderTexture.GetTemporary(n, n, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);+ var gpu = new Texture2D(n, n, TextureFormat.RGBAFloat, false, true);+ var png = new Texture2D(2, 2, TextureFormat.RGBA32, false, true);+ var prev = RenderTexture.active;+ try+ {+ Graphics.Blit(ao, rt);+ RenderTexture.active = rt; gpu.ReadPixels(new Rect(0, 0, n, n), 0, 0); gpu.Apply();+ Assert.IsTrue(png.LoadImage(System.IO.File.ReadAllBytes(MapTexturePaths.Ao)));+ Assert.AreEqual(n, png.width);+ var d = gpu.GetPixels(); var s = png.GetPixels32();+ var meta = JsonUtility.FromJson<HeightmapMeta>(System.IO.File.ReadAllText(System.IO.Path.Combine(Paths.StreamingMap, "heightmap.json")));+ int X(double lon) => (int)((lon - meta.lon0) / (meta.lon1 - meta.lon0) * n);+ int Y(double lat) => (int)((lat - meta.lat0) / (meta.lat1 - meta.lat0) * n); // texture row 0 is south+ foreach (var (name, lon0, lon1, lat0, lat1) in new[] { ("Judean slopes", 35.05, 35.30, 31.60, 31.90), ("Negev plateau", 34.70, 35.10, 30.40, 30.80) })+ {+ int broad = 0, stepped = 0;+ for (int y = Y(lat0) + 2; y < Y(lat1) - 2; y++)+ for (int x = X(lon0) + 2; x < X(lon1) - 2; x++)+ {+ int S(int xx, int yy) => s[yy * n + xx].r;+ // Broad: the source steps by at most one 8-bit level to both neighbours.+ if (Mathf.Max(Mathf.Abs(S(x + 1, y) - S(x, y)), Mathf.Abs(S(x, y + 1) - S(x, y))) > 1) continue;+ broad++;+ float r = d[y * n + x].r;+ float step = Mathf.Max(Mathf.Abs(d[y * n + x + 1].r - r), Mathf.Abs(d[(y + 1) * n + x].r - r)) * 255f;+ if (step >= 2f - 1e-3f) stepped++;+ }+ float share = (float)stepped / Mathf.Max(1, broad);+ TestContext.WriteLine($"AO banding {name}: {stepped} of {broad} broad-slope texels step >= 2 levels ({share:P2})");+ Assert.Greater(broad, 500, name);+ Assert.LessOrEqual(share, 0.02f, name);+ }+ }+ finally+ {+ RenderTexture.active = prev; RenderTexture.ReleaseTemporary(rt);+ Object.DestroyImmediate(gpu); Object.DestroyImmediate(png);+ }+ }++ /// <summary>Review A3: the art checkpoint also shoots the 6 km hero zoom over the Judean slopes and the Negev plateau+ /// (with the haze off), where AO steps would show; they are checks, not promo matches, so PromoPose.All (the profile's+ /// and the editor capture's list) keeps its two poses.</summary>+ [Test]+ public void TheCheckpointShootsTheHeroZoomOverTheJudeanSlopesAndTheNegev()+ {+ var checks = PromoPose.CloseChecks;+ CollectionAssert.AreEqual(new[] { "hero06judea", "hero06negev" }, checks.Select(p => p.Name).ToArray());+ Assert.AreEqual((35.15, 31.78), (checks[0].Lon, checks[0].Lat));+ Assert.AreEqual((34.90, 30.60), (checks[1].Lon, checks[1].Lat));+ foreach (var p in checks) Assert.AreEqual(6000f, p.Distance, p.Name);+ Assert.IsFalse(PromoPose.All.Any(p => checks.Any(c => c.Name == p.Name)));+ }+ }