feat(world): Phase G.1 — debug-time override tests + clear-color clamp

Small polish commit:
- Clamp ClearColor inputs to [0, 1] because retail keyframes store
  sun/fog colors pre-multiplied by their brightness scalars, which can
  exceed 1.0; some drivers treat ClearColor > 1 as a saturate-bright
  hint and produce visible color shifts at the edges.
- 4 new tests cover WorldTimeService.SetDebugTime / ClearDebugTime /
  SyncFromServer-clears-override / SetProvider hot-swap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-19 10:52:54 +02:00
parent cd89e9a498
commit 756def5ceb
2 changed files with 67 additions and 1 deletions

View file

@ -3040,7 +3040,15 @@ public sealed class GameWindow : IDisposable
var kf = WorldTime.CurrentSky;
var atmo = Weather.Snapshot(in kf);
var fogColor = atmo.FogColor;
_gl!.ClearColor(fogColor.X, fogColor.Y, fogColor.Z, 1f);
// Clamp to 0..1 — keyframes may store over-1 values (retail uses the
// dir-bright scalar pre-multiplied into color) and GL's ClearColor
// will silently accept them, but some drivers interpret > 1 as
// "bright clamp", producing ugly pink/green frames.
_gl!.ClearColor(
System.Math.Clamp(fogColor.X, 0f, 1f),
System.Math.Clamp(fogColor.Y, 0f, 1f),
System.Math.Clamp(fogColor.Z, 0f, 1f),
1f);
_gl!.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);