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
|
|
@ -246,14 +246,33 @@ public static class SkyDescLoader
|
|||
|
||||
private static DatSkyKeyframeData ConvertTimeOfDay(SkyTimeOfDay s)
|
||||
{
|
||||
// Transparent / Luminosity / MaxBright are stored in the retail
|
||||
// Region dat as PERCENTAGES (0..100), not fractions (0..1). Our
|
||||
// shader expects fractions — divide here. Confirmed from live
|
||||
// diag dump of Region 0x13000000 / DayGroup "Sunny": noon keyframes
|
||||
// have Luminosity=100 and Transparent=100 across multiple
|
||||
// SkyObjectReplace entries, corresponding to 1.0 in shader units.
|
||||
// Previously passing the raw 100 through resulted in
|
||||
// `rgb = texture * 100` which blew out to pure white everywhere
|
||||
// (clamped to vec3(1.2) in the sky fragment shader) — this was the
|
||||
// "white sky at noon" bug observed by the user.
|
||||
//
|
||||
// Rotate stays as degrees (270° values in the data are genuinely
|
||||
// heading-degrees, not percentages). ObjectIndex / GfxObjId are
|
||||
// IDs with no unit transform.
|
||||
//
|
||||
// WorldBuilder's SkyboxRenderManager does NOT apply Luminosity /
|
||||
// Transparent / MaxBright at all (ignores the fields entirely),
|
||||
// which is why they never ran into this bug. We apply them for
|
||||
// per-keyframe day-night fade which retail does.
|
||||
var replaces = s.SkyObjReplace.Select(r => new SkyObjectReplaceData
|
||||
{
|
||||
ObjectIndex = r.ObjectIndex,
|
||||
GfxObjId = r.GfxObjId?.DataId ?? 0u,
|
||||
Rotate = r.Rotate,
|
||||
Transparent = r.Transparent,
|
||||
Luminosity = r.Luminosity,
|
||||
MaxBright = r.MaxBright,
|
||||
Transparent = r.Transparent / 100f,
|
||||
Luminosity = r.Luminosity / 100f,
|
||||
MaxBright = r.MaxBright / 100f,
|
||||
}).ToList();
|
||||
|
||||
var fogMode = s.WorldFog switch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue