Z-fighting on near-coplanar surfaces (windowsills, frames); worse under TAA jitter -- reversed-Z #188

Closed
opened 2026-09-29 22:59:51 +00:00 by sky_line · 0 comments
Owner

Symptom: coplanar / near-coplanar surfaces (windowsills, frames, trim laid over walls) flicker between each other. Present at native resolution too, so it is not the upscaler (#182).

Why it matters more now: with TAA (RenderFSAAType 3) the projection is jittered every frame, so which surface wins a z-fight changes every frame -- a still camera shows shimmering instead of a fixed pattern. Upscaling (#181) coarsens the depth further.

Depth setup today: D32_SFLOAT, conventional depth (near 0 -> far 1), LESS / LESS_OR_EQUAL tests. Float depth with conventional Z wastes almost all of its precision near the camera; at SL draw distances (256-512 m+) with a small near plane, distant surfaces get very coarse depth steps.

To do

  1. Reversed-Z (near 1 -> far 0, GREATER tests, clear to 0, infinite far plane optional): with a float depth buffer this gives near-uniform relative precision over distance -- the standard fix, and it helps every pass (pre-pass EQUAL, shadows, occlusion Hi-Z, water, SSR, TAA depth tests). Touches: projection matrices from LL (VK conversion point), every depthCompare, depth clears, every shader that linearizes / compares depth (TAA linearDepth, water fog, SSR, AO, DoF, flare, occlusion zmin > far_depth, clean_depth_up, RT).
  2. Check the near plane LL hands us (camera near clip) -- a larger near plane in normal views is cheap extra precision.
  3. Content that is truly coplanar (same plane, both drawn) will still fight: compare with the official viewer / Firestorm to see which cases they also show; LL has no generic fix either.
  4. With TAA on, confirm the fight pattern is stable after 1-2 (jitter no longer decides the winner for surfaces separated by more than the depth step).

Related: #182 (TAA upscale), #167 (occlusion Hi-Z assumes conventional depth).

**Symptom:** coplanar / near-coplanar surfaces (windowsills, frames, trim laid over walls) flicker between each other. Present at native resolution too, so it is not the upscaler (#182). **Why it matters more now:** with TAA (RenderFSAAType 3) the projection is jittered every frame, so which surface wins a z-fight changes every frame -- a still camera shows shimmering instead of a fixed pattern. Upscaling (#181) coarsens the depth further. **Depth setup today:** D32_SFLOAT, conventional depth (near 0 -> far 1), LESS / LESS_OR_EQUAL tests. Float depth with conventional Z wastes almost all of its precision near the camera; at SL draw distances (256-512 m+) with a small near plane, distant surfaces get very coarse depth steps. ### To do 1. **Reversed-Z** (near 1 -> far 0, GREATER tests, clear to 0, infinite far plane optional): with a float depth buffer this gives near-uniform relative precision over distance -- the standard fix, and it helps every pass (pre-pass EQUAL, shadows, occlusion Hi-Z, water, SSR, TAA depth tests). Touches: projection matrices from LL (VK conversion point), every depthCompare, depth clears, every shader that linearizes / compares depth (TAA `linearDepth`, water fog, SSR, AO, DoF, flare, occlusion `zmin > far_depth`, clean_depth_up, RT). 2. Check the near plane LL hands us (camera near clip) -- a larger near plane in normal views is cheap extra precision. 3. Content that is truly coplanar (same plane, both drawn) will still fight: compare with the official viewer / Firestorm to see which cases they also show; LL has no generic fix either. 4. With TAA on, confirm the fight pattern is stable after 1-2 (jitter no longer decides the winner for surfaces separated by more than the depth step). Related: #182 (TAA upscale), #167 (occlusion Hi-Z assumes conventional depth).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#188
No description provided.