Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

fix(visual): Task 10 review fixes: the no-op bloom toggle removed, desktop render scale and web SSAO pinned, docs corrected

eyalgolanc321017d4f99
diff --git a/docs/dev-setup.md b/docs/dev-setup.md
index 16f6c0ff3..fc8a76e32 100644
--- a/docs/dev-setup.md
+++ b/docs/dev-setup.md
@@ -35,9 +35,10 @@
batch commands in `uv run tools/machine_lock.py --shared -- ...`; `tools/art_checkpoint.sh [--no-build] <name>` for the
owner's side-by-side images.
- Quality tiers: `uv run tools/machine_lock.py --shared -- "$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -executeMethod Statecraft.Game.EditorTools.QualityTiers.Apply`
- writes the decisions in `QualityTierValues` to the URP assets (docs/visual-v1.md "Tier decisions"). The macOS player
- does not run in the background (`runInBackground` is off): start `-vprofile` with the player window in front, or it
- waits at `GAME OK` until it is.
+ writes the decisions in `QualityTierValues` to the URP assets (docs/visual-v1.md "Tier decisions"). The built macOS
+ player (`unity/Builds/Mac/Statecraft.app`) does not run in the background (`runInBackground` is off): its `-vprofile`
+ waits at `GAME OK` until that player's window is in front (`open -a unity/Builds/Mac/Statecraft.app` brings it
+ forward). Never script, `open -a` or AppleScript the Unity editor itself.
- A player build rewrites some URP asset and player-setting fields as build-time caches; drop them afterwards with
`git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset`.
- Play a build locally: `python3 -m http.server 8000 --directory unity/Builds/Web-disabled`, then open http://localhost:8000/.
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 568edde60..ac306decd 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -642,10 +642,10 @@ beyond budget + the larger spread.
| Render scale | 1.0 (was 0.8) | 1.0 | all three rules hold at 1.0 (headless p95 <= 16.7 ms, headed <= 20 ms, DPR 2 <= 33 ms): headless `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.58 spread_ms=0.18 median_p95_ms=5.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=9.96 spread_ms=0.05 median_p95_ms=11.00`; headed `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=2.39 spread_ms=0.10 median_p95_ms=5.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=10.14 spread_ms=0.20 median_p95_ms=11.00`; DPR 2 `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=4.01 spread_ms=0.00 median_p95_ms=5.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=18.59 spread_ms=0.36 median_p95_ms=19.00` |
| Fill-rate stress (DPR 2, headed, final at 1.0) | `PROFILE summary visual=all pose=gameplay03 runs=3 median_avg_ms=3.78 spread_ms=0.05 median_p95_ms=5.00`<br>`PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=18.08 spread_ms=0.06 median_p95_ms=20.00` | — | a stand-in for a GPU with a quarter of the fill rate; under the 33 ms floor with 13 ms to spare |
| Boot | `BOOT map_build_ms median=432 runs=3 cpu=1`<br>`BOOT first_frame_ms median=3563 runs=3 cpu=1`<br>`BOOT map_build_ms median=1751 runs=3 cpu=4`<br>`BOOT first_frame_ms median=6797 runs=3 cpu=4`<br>`BOOT map_build_ms median=426 runs=3 cpu=1`<br>`BOOT first_frame_ms median=3477 runs=3 cpu=1`<br>`BOOT map_build_ms median=1746 runs=3 cpu=4`<br>`BOOT first_frame_ms median=6696 runs=3 cpu=4` (Step 1, then final) | — | each within max(300 ms, 50%) of its Task 1 baseline (443 / 3547; 1813 / 6963 ms); both runs exit 0 |
-| Shadows | 1 cascade, 2048, hard | 4 cascades, 2048, soft | `-shadows` at diorama02: Step 1 headless 10.32 - 7.36 = **2.96 ms** (spread 0.32: over 2.82), headed 2.90 (0.41: within), DPR 2 4.99 (0.23); final headless 2.89 (0.41: within 2.91), headed 2.92 (0.29: **over** 2.79), DPR 2 4.80. A 1024 build measured 2.84 (headless, spread 0.09), 2.94 (headed) and 5.03 (DPR 2): the map's resolution is not the cost (the caster pass redraws the whole map's geometry at the overview), so 1024 would blur the relief for nothing. **2048 kept; the overrun (about 0.1-0.4 ms beyond budget + spread at the 250 km overview only) is named here.** gameplay03: 0.33 ms final |
+| Shadows | 1 cascade, 2048, hard | 4 cascades, 2048, soft | `-shadows` at diorama02: Step 1 headless 10.32 - 7.36 = **2.96 ms** (spread 0.32: over 2.82), headed 2.90 (0.41: within), DPR 2 4.99 (0.23); final headless 2.89 (0.41: within 2.91), headed 2.92 (0.29: **over** 2.79), DPR 2 4.80. A 1024 build measured 2.84 (headless, spread 0.09), 2.94 (headed) and 5.03 (DPR 2): (1024 lines, headless: `PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=10.08 spread_ms=0.09 median_p95_ms=11.00`<br>`PROFILE summary visual=-shadows pose=diorama02 runs=3 median_avg_ms=7.24 spread_ms=0.03 median_p95_ms=9.00`<br>headed: `PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=10.20 spread_ms=0.28 median_p95_ms=11.00`<br>`PROFILE summary visual=-shadows pose=diorama02 runs=3 median_avg_ms=7.26 spread_ms=0.13 median_p95_ms=9.00`<br>DPR 2: `PROFILE summary visual=all pose=diorama02 runs=3 median_avg_ms=18.34 spread_ms=0.21 median_p95_ms=19.00`<br>`PROFILE summary visual=-shadows pose=diorama02 runs=3 median_avg_ms=13.31 spread_ms=0.10 median_p95_ms=14.00`): the map's resolution is not the cost (the caster pass redraws the whole map's geometry at the overview), so 1024 would blur the relief for nothing. **2048 kept; the overrun (about 0.1-0.4 ms beyond budget + spread at the 250 km overview only) is named here.** gameplay03: 0.33 ms final |
| Tilt-shift | downsample 2 | downsample 2 | `-tiltshift` cost: Step 1 headless 0.09 / 0.09 ms (gameplay03 / diorama02), final headless 0.03 / -0.04, DPR 2 0.29 / -0.04: far under 1.5 ms |
| Tilt-shift bottom band | unchanged (HalfWidth 0.13 / Feather 0.17) | same | final gameplay03 shot against `?notiltshift`, gradient energy per 1% row band (columns 30-80%): fully blurred (ratio <= 0.05-0.09) from under the bar to about 26% and from about 78-83% to the bottom, so the bottom band is 17-22% against the promo's ~15%. The 2-7 point gap is the one Task 3 offered the owner (bottom-only 0.16 / 0.19); no owner verdict yet, so not changed |
-| Bloom | off (was the URP template's 0.25 above 1) | off | rendered on both tiers at both poses it changed at most 2/255 of any pixel (mean 0.25/255 at diorama02, warmth +0.0003, `GradeTests.TheBloomToggleSwitchesThePipelineBloom`); `-bloom` cost Step 1 headless 0.37 ms (diorama02), headed 0.18, macOS 0.17 / 0.13. Off in the pipeline profile (`Settings/SampleSceneProfile`), which keeps its Neutral tonemapper (the stripping guarantee, GradeTests) |
+| Bloom | off (was the URP template's 0.25 above 1) | off | rendered on both tiers at both poses it changed at most 2/255 of any pixel (mean 0.25/255 at diorama02, warmth +0.0003, measured with a temporary `bloom` toggle, commit `8d45a93`, removed in fix round 1 once bloom shipped off); `-bloom` cost Step 1 headless 0.37 ms (diorama02), headed 0.18, macOS 0.17 / 0.13. Off in the pipeline profile (`Settings/SampleSceneProfile`), which keeps its Neutral tonemapper (the stripping guarantee, GradeTests) |
| SSAO | none | off (was on) | metre radius cannot reach km relief; baked AO replaces it (Tasks 5-6) |
| Grade, vignette, haze, grid, water, labels | on | on | Step 1 headless costs (gameplay03 / diorama02, ms): grade -0.02 / 0.27, haze 0.08 / 0.11, grid 0.07 / -0.14, water 0.04 / 0.14, labels -0.14 / -0.02; final headless: grade 0.00 / -0.03, haze -0.03 / -0.10, grid 0.00 / -0.01, water -0.05 / -0.06, labels -0.01 / 0.01; all within budget. The grid, unmeasured on a quiet machine since Task 8, costs nothing measurable |
| Baked shading texture | block-compressed | block-compressed | review minor 9: recorded, not changed (mobile browsers are outside the 1920x1080 target) |
@@ -657,8 +657,15 @@ Colour after the decisions (WebGL `?shot`, t10-tiers against t-merge-r3): dioram
0.5655 (+0.0009, away from the promo's 0.382 by a rounding-level step: the 1:1 render), contrast 0.1959 -> 0.1960, warmth
0.0774 -> 0.0771. The sea, palette and grade are untouched.
-The macOS player does not run in the background (`runInBackground` is off): its `-vprofile` waits at `GAME OK` until its
-window is in front.
+The built macOS player (`unity/Builds/Mac/Statecraft.app`) does not run in the background (`runInBackground` is off): its
+`-vprofile` waits at `GAME OK` until its window is in front. Bring that player forward (Task 10 used
+`open -a unity/Builds/Mac/Statecraft.app`); never script, `open -a` or AppleScript the Unity editor (team rule).
+
+The `-bloom` lines below come from the temporary toggle (`8d45a93`); in the final runs bloom already ships off, so
+`-bloom` equals `all` there. At gameplay03 in Step 1 (scale 0.8), `-bloom`, `-shadows` and `none` all read about 0.4 ms
+*above* `all` (headless 2.51 / 2.40 / 2.40 against 2.03; headed 2.34 / 2.37 / 2.24 against 1.85). `none` cannot really be
+slower than `all`; the pose runs at about 2 ms, at the WebGL clock's ~1 ms resolution, and the readings look bimodal
+(~2.0 / ~2.4 ms). Unexplained; it changes no decision (every gameplay03 cost is far inside its budget).
### Final measurements
Step 1 headless (scale 0.80):
diff --git a/unity/Assets/Scripts/Map/CameraRig.cs b/unity/Assets/Scripts/Map/CameraRig.cs
index 5dd367282..bdb2467a7 100644
--- a/unity/Assets/Scripts/Map/CameraRig.cs
+++ b/unity/Assets/Scripts/Map/CameraRig.cs
@@ -51,10 +51,6 @@ namespace Statecraft.Game.Map
TeardownActions.Add(TiltShift.Reset);
TeardownActions.Add(VisualToggles.Register("tiltshift", on => TiltShift.Enabled = on));
TeardownActions.Add(VisualToggles.Register("grade", on => MapGrade.SetActive(vol.profile, on)));
- // Prices the pipeline assets' own bloom (Settings/SampleSceneProfile; off on both tiers since Task 10, QualityTierValues.Bloom):
- // off overrides the intensity with 0, on leaves the pipeline profile in charge.
- var bloom = vol.profile.Add<Bloom>(true); bloom.intensity.Override(0f); bloom.active = false;
- TeardownActions.Add(VisualToggles.Register("bloom", on => bloom.active = !on));
if (TiltShift.OffRequested()) TiltShift.Enabled = false;
initialised = true;
Apply();
diff --git a/unity/Assets/Scripts/Map/QualityTierValues.cs b/unity/Assets/Scripts/Map/QualityTierValues.cs
index 067ccdb5d..393bd029e 100644
--- a/unity/Assets/Scripts/Map/QualityTierValues.cs
+++ b/unity/Assets/Scripts/Map/QualityTierValues.cs
@@ -13,9 +13,10 @@ namespace Statecraft.Game.Map
/// cost is the caster pass's geometry, not the map's resolution, and halving it would only blur the relief.</summary>
public const int WebShadowMap = 2048, WebTiltShiftDownsample = 2;
public const int DesktopShadowMap = 2048, DesktopTiltShiftDownsample = 2;
- /// <summary>The pipeline profile's bloom (the URP template's 0.25 above 1), off on both tiers: rendered, it changed at
- /// most 2/255 of any pixel at either pose on either tier, for 0.1-0.4 ms on the web and 0.13-0.17 ms on the macOS
- /// player.</summary>
+ /// <summary>The pipeline profile's bloom (the URP template's 0.25 above 1), off on both tiers. Measured with a
+ /// temporary "bloom" toggle (commit 8d45a93, removed once bloom shipped off): rendered on both tiers at both promo
+ /// poses it changed at most 2/255 of any pixel (mean 0.25/255 at diorama02, warmth +0.0003), for 0.37 ms (headless),
+ /// 0.18 ms (headed) and 0.17 / 0.13 ms (macOS) at diorama02 (docs/visual-v1.md "Tier decisions").</summary>
public const bool Bloom = false;
}
}
diff --git a/unity/Assets/Tests/EditMode/GradeTests.cs b/unity/Assets/Tests/EditMode/GradeTests.cs
index 083dea702..0e78a50ca 100644
--- a/unity/Assets/Tests/EditMode/GradeTests.cs
+++ b/unity/Assets/Tests/EditMode/GradeTests.cs
@@ -171,50 +171,6 @@ public class GradeTests
Assert.That(ratio, Is.InRange(0.98f, 1.12f));
}
- /// <summary>Task 10: the "bloom" toggle prices the pipeline assets' own bloom (Settings/SampleSceneProfile: the template's
- /// 0.25 above 1; off on both tiers since this measurement, QualityTierValues.Bloom), so the profile can measure it like every other feature. Off, the map's runtime profile overrides it with
- /// intensity 0; on, that override is inactive and the pipeline profile decides. Rendered at both promo poses on both
- /// tiers (0 web, 1 desktop), the bloom's whole effect on the frame is logged for the tier decision (docs/visual-v1.md
- /// "Tier decisions"); bloom only ever adds light.</summary>
- [UnityTest]
- public IEnumerator TheBloomToggleSwitchesThePipelineBloom([Values(0, 1)] int level)
- {
- int previous = QualitySettings.GetQualityLevel();
- QualitySettings.SetQualityLevel(level, false);
- try
- {
- var (map, rig, profile) = Open();
- yield return null;
- CollectionAssert.Contains(VisualToggles.Names, "bloom");
- VisualToggles.Set("bloom", false);
- Assert.IsTrue(profile.TryGet<Bloom>(out var bloom), "the runtime profile carries the bloom override");
- Assert.IsTrue(bloom.active && bloom.intensity.overrideState && bloom.intensity.value == 0f, "off: intensity 0 wins");
- VisualToggles.Set("bloom", true);
- Assert.IsFalse(bloom.active, "on: the pipeline profile's bloom applies");
- var cam = Camera.main;
- static float Warmth(RenderSample s) { float w = 0f; foreach (var c in s.Pixels) w += c.r - c.b; return w / s.Pixels.Length; }
- foreach (var pose in PromoPose.All)
- {
- pose.Apply(rig, map.Frame);
- VisualToggles.Set("bloom", true); var on = RenderSample.Render(cam, 480, 270);
- VisualToggles.Set("bloom", false); var off = RenderSample.Render(cam, 480, 270);
- VisualToggles.Set("bloom", true);
- float sum = 0f, max = 0f; int changed = 0;
- for (int i = 0; i < on.Pixels.Length; i++)
- {
- float d = Mathf.Max(Mathf.Abs(on.Pixels[i].r - off.Pixels[i].r), Mathf.Abs(on.Pixels[i].g - off.Pixels[i].g), Mathf.Abs(on.Pixels[i].b - off.Pixels[i].b));
- sum += d; max = Mathf.Max(max, d); if (d > 1.5f / 255f) changed++;
- }
- float lumaOn = on.MeanLuma(0f, 0f, 1f, 1f), lumaOff = off.MeanLuma(0f, 0f, 1f, 1f);
- TestContext.WriteLine($"level {level} {pose.Name}: bloom mean |d| {sum / on.Pixels.Length * 255f:0.00}/255, max {max * 255f:0}/255, " +
- $"pixels changed > 1.5/255 {(float)changed / on.Pixels.Length:P2}; luma {lumaOff:0.0000} -> {lumaOn:0.0000}; " +
- $"saturation {off.MeanSaturation():0.0000} -> {on.MeanSaturation():0.0000}; warmth {Warmth(off):0.0000} -> {Warmth(on):0.0000}");
- Assert.GreaterOrEqual(lumaOn + 1e-4f, lumaOff, "bloom only adds light");
- }
- }
- finally { QualitySettings.SetQualityLevel(previous, false); }
- }
-
/// <summary>Rendered: MapGrade's vignette darkens the corners relative to the centre more than the vignette it replaces
/// (the pipeline's template profile, Settings/SampleSceneProfile, applies a 0.2 black one, which "plain" still shows).</summary>
[UnityTest]
diff --git a/unity/Assets/Tests/EditMode/QualityTierTests.cs b/unity/Assets/Tests/EditMode/QualityTierTests.cs
index 20b35d1b1..b7e5251a0 100644
--- a/unity/Assets/Tests/EditMode/QualityTierTests.cs
+++ b/unity/Assets/Tests/EditMode/QualityTierTests.cs
@@ -10,6 +10,7 @@ using UnityEngine.Rendering.Universal;
/// <summary>Plan Task 10: the tier decisions recorded in docs/visual-v1.md, pinned on the URP assets.</summary>
public class QualityTierTests
{
+ // The asset paths repeat QualityTiers.WebAsset etc.: that class is in the editor assembly, which this one cannot see.
static SerializedObject Asset(string path) => new SerializedObject(AssetDatabase.LoadAssetAtPath<UniversalRenderPipelineAsset>(path));
[Test]
@@ -24,6 +25,8 @@ public class QualityTierTests
Assert.AreEqual(QualityTierValues.WebRenderScale, web.FindProperty("m_RenderScale").floatValue, 1e-4f);
var renderer = new SerializedObject(AssetDatabase.LoadAssetAtPath<UniversalRendererData>("Assets/Settings/Mobile_Renderer.asset"));
Assert.AreEqual(0, renderer.FindProperty("m_RenderingMode").intValue, "Forward on WebGL (research notes 2.1)");
+ var webData = AssetDatabase.LoadAssetAtPath<UniversalRendererData>("Assets/Settings/Mobile_Renderer.asset");
+ Assert.IsFalse(webData.rendererFeatures.Any(f => f != null && f.isActive && f.GetType().Name == "ScreenSpaceAmbientOcclusion"), "no SSAO on the web");
StringAssert.IsMatch(@"(?m)^\s+WebGL: 0\s*$", System.IO.File.ReadAllText("ProjectSettings/QualitySettings.asset"), "WebGL runs the Mobile tier (level 0)");
}
@@ -32,6 +35,7 @@ public class QualityTierTests
{
var pc = Asset("Assets/Settings/PC_RPAsset.asset");
Assert.AreEqual(4, pc.FindProperty("m_ShadowCascadeCount").intValue);
+ Assert.AreEqual(1f, pc.FindProperty("m_RenderScale").floatValue, 1e-4f, "desktop renders 1:1");
Assert.AreEqual(QualityTierValues.DesktopShadowMap, pc.FindProperty("m_MainLightShadowmapResolution").intValue);
Assert.IsTrue(pc.FindProperty("m_SoftShadowsSupported").boolValue);
Assert.IsFalse(pc.FindProperty("m_RequireDepthTexture").boolValue);
@@ -51,7 +55,7 @@ public class QualityTierTests
}
}
/// <summary>The pipeline assets' own volume profile: bloom as decided (rendered, the template's 0.25 above 1 changed at
- /// most 2/255 of any pixel at either pose on either tier: GradeTests.TheBloomToggleSwitchesThePipelineBloom), and the
+ /// most 2/255 of any pixel at either pose on either tier: measured in commit 8d45a93, docs/visual-v1.md "Tier decisions"), and the
/// Neutral tonemapper kept, which keeps its variants in builds (GradeTests).</summary>
[Test]
public void BothTiersBloomAsDecidedAndKeepTheNeutralTonemapper()