feat(render): Phase W Stage 4 — sky/weather portal-clip seal (LScape through the doorway)
The sky + weather (rain cylinder) are retail's LScape — 'the outside seen through the exit portal.' Retail PView::DrawCells (pseudo_c:432709) draws LScape clipped to the OutsideView when outside_view.view_count>0, then does a conditional Z-buffer-ONLY clear (432731) before the indoor cells. acdream now does the same: - sky.vert writes gl_ClipDistance against the SAME binding=2 TerrainClip UBO the terrain reads. The OutsideView planes are screen-space (NDC) half-spaces encoded as clip-space planes (nx,ny,0,dw); the test dot(plane,gl_Position)>=0 reduces after perspective divide to nx*ndcX+ny*ndcY+dw>=0 — projection-INDEPENDENT — so the same plane set clips the sky EXACTLY despite its separate dome projection. count==0 (outdoor) → all distances +1 → full-screen, bit-identical. Lighting/fog math untouched. - GameWindow: relocated the sky pre-scene + weather post-scene draws to their retail LScape positions, each in a local 8-plane clip bracket so sky.vert confines them to the doorway indoors / full-screen outdoors. Added the conditional doorway depth-ONLY Z-clear (no color → no blue hole), scissored to the OutsideView AABB. drawSkyThisFrame = seen_outside policy AND (outdoor OR exit-portal-in-view) — a sealed interior with no exit portal in view draws no sky (kills the full-screen-sky interim regression). Sky pre/post particle passes (particle.vert has no gl_ClipDistance) scissored to the doorway bbox. - ClipFrameAssembly gains HasOutsideView + OutsideViewNdcAabb (the doorway NDC AABB, computed for BOTH Planes and Scissor terrain modes — unlike TerrainScissorNdcAabb which is Scissor-only). - The pre-login goto SkipWorldGeometry moved BELOW the sky draw so the live sky still renders during the EnterWorld handshake (clipAssembly is null/no-clip pre-login → full-screen). Build green; App tests 160/160. Stage 4 tests + verify-annotations follow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
55e1b30553
commit
ce2edad66a
3 changed files with 194 additions and 30 deletions
|
|
@ -65,6 +65,33 @@ layout(std140, binding = 1) uniform SceneLighting {
|
|||
vec4 uCameraAndTime;
|
||||
};
|
||||
|
||||
// === Phase W Stage 4: sky/weather portal clip (the OutsideView region) ========
|
||||
// The sky + weather (rain cylinder) meshes are "the outside seen through a
|
||||
// doorway" — retail draws them as part of LScape, clipped to the exit-portal
|
||||
// region (PView::DrawCells @ 0x005a4840). acdream gates them with the SAME
|
||||
// binding=2 TerrainClip UBO the terrain shader reads (ClipFrame.SetTerrainClip →
|
||||
// the OutsideView convex planes). The planes are SCREEN-SPACE (NDC) half-spaces
|
||||
// encoded as clip-space planes (nx, ny, 0, dw) with the test
|
||||
// dot(plane, gl_Position) >= 0. After the perspective divide that reduces to
|
||||
// nx*ndcX + ny*ndcY + dw >= 0 — INDEPENDENT of the projection matrix. So the same
|
||||
// plane set clips the sky correctly even though the sky uses its OWN dome
|
||||
// projection (uSkyProjection / uSkyView, translation-zeroed) rather than the
|
||||
// camera view-proj. uTerrainClipCount == 0 (outdoor / no exit portal visible)
|
||||
// ungates the sky entirely (the second loop sets all 8 distances to +1.0 ⇒
|
||||
// full-screen sky, bit-identical to pre-Stage-4). Host enables GL_CLIP_DISTANCE0..7
|
||||
// only around the sky/weather draws.
|
||||
layout(std140, binding = 2) uniform TerrainClip {
|
||||
int uTerrainClipCount;
|
||||
vec4 uTerrainClipPlanes[8];
|
||||
};
|
||||
|
||||
// Core profile: redeclare gl_PerVertex so writing gl_ClipDistance[] is legal
|
||||
// (mirrors terrain_modern.vert). Sized 8 to match GL_MAX_CLIP_DISTANCES >= 8.
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
float gl_ClipDistance[8];
|
||||
};
|
||||
|
||||
out vec2 vTex;
|
||||
out vec3 vTint;
|
||||
out float vFogFactor; // 1 = no fog (close), 0 = full fog (far)
|
||||
|
|
@ -113,4 +140,17 @@ void main() {
|
|||
float fogEnd = uFogParams.y;
|
||||
float span = max(fogEnd - fogStart, 1e-3);
|
||||
vFogFactor = clamp((fogEnd - dist) / span, 0.0, 1.0);
|
||||
|
||||
// Phase W Stage 4: clip the sky/weather to the OutsideView (doorway) region.
|
||||
// With uTerrainClipCount == 0 (outdoor / no exit portal in view) the first loop
|
||||
// is skipped and the second sets all 8 distances to +1.0 ⇒ no clipping ⇒
|
||||
// full-screen sky. Indoors with an exit portal visible, the OutsideView planes
|
||||
// confine the sky to the doorway opening — exactly, per-fragment, matching the
|
||||
// terrain (no scissor approximation). plane.z is 0 (a screen-space slab), so the
|
||||
// sky's depth / dome radius is irrelevant. gl_Position here is the sky's own
|
||||
// dome-projected clip position; the NDC-plane test is projection-independent.
|
||||
for (int i = 0; i < uTerrainClipCount; ++i)
|
||||
gl_ClipDistance[i] = dot(uTerrainClipPlanes[i], gl_Position);
|
||||
for (int i = uTerrainClipCount; i < 8; ++i)
|
||||
gl_ClipDistance[i] = 1.0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue