fix(sky): scale keyframe Luminosity/Transparent/MaxBright from percent → fraction
Retail's Region dat stores SkyObjectReplace.Luminosity / Transparent /
MaxBright as percentages in the 0..100 range. Our shader expects
fractions in 0..1. We were passing raw values (luminosity up to 100)
straight into the sky fragment shader's rgb-multiplier:
rgb = sampled.rgb * uTint.rgb * uLuminosity;
At the "Sunny" DayGroup's noon keyframes (verified via live diag),
Luminosity = 100 → shader multiplied the cloud texture RGB by 100 →
min(rgb, vec3(1.2)) clamped all channels to 1.2 → pure white sky.
Also gave the dawn/dusk purple sky effect on top of the pale texture.
Fix: SkyDescLoader.ConvertTimeOfDay divides Luminosity, Transparent
and MaxBright by 100 when loading each SkyObjectReplace. The Rotate
field stays as degrees (values like 270° are genuine headings, not
percentages).
Transparent was accidentally surviving via a 0..1 clamp downstream,
but we fix it for consistency and so brightness-attenuating values
in the 0..99 range (partial fade during dawn/dusk) work correctly
instead of rounding to full-transparent.
WorldBuilder's SkyboxRenderManager does NOT apply these fields at
all — that's why they never hit this bug. Our port applies them for
per-keyframe day-night fades, so we needed the unit conversion.
Also picked up in this commit (incidental, already running):
- Sky render: per-submesh blend mode from TranslucencyKind.Additive
for sun/moon-style self-bright objects (Additive bit 0x10000).
Luminous flag 0x40 intentionally NOT mapped to additive — that
flag is on the sky dome + cloud sheets and making them additive
produced the previous "fully white" iteration of this bug.
- ToD default seed: DayTicks/16 (Midsong = hour 9 = true noon)
instead of DayTicks*0.5 which landed on Gloaming-and-Half (sunset)
due to DerethDateTime's +7/16 day-fraction offset. Pre-TimeSync
view now correctly starts at noon.
- Lightning flash: brighter white-blue (vec3(1.5,1.5,1.8)) instead
of dim grey; ceiling relaxed during flash so the strobe actually
blows out. Cadence (strike intervals, decay) unchanged.
- Saved docs/research/2026-04-21-sky-deep-audit.md with the
decompile+ACE+ACME+WorldBuilder research done to corner this bug.
Open follow-up (not fixed here): sky clouds are white at noon /
don't get the dusk/night purple tint. Our sky shader is fully unlit
— doesn't apply sun/ambient directional light like the terrain
shader does. AmbientColor in the keyframe data carries the right
tint (purple at midnight, magenta at dusk) but we pass
uTint = Vector4.One instead of the keyframe value. Next commit will
wire directional-sun + ambient into sky.frag so cloud meshes pick
up the time-of-day color.
All 717 tests green. User-confirmed: sky colors are now "much
better" after this change (previously fully white).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7007758293
commit
eeae83a14e
5 changed files with 277 additions and 10 deletions
|
|
@ -886,7 +886,18 @@ public sealed class GameWindow : IDisposable
|
|||
// Seed WorldTime to noon so outdoor scenes aren't pitch-black before
|
||||
// the server sends its first TimeSync packet (offline rendering in
|
||||
// particular never receives one).
|
||||
WorldTime.SyncFromServer(AcDream.Core.World.DerethDateTime.DayTicks * 0.5);
|
||||
//
|
||||
// "Noon" here means sun at zenith — dayFraction = 0.5. Because
|
||||
// DerethDateTime applies a +7/16 offset (tick 0 = Morntide-and-Half,
|
||||
// hour 8 of 16), we need raw ticks = 476.25 (one hour past tick 0 =
|
||||
// Midsong / Hour 9, which is what retail considers noon).
|
||||
//
|
||||
// Using `DayTicks * 0.5 = 3810` WOULD be correct if the offset were
|
||||
// zero, but with our 3333.75-tick shift it lands on dayFraction
|
||||
// 0.9375 — that's Gloaming-and-Half (sunset, nearly midnight),
|
||||
// producing a dim orange sky with the sun below the horizon until
|
||||
// TimeSync arrives.
|
||||
WorldTime.SyncFromServer(AcDream.Core.World.DerethDateTime.DayTicks / 16.0); // = 476.25 = Midsong (noon)
|
||||
|
||||
// Build the terrain atlas once from the Region dat.
|
||||
var terrainAtlas = AcDream.App.Rendering.TerrainAtlas.Build(_gl, _dats);
|
||||
|
|
@ -3504,10 +3515,12 @@ public sealed class GameWindow : IDisposable
|
|||
var kf = WorldTime.CurrentSky;
|
||||
var atmo = Weather.Snapshot(in kf);
|
||||
var fogColor = atmo.FogColor;
|
||||
// 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.
|
||||
// Clear to fog color (horizon haze) so if sky meshes have alpha
|
||||
// gaps or don't cover the full view, the "missing" area reads as
|
||||
// distant haze, not as pitch-black. Fog color is clamped to 0..1
|
||||
// since keyframes may pre-multiply DirBright and produce over-1
|
||||
// values that some drivers interpret as "bright clamp" (pink/green
|
||||
// frames).
|
||||
_gl!.ClearColor(
|
||||
System.Math.Clamp(fogColor.X, 0f, 1f),
|
||||
System.Math.Clamp(fogColor.Y, 0f, 1f),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue