From 00a9c964b83bcf4ba316820ef4536f8033bd7bbb Mon Sep 17 00:00:00 2001 From: dpjudas Date: Mon, 7 Apr 2025 01:08:49 +0200 Subject: [PATCH] Render the world surfaces always in DF_LEqual mode instead of sometimes using DF_Less. --- src/rendering/hwrenderer/hw_models.cpp | 4 ---- src/rendering/hwrenderer/scene/hw_drawinfo.cpp | 2 +- src/rendering/hwrenderer/scene/hw_portal.cpp | 7 +++---- src/rendering/hwrenderer/scene/hw_walls.cpp | 4 ---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/rendering/hwrenderer/hw_models.cpp b/src/rendering/hwrenderer/hw_models.cpp index cd99cc4e2..a5540d81f 100644 --- a/src/rendering/hwrenderer/hw_models.cpp +++ b/src/rendering/hwrenderer/hw_models.cpp @@ -56,7 +56,6 @@ VSMatrix FHWModelRenderer::GetViewToWorldMatrix() void FHWModelRenderer::BeginDrawModel(FRenderStyle style, int smf_flags, const VSMatrix &objectToWorldMatrix, bool mirrored) { - state.SetDepthFunc(DF_LEqual); state.EnableTexture(true); if (!gl_texture) @@ -83,14 +82,12 @@ void FHWModelRenderer::EndDrawModel(FRenderStyle style, int smf_flags) { state.SetBoneIndexBase(-1); state.SetModelMatrix(VSMatrix::identity(), VSMatrix::identity()); - state.SetDepthFunc(DF_Less); if ((smf_flags & MDL_FORCECULLBACKFACES) || (!(style == DefaultRenderStyle()) && !(smf_flags & MDL_DONTCULLBACKFACES))) state.SetCulling(Cull_None); } void FHWModelRenderer::BeginDrawHUDModel(FRenderStyle style, const VSMatrix &objectToWorldMatrix, bool mirrored, int smf_flags) { - state.SetDepthFunc(DF_LEqual); state.SetDepthClamp(true); state.EnableTexture(true); @@ -119,7 +116,6 @@ void FHWModelRenderer::EndDrawHUDModel(FRenderStyle style, int smf_flags) state.SetBoneIndexBase(-1); state.SetModelMatrix(VSMatrix::identity(), VSMatrix::identity()); - state.SetDepthFunc(DF_Less); if (!(style == DefaultRenderStyle()) || (smf_flags & MDL_FORCECULLBACKFACES)) state.SetCulling(Cull_None); } diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index 70b67c36b..ed0dafa59 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -754,7 +754,7 @@ void HWDrawInfo::RenderScene(FRenderState &state) } // Part 1: solid geometry. This is set up so that there are no transparent parts - state.SetDepthFunc(DF_Less); + state.SetDepthFunc(DF_LEqual); state.AlphaFunc(Alpha_GEqual, 0.f); state.ClearDepthBias(); diff --git a/src/rendering/hwrenderer/scene/hw_portal.cpp b/src/rendering/hwrenderer/scene/hw_portal.cpp index ed63cd2dc..4a30912c6 100644 --- a/src/rendering/hwrenderer/scene/hw_portal.cpp +++ b/src/rendering/hwrenderer/scene/hw_portal.cpp @@ -284,7 +284,7 @@ void HWPortal::SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil // set normal drawing mode state.EnableTexture(true); state.SetDepthRange(0, 1); - state.SetDepthFunc(DF_Less); + state.SetDepthFunc(DF_LEqual); state.SetColorMask(true); state.SetEffect(EFF_NONE); } @@ -298,6 +298,7 @@ void HWPortal::SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil state.SetStencil(1, SOP_Keep); // draw sky into stencil. This stage doesn't modify the stencil. state.EnableTexture(true); state.SetColorMask(true); + state.SetDepthFunc(DF_LEqual); state.SetEffect(EFF_NONE); state.EnableDepthTest(false); state.SetDepthMask(false); // don't write to Z-buffer! @@ -359,9 +360,8 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci state.SetDepthRange(0, 1); state.SetStencil(0, SOP_Decrement); DrawPortalStencil(state, STP_DepthRestore); - state.SetDepthFunc(DF_Less); - + state.SetDepthFunc(DF_LEqual); state.EnableTexture(true); state.SetEffect(EFF_NONE); state.SetColorMask(true); @@ -396,7 +396,6 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci state.SetEffect(EFF_NONE); state.EnableTexture(true); state.SetColorMask(true); - state.SetDepthFunc(DF_Less); } } diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index dafebf15c..d474fe111 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -146,8 +146,6 @@ void HWWall::RenderMirrorSurface(HWWallDispatcher*di, FRenderState &state) { if (!TexMan.mirrorTexture.isValid()) return; - state.SetDepthFunc(DF_LEqual); - // Use sphere mapping for this state.SetEffect(EFF_SPHEREMAP); SetColor(state, di->Level, di->lightmode, lightlevel, 0, di->isFullbrightScene(), Colormap, 0.1f); @@ -165,8 +163,6 @@ void HWWall::RenderMirrorSurface(HWWallDispatcher*di, FRenderState &state) state.SetEffect(EFF_NONE); state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold); - state.SetDepthFunc(DF_Less); - // This is drawn in the translucent pass which is done after the decal pass // As a result the decals have to be drawn here, right after the wall they are on, // because the depth buffer won't get set by translucent items.