sky(phase-3b): revert Phase 2 per-vertex lighting — sky meshes are UNLIT
Phase 2 added a per-vertex lighting path to the sky shader based on the Phase 1 dump showing dome surfaces with Luminosity=1.0 and cloud surfaces with Luminosity=0.0. Live visual verification vs retail at MorntideAndHalf (dayFraction=0.48, user-observed 2026-04-23) disproved the hypothesis: retail: clean blue sky + white clouds acdream: blue-green-yellow sky sweep + greyish clouds The "sweep" is exactly the signature of per-vertex `diffuse × sunColor` where sunColor=(250,215,151) warm gold at ~63° east: the west-facing cloud faces get the gold tint, east-facing stay cool, and interpolation across the mesh produces the color sweep. Retail's clean white clouds at the same time of day means retail is NOT applying per-vertex lighting to sky meshes. Revised model (unlit + SkyObjectReplace modulation): fragment.rgb = texture.rgb * uLuminosity fragment.a = texture.a * (1 - uTransparency) The "purple haze night / warm dusk" effect users describe from retail comes from SkyObjectReplace per-keyframe Luminosity dimming + Transparent fading, NOT from a shader ambient multiply. At midnight, for example, Replace[0] dims the dome to 11% (Luminosity_raw=11) and Replace[2] fully hides the drifting cloud (Transparent_raw=100) — so the camera sees the dome texture at 11% × baked gradient colors, and any purple the user perceives is baked into the dome texture's night gradient. The retail-authoritative Surface.Luminosity flag probably feeds a separate render path (material system? D3D emissive vs diffuse coefficients?) that is NOT per-vertex GL lighting. A future phase can revive it if the decompile hunt for the DayGroup selection algorithm surfaces it. Code change: sky.vert + sky.frag only. The C# renderer still pushes uAmbientColor/uSunColor/uSunDir/uEmissive uniforms — they are declared in the shaders but unused in Phase 3b. No renderer change needed; these uniforms cost nothing and keep the port-forward path open. Build + 717 tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
62e9c6b9ac
commit
027ccb46b9
2 changed files with 46 additions and 59 deletions
|
|
@ -1,28 +1,29 @@
|
|||
#version 430 core
|
||||
// Sky mesh fragment shader — retail-verbatim composite:
|
||||
// Sky mesh fragment shader — UNLIT texture passthrough modulated by the
|
||||
// per-keyframe SkyObjectReplace.Luminosity and .Transparent overrides.
|
||||
//
|
||||
// fragment.rgb = texture.rgb * vTint * uLuminosity + lightning_flash
|
||||
// fragment.rgb = texture.rgb * uLuminosity + lightning_flash
|
||||
// fragment.a = texture.a * (1 - uTransparency)
|
||||
//
|
||||
// vTint arrives from the vertex shader with retail's per-vertex lighting
|
||||
// baked in (emissive + ambient + diffuse × sun, clamped to [0,1]).
|
||||
// uLuminosity is the per-keyframe SkyObjectReplace override (0..1
|
||||
// fraction after the /100 scale in SkyDescLoader) — NOT to be confused
|
||||
// with the Surface.Luminosity that feeds uEmissive in the vertex shader.
|
||||
// uTransparency is the per-keyframe SkyObjectReplace alpha-fade.
|
||||
// uLuminosity defaults to 1.0 (no dim). A SkyObjectReplace entry with
|
||||
// Luminosity_raw=11 (11%) sets uLuminosity to 0.11 — mesh renders at
|
||||
// 11% brightness. MaxBright is min-clamped into uLuminosity by the C#
|
||||
// renderer before it reaches the shader.
|
||||
// uTransparency defaults to 0.0. Replace.Transparent_raw=100 (100%) sets
|
||||
// uTransparency to 1.0 — alpha is zeroed and the pixel discarded
|
||||
// (cloud hidden so the dome behind shows through).
|
||||
//
|
||||
// See docs/research/2026-04-23-sky-retail-verbatim.md §6 + §7.
|
||||
// See `docs/research/2026-04-23-sky-retail-verbatim.md` §6 + Phase 3b
|
||||
// rationale in sky.vert.
|
||||
|
||||
in vec2 vTex;
|
||||
in vec3 vTint;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D uDiffuse;
|
||||
uniform float uTransparency; // 0 = fully visible, 1 = fully transparent
|
||||
uniform float uLuminosity; // 1.0 = normal; <1 dims per SkyObjectReplace
|
||||
uniform float uTransparency;
|
||||
uniform float uLuminosity;
|
||||
|
||||
// Shared SceneLighting UBO — only need fog/flash channel for the
|
||||
// client-driven lightning strobe. Sun/ambient already baked into vTint.
|
||||
// Shared SceneLighting UBO — only fog-flash channel used (lightning).
|
||||
struct Light {
|
||||
vec4 posAndKind;
|
||||
vec4 dirAndRange;
|
||||
|
|
@ -40,16 +41,13 @@ layout(std140, binding = 1) uniform SceneLighting {
|
|||
void main() {
|
||||
vec4 sampled = texture(uDiffuse, vTex);
|
||||
|
||||
// Composite: texture × per-vertex lighting × per-keyframe dim.
|
||||
vec3 rgb = sampled.rgb * vTint * uLuminosity;
|
||||
// Unlit passthrough with per-keyframe dim.
|
||||
vec3 rgb = sampled.rgb * uLuminosity;
|
||||
|
||||
// Lightning additive bump (client-side during storm keyframes).
|
||||
// Lightning additive bump (client-driven during storm keyframes).
|
||||
float flash = uFogParams.z;
|
||||
rgb += flash * vec3(1.5, 1.5, 1.8);
|
||||
|
||||
// Soft clamp. Normal frame: cap at 1.2 so emissive meshes have a
|
||||
// small highlight margin. During a flash the ceiling relaxes so the
|
||||
// strobe actually blows out instead of getting pinned mid-rise.
|
||||
float cap = mix(1.2, 3.0, clamp(flash, 0.0, 1.0));
|
||||
rgb = min(rgb, vec3(cap));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,57 +1,46 @@
|
|||
#version 430 core
|
||||
// Sky mesh vertex shader — computes the per-vertex lighting tint that
|
||||
// gives retail its time-of-day variation:
|
||||
// Sky mesh vertex shader — UNLIT texture passthrough.
|
||||
//
|
||||
// tint = clamp(emissive + ambient + max(dot(N, -sunDir), 0) * sunColor,
|
||||
// 0.0, 1.0)
|
||||
// Phase 2 experimented with per-vertex `emissive + ambient + diffuse×sun`
|
||||
// lighting driven from the Surface.Luminosity field. The Phase 3a live
|
||||
// verification (2026-04-23, user-observed against retail side-by-side
|
||||
// at MorntideAndHalf) produced a "blue-green-yellow sweep" across the
|
||||
// sky in acdream while retail showed a clean blue sky with white clouds.
|
||||
// That's the signature of `diffuse × (250,215,151) warm-gold sunColor`
|
||||
// tinting the cloud mesh's west-facing faces — retail does NOT do this.
|
||||
//
|
||||
// This is the retail-verbatim AdjustPlanes formula ported from the
|
||||
// decompiled D3D fixed-function lighting. The `emissive` scalar is the
|
||||
// Surface.Luminosity FLOAT field (NOT the SurfaceType.Luminous flag bit) —
|
||||
// for Dereth's sky meshes, the DOME + SUN/MOON have emissive=1.0
|
||||
// (texture-passthrough regardless of lighting), while CLOUDS have
|
||||
// emissive=0.0 (lit normally, so they pick up the ambient tint that
|
||||
// produces retail's purple-haze night / warm-tan dusk / pale-cool noon).
|
||||
// Retail sky meshes render UNLIT. The time-of-day color variation users
|
||||
// observe (purple haze at night, warm dusk) comes from SkyObjectReplace
|
||||
// per-keyframe Luminosity + Transparent modulation, revealing/dimming
|
||||
// different mesh layers — NOT from per-vertex ambient multiply.
|
||||
//
|
||||
// See docs/research/2026-04-23-sky-retail-verbatim.md §6 for the full
|
||||
// decompile trail and field citations.
|
||||
// See `docs/research/2026-04-23-sky-retail-verbatim.md` §6 for the
|
||||
// surviving hypotheses and the Phase 3b decision rationale.
|
||||
//
|
||||
// Uniforms for Ambient/Sun/Emissive stay declared below so the C#-side
|
||||
// plumbing doesn't need to change — they are simply UNUSED. A future
|
||||
// phase can revive them if the decompile hunt proves retail applies
|
||||
// lighting to sky through a different channel.
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
layout(location = 2) in vec2 aTex;
|
||||
|
||||
uniform mat4 uModel; // per-object arc transform
|
||||
uniform mat4 uSkyView; // camera view with M41..M43 = 0
|
||||
uniform mat4 uSkyProjection; // near=0.1, far=1e6
|
||||
uniform vec2 uUvScroll; // cumulative TexVelocityX/Y * time
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uSkyView;
|
||||
uniform mat4 uSkyProjection;
|
||||
uniform vec2 uUvScroll;
|
||||
|
||||
// Per-frame lighting — keyframe-interpolated values pushed before each
|
||||
// Render() call. AmbColor × AmbBright and DirColor × DirBright are
|
||||
// pre-multiplied by SkyDescLoader so the shader feeds them straight in.
|
||||
uniform vec3 uAmbientColor; // AmbColor × AmbBright
|
||||
uniform vec3 uSunColor; // DirColor × DirBright
|
||||
uniform vec3 uSunDir; // unit vector FROM surface TO sun
|
||||
|
||||
// Per-submesh: Surface.Luminosity (0..1 self-illumination scalar).
|
||||
// Unused in Phase 3b — see header. Kept for forward-compat with the
|
||||
// C# renderer's push calls.
|
||||
uniform vec3 uAmbientColor;
|
||||
uniform vec3 uSunColor;
|
||||
uniform vec3 uSunDir;
|
||||
uniform float uEmissive;
|
||||
|
||||
out vec2 vTex;
|
||||
out vec3 vTint;
|
||||
|
||||
void main() {
|
||||
vTex = aTex + uUvScroll;
|
||||
gl_Position = uSkyProjection * uSkyView * uModel * vec4(aPos, 1.0);
|
||||
|
||||
// uModel for sky is scale * RotZ(-heading) * RotY(-rotation) — pure
|
||||
// orthonormal rotation, so mat3(uModel) correctly transforms normals
|
||||
// without needing transpose(inverse(...)).
|
||||
vec3 worldNormal = normalize(mat3(uModel) * aNormal);
|
||||
|
||||
// Per-vertex lighting. `emissive` is broadcast scalar → vec3. For
|
||||
// emissive=1.0 the clamp saturates to white regardless of ambient/sun
|
||||
// (the retail "unlit" mesh). For emissive=0.0 only the ambient + sun
|
||||
// term drives `tint` (the retail "lit" mesh, e.g. clouds).
|
||||
float diff = max(dot(worldNormal, uSunDir), 0.0);
|
||||
vec3 lit = vec3(uEmissive) + uAmbientColor + diff * uSunColor;
|
||||
vTint = clamp(lit, 0.0, 1.0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue