summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop/M6Presentation.fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop/M6Presentation.fs')
-rw-r--r--src/LivingVillage.Desktop/M6Presentation.fs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/M6Presentation.fs b/src/LivingVillage.Desktop/M6Presentation.fs
index 825847a..4e88bd9 100644
--- a/src/LivingVillage.Desktop/M6Presentation.fs
+++ b/src/LivingVillage.Desktop/M6Presentation.fs
@@ -159,3 +159,73 @@ module M6Presentation =
elif hour < 17 then "白天"
elif hour < 21 then "黄昏"
else "夜晚"
+
+ // ------------------------------------------------------------------
+ // P73:四时段光照档(清晨/正午/黄昏/夜晚)。
+ // 既有的 blend/warmth 是连续曲线;这里在其上叠加一层「时段档」——
+ // 每个时段一份乘性环境色调 + 加性覆盖色 + 灯光强度,保证 6/12/18/22 时
+ // 四张真实帧肉眼可辨,尤其填补 17:00–19:15 原本与正午无差的黄昏空档。
+ // 正午档为恒等(白 tint / alpha 0 / 灯光 0),因此不改变既有正午观感。
+ // ------------------------------------------------------------------
+
+ type M6Period =
+ | Morning
+ | Noon
+ | Dusk
+ | Night
+
+ type M6PeriodLighting =
+ { AmbientTint: Color
+ Veil: Color
+ VeilAlpha: int
+ LanternGlow: float32 }
+
+ /// 时段档参数表(纯数据)。调用方按 periodAtTick 取值。
+ let periodLighting (period: M6Period) : M6PeriodLighting =
+ match period with
+ | Morning ->
+ { AmbientTint = Color(238, 246, 255)
+ Veil = Color(255, 222, 160)
+ VeilAlpha = 20
+ LanternGlow = 0.0f }
+ | Noon ->
+ { AmbientTint = Color(255, 255, 255)
+ Veil = Color(255, 255, 255)
+ VeilAlpha = 0
+ LanternGlow = 0.0f }
+ | Dusk ->
+ { AmbientTint = Color(255, 231, 200)
+ Veil = Color(255, 140, 58)
+ VeilAlpha = 52
+ LanternGlow = 0.6f }
+ | Night ->
+ { AmbientTint = Color(150, 176, 216)
+ Veil = Color(70, 110, 190)
+ VeilAlpha = 26
+ LanternGlow = 1.0f }
+
+ /// 时段枚举名(证据日志用,纯函数;与 timePeriodLabel 边界一致)。
+ let lightingPeriodName = function
+ | Morning -> "清晨"
+ | Noon -> "正午"
+ | Dusk -> "黄昏"
+ | Night -> "夜晚"
+
+ /// tick → 四时段档。边界与 timePeriodLabel 完全一致:<5 夜晚、<8 清晨、<17 正午、<21 黄昏、否则夜晚。
+ let periodAtTick (tick: int64) : M6Period =
+ let hour = hourOf tick
+ if hour < 5 then Night
+ elif hour < 8 then Morning
+ elif hour < 17 then Noon
+ elif hour < 21 then Dusk
+ else Night
+
+ let periodLightingAtTick (tick: int64) : M6PeriodLighting = periodAtTick tick |> periodLighting
+
+ /// 两乘性色调逐通道相乘(255 为恒等)。用于把时段环境色调并入世界 tint。
+ let multiplyTint (a: Color) (b: Color) : Color =
+ Color(int a.R * int b.R / 255, int a.G * int b.G / 255, int a.B * int b.B / 255, 255)
+
+ /// 实际灯光强度:连续曲线与时段档取较大者(黄昏档让灯笼从 18:00 起点亮)。
+ let effectiveLanternGlow (tick: int64) : float32 =
+ max (lightingAtTick tick).LanternGlow (periodLightingAtTick tick).LanternGlow