From 88caa0dc8b783f234fefcc2f1e9f14a351cef835 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 7 Jun 2026 20:18:33 +0200 Subject: [PATCH] fix(render): outdoor-root skips the full-screen depth clear (cellar/buildings no longer draw over the world) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cutover-flip follow-up (issues 1+2 from the visual gate). After the flip an outdoor-node frame ran DrawInside with a full-screen OutsideView slice (Step A) whose ClearDepthSlice wiped the ENTIRE depth buffer AFTER terrain/exteriors/player drew — so the flooded building interior shells (cellars) drew over everything: the cellar painted in front of the player from outside, and distant building interiors showed through the ground in the open field. The depth clear is a doorway look-in trick (clear a small door region so the cell seen through it draws over the terrain drawn through it). It is wrong for the full-screen base terrain of the outdoor root. Skip it there (ClearDepthSlice=null when clipRoot is the outdoor node); interiors now depth-test against terrain + exteriors and appear only through real door openings. Interior roots keep the doorway clear unchanged. App 216/0, build green. Visual gate pending (player must be outdoors to exercise the outdoor root). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.App/Rendering/GameWindow.cs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index 481eb6fe..a1a96a34 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -7527,13 +7527,24 @@ public sealed class GameWindow : IDisposable renderSky, kf, environOverrideActive), - ClearDepthSlice = slice => - { - bool zc = BeginDoorwayScissor(true, slice.NdcAabb); - _gl.Clear(ClearBufferMask.DepthBufferBit); - if (zc) - _gl.Disable(EnableCap.ScissorTest); - }, + // The depth clear is a doorway "look-in" trick: clear depth inside a door/window + // region so the cell seen THROUGH it draws over the terrain drawn through that + // region (the indoor root looking out). For the OUTDOOR-node root the only + // OutsideView slice is the FULL-SCREEN base terrain, so clearing its depth wipes the + // entire depth buffer AFTER terrain/exteriors/player drew — the flooded building + // interiors (cellars) would then paint over everything (cellar in front of the + // player; building interiors through the ground). Outdoors the interiors must + // depth-test against terrain+exteriors and appear only through real door openings, + // so issue NO depth clear. Interior roots keep the doorway clear (unchanged). + ClearDepthSlice = ReferenceEquals(clipRoot, _outdoorNode) + ? null + : slice => + { + bool zc = BeginDoorwayScissor(true, slice.NdcAabb); + _gl.Clear(ClearBufferMask.DepthBufferBit); + if (zc) + _gl.Disable(EnableCap.ScissorTest); + }, DrawCellParticles = sliceCtx => DrawRetailPViewCellParticles(sliceCtx, camera, camPos), EmitDiagnostics = result =>