Revert "fix(render): Phase A8 R3.5 v2 — gate depth-clear on cameraReallyInside too"
This reverts commit 2bfeafd358.
This commit is contained in:
parent
84c4a70296
commit
664ca9cb16
1 changed files with 25 additions and 33 deletions
|
|
@ -7160,42 +7160,17 @@ public sealed class GameWindow : IDisposable
|
||||||
_terrainCpuSampleCursor = (_terrainCpuSampleCursor + 1) % _terrainCpuSamples.Length;
|
_terrainCpuSampleCursor = (_terrainCpuSampleCursor + 1) % _terrainCpuSamples.Length;
|
||||||
MaybeFlushTerrainDiag();
|
MaybeFlushTerrainDiag();
|
||||||
|
|
||||||
// Phase A8 R3.5 — transition-flicker fix. `cameraInsideCell`
|
// Conditional depth clear: when camera is inside a building, clear
|
||||||
// stays true for ~3 grace frames after the camera physically
|
// depth (not color) so interior geometry writes fresh Z values on top
|
||||||
// exits a cell (see CellVisibility._cellSwitchGraceFrames).
|
// of the terrain color buffer. Exit portals show outdoor terrain color
|
||||||
// The grace mechanism prevents sky/lighting flicker at the
|
// because we kept the color buffer. Matching ACME GameScene.cs pattern.
|
||||||
// doorway threshold, but the render-frame mechanisms that
|
if (cameraInsideCell)
|
||||||
// touch depth (depth-clear AND the stencil pipeline) MUST be
|
|
||||||
// gated on the stricter PointInCell containment so they don't
|
|
||||||
// fire during grace frames when the camera is actually outside.
|
|
||||||
//
|
|
||||||
// cameraInsideCell — lenient, grace-aware → sky, lighting
|
|
||||||
// cameraReallyInside — PointInCell, no grace → depth-clear,
|
|
||||||
// stencil pipeline branch
|
|
||||||
//
|
|
||||||
// R3.5 v1 only gated the stencil branch on `cameraReallyInside`;
|
|
||||||
// depth-clear stayed on `cameraInsideCell`. Result: during grace
|
|
||||||
// frames the depth-clear ran but the outdoor branch ran (because
|
|
||||||
// !cameraReallyInside), so terrain depth was destroyed AND
|
|
||||||
// everything below terrain (cellars, basement geometry) won the
|
|
||||||
// depth test in the outdoor pass → "objects visible through
|
|
||||||
// ground." R3.5 v2 unifies the depth-related gates on
|
|
||||||
// `cameraReallyInside` so terrain depth is preserved during
|
|
||||||
// grace, eliminating the through-ground artifact.
|
|
||||||
bool cameraReallyInside = visibility?.CameraCell is not null
|
|
||||||
&& CellVisibility.PointInCell(camPos, visibility.CameraCell);
|
|
||||||
|
|
||||||
// Conditional depth clear: when camera is ACTUALLY inside a cell
|
|
||||||
// volume (not just in the grace window), clear depth (not color)
|
|
||||||
// so interior geometry writes fresh Z values on top of the
|
|
||||||
// terrain color buffer. Matches ACME GameScene.cs pattern.
|
|
||||||
if (cameraReallyInside)
|
|
||||||
_gl!.Clear(ClearBufferMask.DepthBufferBit);
|
_gl!.Clear(ClearBufferMask.DepthBufferBit);
|
||||||
|
|
||||||
// L-fix1 (2026-04-28): animated-entity id set. Required by both
|
// L-fix1 (2026-04-28): animated-entity id set. Required by both
|
||||||
// the cameraReallyInside branch (to route them to LiveDynamic
|
// the cameraInsideCell branch (to route them to LiveDynamic pass)
|
||||||
// pass) and the outdoor path (where it preserves visibility
|
// and the outdoor path (where it preserves visibility across
|
||||||
// across landblock frustum culling).
|
// landblock frustum culling).
|
||||||
HashSet<uint>? animatedIds = null;
|
HashSet<uint>? animatedIds = null;
|
||||||
if (_animatedEntities.Count > 0)
|
if (_animatedEntities.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -7204,6 +7179,23 @@ public sealed class GameWindow : IDisposable
|
||||||
animatedIds.Add(k);
|
animatedIds.Add(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Phase A8 R3.5 — transition-flicker fix. `cameraInsideCell`
|
||||||
|
// stays true for ~3 grace frames after the camera physically
|
||||||
|
// exits a cell (see CellVisibility._cellSwitchGraceFrames).
|
||||||
|
// The grace mechanism prevents lighting/sky flicker at the
|
||||||
|
// doorway threshold, but if the stencil pipeline runs during
|
||||||
|
// grace frames it marks/punches at the OLD cell's portal
|
||||||
|
// silhouettes — which are now behind/beside the camera — and
|
||||||
|
// the subsequent IndoorPass + stencil-gated outdoor produce
|
||||||
|
// a brief frame of "walls disappear + buildings under ground"
|
||||||
|
// garbage. Gate the stencil branch on the stricter
|
||||||
|
// `PointInCell` containment check so the pipeline only runs
|
||||||
|
// when the camera is ACTUALLY inside its cell volume; sky /
|
||||||
|
// lighting / depth-clear continue to use `cameraInsideCell`
|
||||||
|
// for their smoother grace-aware behavior.
|
||||||
|
bool cameraReallyInside = visibility?.CameraCell is not null
|
||||||
|
&& CellVisibility.PointInCell(camPos, visibility.CameraCell);
|
||||||
|
|
||||||
// The `visibility?.CameraCell is not null` repeat is for the
|
// The `visibility?.CameraCell is not null` repeat is for the
|
||||||
// compiler's null-flow analysis: `cameraReallyInside` already
|
// compiler's null-flow analysis: `cameraReallyInside` already
|
||||||
// implies it, but flow doesn't propagate through a separate
|
// implies it, but flow doesn't propagate through a separate
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue