From ac7e298c42e91991fb5325790724c376fa8b70f4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 00:17:31 +0200 Subject: [PATCH] try to fix skywalls zfighting just apply a small polygonoffset to them lets hope this is small enough so they dont end up rendering infront of actual textures and such --- src/hardware/hw_defs.h | 3 ++- src/hardware/hw_main.c | 4 ++-- src/hardware/r_opengl/r_opengl.c | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index ef512bb8a..5bf994054 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -256,7 +256,8 @@ enum EPolyFlags PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y PF_ForceWrapX = 0x00020000, // Force repeat texture on X PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y - PF_Ripple = 0x00100000 // Water ripple effect. The current backend doesn't use it for anything. + PF_Ripple = 0x00100000, // Water ripple effect. The current backend doesn't use it for anything. + PF_Skydecal = 0x20000000 // Enables smaller polygon offset, to be used for skywalls only // 0x20000000 // 0x40000000 // 0x80000000 diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 64f7be60a..c90ea38da 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1248,7 +1248,7 @@ static void HWR_DrawSkyWallList(void) GL_UnSetShader(); for (i = 0; i < skyWallVertexArraySize; i++) { - GL_DrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture); + GL_DrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture|PF_Skydecal); } } @@ -1270,7 +1270,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) else { HWR_SetCurrentTexture(NULL); - HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture, 255, NULL); + HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture|PF_Skydecal, 255, NULL); } // PF_Invisible so it's not drawn into the colour buffer // PF_NoTexture for no texture diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 59fbc9743..a80491e37 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1500,7 +1500,7 @@ void GL_SetBlend(FBITFIELD PolyFlags) { const FBITFIELD Xor = CurrentPolyFlags^PolyFlags;; - if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) + if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Skydecal|PF_Invisible)) { if (Xor & PF_Blending) // if blending mode must be changed GL_SetBlendMode(PolyFlags & PF_Blending); @@ -1516,7 +1516,21 @@ void GL_SetBlend(FBITFIELD PolyFlags) if (Xor & PF_Decal) { if (PolyFlags & PF_Decal) + { + pglPolygonOffset(-1.0f, -1.0f); pglEnable(GL_POLYGON_OFFSET_FILL); + } + else + pglDisable(GL_POLYGON_OFFSET_FILL); + } + + if (Xor & PF_Skydecal) + { + if (PolyFlags & PF_Skydecal) + { + pglPolygonOffset(-0.45f, -0.45f); // dont let skywalls draw over actual walls tho + pglEnable(GL_POLYGON_OFFSET_FILL); + } else pglDisable(GL_POLYGON_OFFSET_FILL); }