You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finish the dormant reverse-z support (glClipControl probing existed but was
disabled) for both the classic (GLC) and modern (GLM) renderers, behind a new
gl_reverse_z cvar (default on, applies on vid_restart, documented in
help_variables.json).
Reverse-z with a 32-bit float depth buffer distributes depth precision evenly
in view distance, eliminating z-fighting on distant geometry. The projection
now also uses an infinite far plane, so r_farclip no longer clips geometry:
useful for mappers placing detail far outside the playable area, and for very
large maps (e.g. surf maps) that exceed the conventional far plane.
Reverse-z only activates when it actually pays off, i.e. when a float depth
buffer will be used: requires vid_framebuffer 1 with
vid_framebuffer_depthformat 0 (best) or 4 (32-bit float), plus GL 4.5 or
GL_ARB_clip_control. Falls back to conventional depth otherwise (the default
framebuffer only has fixed-point depth, where reverse-z brings no precision
benefit), with a console notice explaining why.
Details:
- Clip control (GL_ZERO_TO_ONE) and glClearDepth(0) are now set once per
context in GL_InitialiseReversedDepth() instead of per-framebuffer; FBO
depth format prefers GL_DEPTH_COMPONENT32F when reversed.
- R_Frustum: reversed branch uses the infinite-far projection
(m[10]=0, m[14]=zNear; near->1, infinity->0). GLC loads the computed matrix
via glLoadMatrixf instead of rebuilding a conventional one with glFrustum.
- Depth range state translation fixed and enabled: logical [near,far] maps to
window [1-far, 1-near], so the viewmodel range [0,0.3] becomes [0.7,1.0]
(GLC path). Depth funcs were already inverted via the existing tables; also
force-sync glDepthFunc at init so state-change elision can't leave the
context at the GL default GL_LESS.
- GLM viewmodel: replace the old clip-space scale (z *= 1/0.3, which
near-clipped the gun e.g. when gibbed) with z' = 0.7*w + 0.3*z, the
clip-space equivalent of glDepthRange(0.7, 1.0); it can never near-clip and
works within batched alias-model draws where per-draw depth range isn't
possible.
- Fog: gl_FragCoord.z/gl_FragCoord.w inverts under reverse-z, so all fog call
sites now use a fogFragDepth() macro that expands to 1.0/gl_FragCoord.w
(exact eye distance) when reversed, legacy expression otherwise.
EZQ_REVERSED_DEPTH is now injected globally into all shaders.
- Polygon offsets are negated when reversed ("farther" = smaller depth).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: help_variables.json
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5564,6 +5564,13 @@
5564
5564
],
5565
5565
"type": "integer"
5566
5566
},
5567
+
"gl_reverse_z": {
5568
+
"default": "1",
5569
+
"desc": "Enables reverse-z depth buffering with an infinite far plane suitable for maps of any size.",
5570
+
"group-id": "35",
5571
+
"remarks": "Takes effect on vid_restart. Only activates when a 32-bit float depth buffer is in use: requires vid_framebuffer 1, vid_framebuffer_depthformat 0 or 4, and OpenGL 4.5+ or the GL_ARB_clip_control extension. Falls back to conventional depth buffering otherwise.",
5572
+
"type": "boolean"
5573
+
},
5567
5574
"gl_rl_globe": {
5568
5575
"default": "0",
5569
5576
"desc": "Helps customize rocket light independent of gl_flashblend.",
0 commit comments