From 60e0e501415ea3915dd28503fa40c09633b441de 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 43e320fc0..822389758 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -255,7 +255,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 65b6137bf..37d0e25cd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1211,7 +1211,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); } } @@ -1233,7 +1233,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 40129b3b1..0fcb58a3d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1529,7 +1529,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); @@ -1545,7 +1545,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); }