User report after Step 5 disable + cull-cache fix: "Cant see anything,
flickering colors, sometimes textures sometimes inside, house missing
lots of walls. 10 FPS. GPU 100%."
Root cause: terrain was being drawn TWICE per indoor frame:
1. Line 7283 _terrain.Draw — UNCONDITIONAL pre-A8 pass; writes full-
screen terrain color + depth at terrain Z.
2. Step 4 inside RenderInsideOutAcdream — stencil-gated terrain at
portal silhouettes only (matching WB VisibilityManager:143).
Pre-A8 papered over the Z conflict with a depth-clear-if-inside
workaround (cleared depth between terrain and cottage) which we
DELETED as part of Wave 4. Without it, when Step 3 writes the cell
geometry with DepthFunc.Less, the cottage walls at Z=92-94 (where
they meet the ground) Z-FIGHT against the terrain already in the
depth buffer from pass 1. Symptom: flickering walls + missing
sections + GPU saturated drawing terrain twice.
Fix: gate the line-7200 terrain draw on `!cameraInsideBuilding`.
When indoor, Step 4 is the SOLE terrain pass — stencil-gated to
portal silhouettes only. No double-draw, no Z-fighting, no need
for the deleted depth-clear workaround.
Outdoor mode unchanged (pass 1 still fires, Step 4 isn't taken).
Build green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>