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.

Map: a lighter far tilt-shift band at the gameplay zoom (Fixes #390) (#399)

Eyal Golan47eac52675a7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9bee821c2..a4d2e2328 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -270,6 +270,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
It decodes to the same bytes, so the terrain is unchanged (#44).
### Fixed
+- The map's far tilt-shift band no longer blurs the far towns into a smear at the play zoom (#390). Since the map drew
+ faster (#320), the quality fallback no longer turns the tilt-shift off, and the far band showed in full. On the owner's
+ ruling it is now gently soft at the gameplay zoom, as on promo 03, and in full only at the overview. Presentation only.
- The map draws about four times faster at the gameplay zoom (#195). The water's shading moved out of the terrain's shader
into its own pass over the water and the shore, and the region borders read one texel a pixel instead of up to seven.
Since the promo sea (#138) and the borders (#206) the terrain's shader had grown large enough to slow every terrain pixel
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 46b70ade7..1b68242a5 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -230,6 +230,7 @@ Two bands, blurred by a half-resolution render-graph pass (`TiltShiftFeature` on
- 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.
+- since issue #390, the far (top) band is lighter at the gameplay zoom (see "Issue #390" below).
URP's far-only Gaussian DoF is retired. Toggle: `tiltshift`; the URL flag `notiltshift` (desktop: `-notiltshift`) boots with
it off.
@@ -720,7 +721,7 @@ beyond budget + the larger spread.
| 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): (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 |
+| 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). Owner's ruling (2026-10-13, issue #390): the bands stay as they are, except that the far band is lighter at the gameplay zoom ("Issue #390"); the bottom band is 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, 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 |
@@ -2096,3 +2097,42 @@ blocks, village houses, red-roofed villas), Jaffa 6 → 7, Tel Aviv 8 → 7.
hitch.
- **Memory.** The water mesh keeps about 4.5 MB on the GPU (its CPU copy is dropped in players, `UploadMeshData`); placing
it from the bake allocates its 3.4 MB of bytes and about 1.5 MB of vertices, short-lived. The borders add nothing (the edge bits ride in the existing texel).
+
+## Issue #390: a lighter far tilt-shift band at the gameplay zoom
+- **What happened.** #320 did not change the tilt-shift. Before it, normal play on the development machine was slow enough
+ that the runtime quality fallback stepped down to level 3 and turned the tilt-shift off (headed Chrome, 1920x1080, New
+ Game then End Turn: `QUALITY level=1` p95 51 ms, `level=2` 45, `level=3 ... tiltshift=off` 42). #320 made the frame
+ about 3.7x faster, so the fallback stays at level 0 and the far band drew in full: Tel Aviv, Hadera and the brigade
+ token were a smear. Main before #320 with `?nofallback` draws the same frame as 4abb64f (0.109% of pixels more than 24
+ levels apart, identical gradient energy per tenth of the rows). `?shot` and `?vprofile` turn the fallback off, so the
+ gameplay03 pixel A/B never showed it.
+- **Owner's ruling (2026-10-13).** Keep a soft tilt-shift, so the game still reads like promo 03, but keep the far towns
+ readable at the play zoom; the wide views (diorama02) keep the full effect. This also settles the open bottom-band note
+ above: the bottom band is not changed.
+- **What changed.** `TiltShift.FarStrength(distance)` scales the far (top) band's radius and its blend: 0.35
+ (`FarGameplayStrength`) up to 150 km, rising to 1 at the 250 km overview. The near band is unchanged. It is one global,
+ `_ScTiltShiftFar`, set with `_ScTiltShift` in `TiltShift.Apply`: no new keyword or variant.
+- **Readability bound.** Promo 03's far band (rows 10-18% from the top, columns 30-80%) has 0.34 of the gradient energy of
+ its focus band (rows 45-60%); a sharp frame of ours (`?notiltshift`, normal play) has 0.93 there, so the promo keeps about
+ 37% of the far detail. `TiltShiftTests.TheFarBandStaysReadableAtTheGameplayZoom` asks for at least 60% (shifted / sharp,
+ rows 0.78-0.90 from the bottom, under the web bar) at 60 km and at the 120 km starting zoom. The fix keeps 0.72 and 0.69;
+ 4abb64f kept 0.17 and 0.14. `TheDioramaKeepsBothBands` asks for at most 0.30 far and 0.45 near at diorama02 (0.20 and
+ 0.33, unchanged). Mutants killed: the far strength at 1 at the gameplay zoom (4abb64f's look), a shader that ignores
+ `_ScTiltShiftFar`, a far strength stuck at 0.35 at the overview, and the far strength applied to both bands.
+- **WebGL captures**, 4abb64f against the fix. Gradient energy per tenth of the rows from the top, columns 30-80%:
+
+ | frame | build | 0-10% | 10-20% | 20-30% | 30-40% | 40-70% | 70-100% |
+ |---|---|---|---|---|---|---|---|
+ | normal play, 22 May 1948 (fallback on) | 4abb64f | 13.4 | 5.2 | 6.6 | 18.3 | 29.4 26.3 23.2 | 13.9 3.3 2.5 |
+ | | fix | 14.6 | 17.7 | 17.4 | 23.4 | 29.4 26.3 23.2 | 13.9 3.3 2.5 |
+ | | `?notiltshift` | 15.3 | 24.7 | 23.1 | 25.8 | 29.4 26.3 23.4 | 21.6 20.5 16.7 |
+ | gameplay03 (`?shot`) | 4abb64f | 12.4 | 3.4 | 4.4 | 12.1 | 17.3 17.1 17.0 | 8.9 2.8 2.2 |
+ | | fix | 13.2 | 12.7 | 13.6 | 15.0 | 17.3 17.1 17.0 | 8.9 2.8 2.2 |
+
+ diorama02 is pixel-identical (0 pixels more than 24 levels apart). The near band and the focus band do not move.
+- **Frame time** (WebGL headless `?vprofile`, 1920x1080, 2 interleaved rounds under the exclusive lock, medians): gameplay03
+ none 5.02 / 5.06 ms against 4abb64f's 5.07 / 5.20, all 7.90 / 7.99 against 7.89 / 7.87; diorama02 none 12.63 / 12.62
+ against 12.20 / 12.21, all 19.51 / 19.49 against 19.08 / 18.94. Main before #320 measured 20.98 ms at gameplay03 none
+ in the same session, so #320's gain stands. The 0.4 ms at diorama02 repeated in both rounds; there the far band's
+ strength is 1 and the frame is pixel-identical, so it is the extra uniform read and compare per tilt-shift pixel or
+ build-to-build noise, within the tilt-shift's 1.5 ms budget.
diff --git a/unity/Assets/Scripts/Map/TiltShift.cs b/unity/Assets/Scripts/Map/TiltShift.cs
index e65bbc324..57d0d6b05 100644
--- a/unity/Assets/Scripts/Map/TiltShift.cs
+++ b/unity/Assets/Scripts/Map/TiltShift.cs
@@ -13,6 +13,7 @@ namespace Statecraft.Game.Map
public static class TiltShift
{
public static readonly int ParamsId = Shader.PropertyToID("_ScTiltShift");
+ public static readonly int FarId = Shader.PropertyToID("_ScTiltShiftFar");
public const float HalfWidth = 0.13f, Feather = 0.17f;
/// <summary>The largest blur radius as a share of the picture's height: 14 px of a 1080-line picture (tap spacing
/// 1.75 texels of the half-resolution target, still adequately sampled by the 9 taps).</summary>
@@ -40,10 +41,27 @@ namespace Statecraft.Game.Map
public static float Strength(float distance) =>
Mathf.Lerp(1f, MinStrength, Mathf.InverseLerp(FullStrengthDistanceM, CameraController.MaxDistance, distance));
+ /// <summary>The far (top) band's strength, scaling its radius and its blend (issue #390, the owner's ruling of
+ /// 2026-10-13: a lighter tilt-shift at the gameplay zoom). FarGameplayStrength up to FarLightBelowM, the far edge only
+ /// gently soft as on promo 03, so the far towns and tokens stay readable; rising to 1 at the overview
+ /// (CameraController.MaxDistance, diorama02), which keeps both bands in full. The near (bottom) band is unchanged.</summary>
+ public const float FarGameplayStrength = 0.35f, FarLightBelowM = 150000f;
+
+ public static float FarStrength(float distance) =>
+ Mathf.Lerp(FarGameplayStrength, 1f, Mathf.InverseLerp(FarLightBelowM, CameraController.MaxDistance, distance));
+
+ /// <summary>A band's strength at viewport y: the far band's above the focus, 1 below (mirrors BandStrength in
+ /// TiltShift.shader).</summary>
+ public static float BandStrength(float y, Vector4 p, float far) => y > p.x ? far : 1f;
+
public static Vector4 Params(float topInset, float distance) =>
new Vector4(FocusCentre(topInset), HalfWidth, Feather, MaxRadiusUv * Strength(distance));
- public static void Apply(float topInset, float distance) => Shader.SetGlobalVector(ParamsId, Params(topInset, distance));
+ public static void Apply(float topInset, float distance)
+ {
+ Shader.SetGlobalVector(ParamsId, Params(topInset, distance));
+ Shader.SetGlobalFloat(FarId, FarStrength(distance));
+ }
/// <summary>No band set: TiltShiftFeature draws nothing until the next Apply (a camera no rig drives, or the map torn
/// down), and the toggle is back on. CameraRig.Init hands it to the map's teardown.</summary>
diff --git a/unity/Assets/Shaders/TiltShift.shader b/unity/Assets/Shaders/TiltShift.shader
index 868506e42..b1518d11a 100644
--- a/unity/Assets/Shaders/TiltShift.shader
+++ b/unity/Assets/Shaders/TiltShift.shader
@@ -2,7 +2,8 @@
// pass 1 blurs that vertically, pass 2 composites it over the camera colour with the band weight as alpha. The radius at a
// pixel is TiltWeight(y) * _ScTiltShift.w of the picture's height, so the focus band stays sharp and the blur grows
// smoothly towards the top and bottom. The radius is a share of the picture's height (UV units). No depth texture: it runs on
-// the web tier.
+// the web tier. The far (top) band is scaled by _ScTiltShiftFar in both its radius and its blend, so at the gameplay zoom
+// the far towns stay readable (issue #390, the owner's ruling) while the overview keeps both bands in full.
Shader "Statecraft/TiltShift"
{
SubShader
@@ -14,18 +15,23 @@ Shader "Statecraft/TiltShift"
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
float4 _ScTiltShift; // x focus centre (viewport y, 0 = bottom), y sharp half-width, z feather, w max radius (share of height)
+ float _ScTiltShiftFar; // the far (top) band's strength, 0..1: scales its radius and its blend (TiltShift.FarStrength)
float TiltWeight(float y)
{
return smoothstep(_ScTiltShift.y, _ScTiltShift.y + _ScTiltShift.z, abs(y - _ScTiltShift.x));
}
+ // The band's own strength: 1 below the focus (the near band), _ScTiltShiftFar above it. Continuous: TiltWeight is 0
+ // within the sharp half-width either side of the focus.
+ float BandStrength(float y) { return y > _ScTiltShift.x ? _ScTiltShiftFar : 1.0; }
+
half3 Sample(float2 uv) { return SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp, uv).rgb; }
// 9-tap Gaussian (sigma = 2 taps) whose tap spacing is a quarter of the local radius.
half3 Blur(float2 uv, float2 dir)
{
- float r = TiltWeight(uv.y) * _ScTiltShift.w;
+ float r = TiltWeight(uv.y) * BandStrength(uv.y) * _ScTiltShift.w;
// r is a share of the picture's height; the horizontal step converts it with the aspect ratio, which the render
// scale does not change (review I4).
float2 s = dir * (r * 0.25) * float2(_ScreenParams.y / _ScreenParams.x, 1.0);
@@ -63,7 +69,7 @@ Shader "Statecraft/TiltShift"
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
- half4 Frag(Varyings i) : SV_Target { return half4(Sample(i.texcoord), TiltWeight(i.texcoord.y)); }
+ half4 Frag(Varyings i) : SV_Target { return half4(Sample(i.texcoord), TiltWeight(i.texcoord.y) * BandStrength(i.texcoord.y)); }
ENDHLSL
}
}
diff --git a/unity/Assets/Tests/EditMode/TiltShiftTests.cs b/unity/Assets/Tests/EditMode/TiltShiftTests.cs
index 3039042c8..83f6ebda2 100644
--- a/unity/Assets/Tests/EditMode/TiltShiftTests.cs
+++ b/unity/Assets/Tests/EditMode/TiltShiftTests.cs
@@ -89,6 +89,19 @@ public class TiltShiftTests
Assert.AreEqual(TiltShift.MaxRadiusUv * TiltShift.MinStrength, TiltShift.Params(0f, CameraController.MaxDistance).w, 1e-7f, "weakest at the overview");
}
+ /// <summary>Issue #390: the far band's strength by zoom, and the near band never takes it.</summary>
+ [Test]
+ public void TheFarBandIsLighterAtTheGameplayZoom()
+ {
+ Assert.AreEqual(TiltShift.FarGameplayStrength, TiltShift.FarStrength(PromoPose.Gameplay03.Distance), 1e-6f);
+ Assert.AreEqual(TiltShift.FarGameplayStrength, TiltShift.FarStrength(120000f), 1e-6f, "CameraRig's starting zoom");
+ Assert.AreEqual(1f, TiltShift.FarStrength(CameraController.MaxDistance), 1e-6f, "the overview keeps it in full");
+ Assert.Less(TiltShift.FarStrength(200000f), 1f); Assert.Greater(TiltShift.FarStrength(200000f), TiltShift.FarGameplayStrength);
+ var p = TiltShift.Params(0.09f, 60000f);
+ Assert.AreEqual(1f, TiltShift.BandStrength(0.1f, p, 0.35f), "the near band is unchanged");
+ Assert.AreEqual(0.35f, TiltShift.BandStrength(0.9f, p, 0.35f));
+ }
+
[Test]
public void BothTiersRunTheTiltShiftAndTheFarBlurIsGone()
{
@@ -113,11 +126,12 @@ public class TiltShiftTests
public void TheTiltShiftShaderCompilesForWebGL2() =>
CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(Shader.Find("Statecraft/TiltShift")));
- /// <summary>Rendered on both tiers at the gameplay pose: local contrast in the top and bottom bands falls by at least
+ /// <summary>Rendered on both tiers at the gameplay pose: local contrast in the bottom (near) band falls by at least
/// 40%, the middle band keeps at least 95% of it. (Thresholds leave room for the terrain and grade tracks: a blur
- /// lowers gradient energy whatever the texture.)</summary>
+ /// lowers gradient energy whatever the texture.) The top (far) band is lighter at this zoom since issue #390:
+ /// TheFarBandStaysReadableAtTheGameplayZoom.</summary>
[UnityTest]
- public IEnumerator TheTopAndBottomBlurAndTheMiddleStaysSharpOnBothTiers()
+ public IEnumerator TheBottomBlursAndTheMiddleStaysSharpOnBothTiers()
{
int saved = QualitySettings.GetQualityLevel();
EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
@@ -134,27 +148,81 @@ public class TiltShiftTests
TiltShift.Enabled = false; var sharp = RenderSample.Render(cam, 960, 540);
TiltShift.Enabled = true; var shifted = RenderSample.Render(cam, 960, 540);
float Ratio(float y0, float y1) => shifted.GradientEnergy(y0, y1) / sharp.GradientEnergy(y0, y1);
- float top = Ratio(0.90f, 0.98f), bottom = Ratio(0.02f, 0.10f), middle = Ratio(0.46f, 0.54f);
- float topInner = Ratio(0.81f, 0.87f), bottomInner = Ratio(0.13f, 0.19f); // review I2: the bands are tall
- TestContext.WriteLine($"{QualitySettings.names[level]}: top {top:0.00}, bottom {bottom:0.00}, middle {middle:0.00}, " +
- $"top 0.81-0.87 {topInner:0.00}, bottom 0.13-0.19 {bottomInner:0.00}");
- Assert.Less(top, 0.6f, "top band blurred"); Assert.Less(bottom, 0.6f, "bottom band blurred");
- Assert.Less(topInner, 0.6f, "fully blurred 13-19% below the top"); Assert.Less(bottomInner, 0.6f, "and 13-19% above the bottom");
+ float bottom = Ratio(0.02f, 0.10f), middle = Ratio(0.46f, 0.54f);
+ float bottomInner = Ratio(0.13f, 0.19f); // review I2: the bands are tall
+ TestContext.WriteLine($"{QualitySettings.names[level]}: bottom {bottom:0.00}, middle {middle:0.00}, bottom 0.13-0.19 {bottomInner:0.00}");
+ Assert.Less(bottom, 0.6f, "bottom band blurred");
+ Assert.Less(bottomInner, 0.6f, "fully blurred 13-19% above the bottom");
Assert.Greater(middle, 0.95f, "middle band sharp");
// Review N6: the same blur at twice the resolution (the radius is a share of the picture's height).
TiltShift.Enabled = false; var sharpBig = RenderSample.Render(cam, 1920, 1080);
TiltShift.Enabled = true; var shiftedBig = RenderSample.Render(cam, 1920, 1080);
- float topBig = shiftedBig.GradientEnergy(0.90f, 0.98f) / sharpBig.GradientEnergy(0.90f, 0.98f);
- TestContext.WriteLine($"{QualitySettings.names[level]}: top at 1920x1080 {topBig:0.00}");
- Assert.AreEqual(top, topBig, 0.1f, "the top band loses the same share of its detail at 1080 lines as at 540");
+ float bottomBig = shiftedBig.GradientEnergy(0.02f, 0.10f) / sharpBig.GradientEnergy(0.02f, 0.10f);
+ TestContext.WriteLine($"{QualitySettings.names[level]}: bottom at 1920x1080 {bottomBig:0.00}");
+ Assert.AreEqual(bottom, bottomBig, 0.1f, "the bottom band loses the same share of its detail at 1080 lines as at 540");
}
}
finally { QualitySettings.SetQualityLevel(saved, true); }
}
+ /// <summary>Issue #390, the owner's ruling (2026-10-13): a lighter tilt-shift at the gameplay zoom, so the far towns and
+ /// tokens stay readable, as on promo 03, whose far edge is only gently soft. At gameplay03 (60 km) and at the
+ /// starting zoom (CameraRig's 120 km, the README map), under the web tier's top bar, the far band keeps at least 60% of
+ /// its local contrast (4abb64f kept 14-25%: a smear). Promo 03's far band, measured against its own focus band and
+ /// compared with the same ratio on a sharp frame of ours, keeps about 37%, so 60% is at least as readable.</summary>
+ [UnityTest]
+ public IEnumerator TheFarBandStaysReadableAtTheGameplayZoom()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
+ yield return null;
+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
+ try
+ {
+ foreach (var distance in new[] { PromoPose.Gameplay03.Distance, 120000f }) // 120 km: CameraRig's starting zoom
+ {
+ PromoPose.Gameplay03.Apply(rig, map.Frame); rig.Distance = distance; rig.TopInset = 0.09f; rig.Apply();
+ TiltShift.Enabled = false; var sharp = RenderSample.Render(cam, 960, 540);
+ TiltShift.Enabled = true; var shifted = RenderSample.Render(cam, 960, 540);
+ float Ratio(float y0, float y1) => shifted.GradientEnergy(y0, y1) / sharp.GradientEnergy(y0, y1);
+ float far = Ratio(0.78f, 0.90f), near = Ratio(0.02f, 0.10f);
+ TestContext.WriteLine($"{distance / 1000f:0} km: far band 0.78-0.90 {far:0.00}, near band {near:0.00}");
+ Assert.GreaterOrEqual(far, 0.6f, $"far band readable at {distance / 1000f:0} km");
+ Assert.Less(far, 0.95f, "but still gently soft (a tilt-shift, not none)");
+ Assert.Less(near, 0.6f, "the near band keeps its blur");
+ }
+ }
+ finally { rig.TopInset = 0f; }
+ }
+
+ /// <summary>Issue #390: the overview (diorama02, CameraController.MaxDistance) keeps both bands in full, as before the
+ /// ruling: the far band keeps at most 30% of its local contrast (21% measured) and the near band at most 45% (33%).</summary>
+ [UnityTest]
+ public IEnumerator TheDioramaKeepsBothBands()
+ {
+ Assert.AreEqual(1f, TiltShift.FarStrength(CameraController.MaxDistance), "full far band at the overview");
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
+ yield return null;
+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
+ try
+ {
+ PromoPose.Diorama02.Apply(rig, map.Frame); rig.TopInset = 0.09f; rig.Apply();
+ TiltShift.Enabled = false; var sharp = RenderSample.Render(cam, 960, 540);
+ TiltShift.Enabled = true; var shifted = RenderSample.Render(cam, 960, 540);
+ float Ratio(float y0, float y1) => shifted.GradientEnergy(y0, y1) / sharp.GradientEnergy(y0, y1);
+ float far = Ratio(0.78f, 0.90f), near = Ratio(0.02f, 0.10f), middle = Ratio(0.43f, 0.48f);
+ TestContext.WriteLine($"diorama02: far {far:0.00}, near {near:0.00}, middle {middle:0.00}");
+ Assert.Less(far, 0.3f, "far band blurred in full");
+ Assert.Less(near, 0.45f, "near band blurred in full");
+ Assert.Greater(middle, 0.95f, "middle band sharp");
+ }
+ finally { rig.TopInset = 0f; }
+ }
+
/// <summary>Review I4: an asymmetric case, so a vertically flipped composite or a focus that ignores the top bar fails.
/// With TopInset 0.3 the focus is at 0.35: the band around 0.35 stays sharp, and 0.70-0.78 (sharp when the focus is at
- /// 0.5) is blurred.</summary>
+ /// 0.5) is blurred. At the overview, where the far band is in full (issue #390).</summary>
[UnityTest]
public IEnumerator AnOffCentreFocusFollowsTheTopBar()
{
@@ -162,7 +230,7 @@ public class TiltShiftTests
var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
yield return null;
var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
- PromoPose.Gameplay03.Apply(rig, map.Frame); rig.TopInset = 0.3f; rig.Apply();
+ PromoPose.Diorama02.Apply(rig, map.Frame); rig.TopInset = 0.3f; rig.Apply(); // the far band in full (issue #390)
Assert.AreEqual(0.35f, Shader.GetGlobalVector(TiltShift.ParamsId).x, 1e-5f, "CameraRig.Apply passes the inset");
TiltShift.Enabled = false; var sharp = RenderSample.Render(cam, 960, 540);
TiltShift.Enabled = true; var shifted = RenderSample.Render(cam, 960, 540);