From 344034bcd36f2b6bc2b147454399bfe1a0a05008 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 26 May 2026 07:55:15 +0200 Subject: [PATCH] =?UTF-8?q?fix(render):=20Phase=20A8=20=E2=80=94=20remove?= =?UTF-8?q?=20over-engineered=20shader=20guards=20(Task=204)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the pos.w clamp in portal_stencil.vert and the FragColor declaration in portal_stencil.frag added in 2d31d49. Both were speculative defensive code not in the spec or the WB reference. The shaders now match the spec verbatim (except the locally-conventional `core` profile qualifier which is correct). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/AcDream.App/Rendering/Shaders/portal_stencil.frag | 9 --------- src/AcDream.App/Rendering/Shaders/portal_stencil.vert | 11 +---------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/AcDream.App/Rendering/Shaders/portal_stencil.frag b/src/AcDream.App/Rendering/Shaders/portal_stencil.frag index ba71c36..7ff1582 100644 --- a/src/AcDream.App/Rendering/Shaders/portal_stencil.frag +++ b/src/AcDream.App/Rendering/Shaders/portal_stencil.frag @@ -10,25 +10,16 @@ // Matches WorldBuilder's PortalStencil.frag at // references/WorldBuilder/Chorizite.OpenGLSDLBackend/Shaders/PortalStencil.frag -out vec4 FragColor; - uniform int uWriteFarDepth; void main() { if (uWriteFarDepth != 0) { - // Write far depth to clear the depth buffer in the portal region. - // This punches through the building exterior's depth so interior - // geometry at any depth can be rendered through the stencil mask. gl_FragDepth = 1.0; } else { gl_FragDepth = gl_FragCoord.z; } - - // Color writes are suppressed via ColorMask(false) on the CPU side. - // Output is required by GLSL but will not be written to the framebuffer. - FragColor = vec4(0.0); } diff --git a/src/AcDream.App/Rendering/Shaders/portal_stencil.vert b/src/AcDream.App/Rendering/Shaders/portal_stencil.vert index adb4d60..bdd118f 100644 --- a/src/AcDream.App/Rendering/Shaders/portal_stencil.vert +++ b/src/AcDream.App/Rendering/Shaders/portal_stencil.vert @@ -12,14 +12,5 @@ uniform mat4 uViewProjection; void main() { - vec4 pos = uViewProjection * vec4(aPosition, 1.0); - - // Prevent near-zero clipping issues when the camera is perfectly - // coplanar with the portal polygon. - if (abs(pos.w) < 0.001) - { - pos.w = pos.w < 0.0 ? -0.001 : 0.001; - } - - gl_Position = pos; + gl_Position = uViewProjection * vec4(aPosition, 1.0); }