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.

test(visual): Task 4 review round 1: seam checked both before the grade and graded, honest stripping and vignette notes

eyalgolan5fa3fa931a32
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 82ea22915..af32bdbe0 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -146,7 +146,10 @@ it. The 2% floor stays: it allows a third of the measured share to be lost to th
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).** `MapLighting.AmbientProbe` builds the trilight from `AddAmbientLight` plus two
+**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,
@@ -230,7 +233,7 @@ Cost `median(all) - median(-tiltshift)`, all within the 1.5 ms budget and within
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, and today the template profile is that asset.
+- 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.
@@ -298,7 +301,11 @@ Bloom is the template's, not this plan's; Task 10 should decide whether the web
- 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 before the grade (`grade` off). The grade roughly doubles the sub-step mismatch between the terrain sea and the skirt shader, from 0.008 to 0.016 against a limit of 0.012. A per-pixel transform cannot open a seam. At the merge, Track B's patch-mean version should keep the line.
+**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`):
```
diff --git a/unity/Assets/Tests/EditMode/GradeTests.cs b/unity/Assets/Tests/EditMode/GradeTests.cs
index 57f80bad9..8a0968c09 100644
--- a/unity/Assets/Tests/EditMode/GradeTests.cs
+++ b/unity/Assets/Tests/EditMode/GradeTests.cs
@@ -38,7 +38,8 @@ public class GradeTests
// The runtime profile is invisible to URP's build-time post-processing stripping, which keeps the tonemapper's
// uber-shader variants only when some VolumeProfile asset under Assets has a Tonemapping component (URP 17.3
// ShaderBuildPreprocessor.GetSupportedFeaturesFromVolumes; strip-unused-post-processing is on). The pipeline assets'
- // own profile (Settings/SampleSceneProfile) has one; without it the WebGL player would silently drop Neutral.
+ // own profile (Settings/SampleSceneProfile) and the global settings' Settings/DefaultVolumeProfile both carry one today,
+ // so this fails only if every such asset loses it, which would make the WebGL player silently drop Neutral.
bool kept = false;
foreach (var guid in AssetDatabase.FindAssets("t:VolumeProfile", new[] { "Assets" }))
kept |= AssetDatabase.LoadAssetAtPath<VolumeProfile>(AssetDatabase.GUIDToAssetPath(guid))?.Has<Tonemapping>() == true;
@@ -164,7 +165,8 @@ public class GradeTests
Assert.Greater(graded.MeanSaturation(), flat.MeanSaturation() * 1.05f);
}
- /// <summary>Rendered: the vignette darkens the corners relative to the centre.</summary>
+ /// <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]
public IEnumerator TheVignetteDarkensTheCorners()
{
diff --git a/unity/Assets/Tests/EditMode/LightingTests.cs b/unity/Assets/Tests/EditMode/LightingTests.cs
index ab446c268..30165abf2 100644
--- a/unity/Assets/Tests/EditMode/LightingTests.cs
+++ b/unity/Assets/Tests/EditMode/LightingTests.cs
@@ -70,7 +70,6 @@ public class LightingTests
RenderSettings.ambientProbe = custom;
var after = new Color[1]; RenderSettings.ambientProbe.Evaluate(new[] { Vector3.right }, after);
Assert.AreEqual(e[1].r, after[0].r, 1e-4f, "an explicit probe does not stick in Trilight mode");
- Assert.IsNull(typeof(MapLighting).GetMethod("AmbientProbe"), "MapLighting sets the colours only");
}
/// <summary>Review I1: URP fades shadows by straight-line distance from the camera, starting at (1 - cascadeBorder) of
diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs b/unity/Assets/Tests/EditMode/SettlementTests.cs
index a3da7b6c0..5e5b4656b 100644
--- a/unity/Assets/Tests/EditMode/SettlementTests.cs
+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs
@@ -372,27 +372,30 @@ public class MapSceneTests
}
/// <summary>Fix round 1 (the sea seam), rendered: at the west and north-west edges of the map, the sea on the terrain and
- /// the sea beyond it come out the same colour (the scene's own light, camera rig and post-processing).</summary>
+ /// the sea beyond it come out the same colour under the scene's own light and camera rig, measured before the grade
+ /// (0.012): the grade is a per-pixel LUT (and a vignette that is flat this close to the centre), so it cannot open a
+ /// seam, only scale one (Task 4). The shipped, graded frame is checked too, with the bound scaled by the grade's
+ /// chroma gain of about 2 (0.024).</summary>
[UnityTest]
public System.Collections.IEnumerator TheSeaBeyondTheEdgeMatchesTheTerrainSea()
{
EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
var map = Object.FindFirstObjectByType<MapScene>();
map.Build();
- // Visual v1 Task 4: measured before the grade. The grade is a per-pixel colour transform (plus a vignette that is flat
- // this close to the centre), so it cannot open a seam, but it 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 this line at the merge.
- VisualToggles.Set("grade", false);
+ // 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.
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);
try
{
+ 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)) })
{
+ VisualToggles.Set("grade", graded);
rig.LookAt = look; rig.Distance = 120000f; rig.Yaw = 0; rig.Apply();
cam.targetTexture = rt;
yield return null;
@@ -405,8 +408,8 @@ public class MapSceneTests
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}: terrain sea {a}, beyond {b}, difference {diff:0.000}");
- Assert.Less(diff, 0.012f, $"seam at {look}: terrain sea {a}, beyond {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}");
}
}
finally { rt.Release(); Object.DestroyImmediate(rt); Object.DestroyImmediate(tex); }