summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-22 02:13:00 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-22 02:13:00 +0800
commit5a908a17335ff291e2d8f2fb3a1ff0ab57770c80 (patch)
treea01b4131d6470d99a03ebfa45e5a6d6456cb20af /src
parent37953a4b58dfc5f3b8aedf10ad6f1474c2960767 (diff)
downloadliving-village-5a908a17335ff291e2d8f2fb3a1ff0ab57770c80.tar.gz
fix(desktop): P19 白天色调去偏黄(day tint 中性白平衡,黄昏暖橙保留)p19-daylight-taming
Diffstat (limited to 'src')
-rw-r--r--src/LivingVillage.Desktop.Tests/DesktopTests.fs17
-rw-r--r--src/LivingVillage.Desktop.Tests/PrototypeTests.fs12
-rw-r--r--src/LivingVillage.Desktop/M6Presentation.fs10
3 files changed, 35 insertions, 4 deletions
diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
index 00e445b..b78f4e0 100644
--- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs
+++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
@@ -143,6 +143,23 @@ type DesktopTests () =
Assert.IsTrue(day.WorldTint.G > day.WorldTint.B)
[<TestMethod>]
+ member _.NoonLightingIsWarmthFreeWithNeutralWhiteBalance () =
+ let noonTick = 12L * Sim.ticksPerDay / 24L
+ let noon = M6Presentation.profileAtTick noonTick
+
+ Assert.AreEqual<M6DayNight>(Day, noon.Mode)
+ Assert.AreEqual<float32>(0.0f, noon.SkyWarmth)
+ Assert.AreEqual<float32>(0.0f, noon.LanternGlow)
+ Assert.AreEqual<int>(0, M6Presentation.goldenVeilAlpha noonTick)
+ // P19 offender was the day world tint attenuating blue (255/248/224); it is neutral now.
+ Assert.AreEqual<int>(255, int noon.WorldTint.R)
+ Assert.AreEqual<int>(int noon.WorldTint.R, int noon.WorldTint.G)
+ Assert.AreEqual<int>(int noon.WorldTint.G, int noon.WorldTint.B)
+ // The sky stays a plain blue, never warm.
+ Assert.IsTrue(noon.Background.B > noon.Background.G)
+ Assert.IsTrue(noon.Background.B > noon.Background.R)
+
+ [<TestMethod>]
member _.DaylightAutoplayBootstrapStartsAtDawnAndPreservesDefaultStart () =
let dawnTick = 6L * Sim.ticksPerDay / 24L
let daylightWorld = WorldBootstrap.initialWorldForDaylight true 42UL Sim.npcCount
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
index 895dff8..e58139c 100644
--- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
+++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
@@ -897,6 +897,18 @@ type PrototypeTests () =
Assert.IsTrue(warmDusk.Background.B < (M6Presentation.backgroundAtBlend warmDusk.Blend).B)
Assert.IsTrue(warmDusk.WorldTint.R > (M6Presentation.worldTintAtBlend warmDusk.Blend).R)
Assert.IsTrue(warmDusk.WorldTint.B < (M6Presentation.worldTintAtBlend warmDusk.Blend).B)
+
+ // P19: no daylight warm cast. Noon (and the whole 10:00-15:00 plateau) must be warmth-free
+ // and channel-neutral, so the world renders at a true white balance instead of yellow.
+ for hour in 10 .. 15 do
+ let daylight = atHour hour
+ Assert.IsTrue(abs (daylight.SkyWarmth) < 1e-6f, sprintf "hour %d must carry no warmth" hour)
+ Assert.IsTrue((int daylight.WorldTint.R) = (int daylight.WorldTint.G), sprintf "hour %d world tint must be neutral" hour)
+ Assert.IsTrue((int daylight.WorldTint.G) = (int daylight.WorldTint.B), sprintf "hour %d world tint must be neutral" hour)
+ Assert.IsTrue((M6Presentation.goldenVeilAlpha (int64 hour * ticksPerHour)) = 0, sprintf "hour %d must have no golden veil" hour)
+ Assert.IsTrue(abs (daylight.LanternGlow) < 1e-6f, sprintf "hour %d must have no lantern glow" hour)
+ let noon = atHour 12
+ Assert.IsTrue((int noon.WorldTint.R) = 255, "neutral day tint should be full white (no attenuation)")
// Additive veil: positive and strongest at the golden peaks, zero at noon/midnight.
Assert.AreEqual<int>(0, M6Presentation.goldenVeilAlpha (int64 12 * ticksPerHour))
Assert.AreEqual<int>(0, M6Presentation.goldenVeilAlpha 0L)
diff --git a/src/LivingVillage.Desktop/M6Presentation.fs b/src/LivingVillage.Desktop/M6Presentation.fs
index 25737d7..90d2e65 100644
--- a/src/LivingVillage.Desktop/M6Presentation.fs
+++ b/src/LivingVillage.Desktop/M6Presentation.fs
@@ -76,13 +76,15 @@ module M6Presentation =
lerp 160 25 blend + int (20.0f * warmth),
lerp 210 55 blend - int (90.0f * warmth))
- /// World tint also warms (red up, green slightly down, blue down) so tiles, props and
- /// characters all lean golden before the additive veil is layered on top.
+ /// World tint multiplies the whole scene. The day baseline is neutral white so noon keeps
+ /// a true white balance (the old day base 255/248/224 clipped blue by ~12% and made daylight
+ /// look yellow); night stays cool, and the golden shade only appears through `warmth`, which
+ /// is a pure function that is zero at noon and outside the dawn/dusk windows.
let worldTintAtWarmth (blend: float32) (warmth: float32) : Color =
Color(
lerp 255 118 blend + int (70.0f * warmth),
- lerp 248 136 blend - int (10.0f * warmth),
- lerp 224 184 blend - int (75.0f * warmth))
+ lerp 255 136 blend - int (10.0f * warmth),
+ lerp 255 184 blend - int (75.0f * warmth))
/// Warmth-free base colours (kept for callers that only have a blend value).
let backgroundAtBlend (blend: float32) : Color = backgroundAtWarmth blend 0.0f