From 2d4b8549c6302728c52cab824cea1c991fe5d2a9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 20 May 2018 08:56:29 +0200 Subject: [PATCH] - per-sector plane rendering needs to be disabled when processing a line portal with hardware that has no working clip plane support. In this case there are no means to discard the parts of the rendered sectors that lie behind the portal so it should only render the parts that are flagged as visible. --- src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/renderer/gl_renderstate.h | 11 +++++++++++ src/gl/scene/gl_flats.cpp | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 305a5177c..a0a1c5cc8 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -62,7 +62,7 @@ static void matrixToGL(const VSMatrix &mat, int loc) void FRenderState::Reset() { mTextureEnabled = true; - mClipLineEnabled = mSplitEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; + mClipLineShouldBeActive = mClipLineEnabled = mSplitEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; mColorMask[0] = mColorMask[1] = mColorMask[2] = mColorMask[3] = true; currentColorMask[0] = currentColorMask[1] = currentColorMask[2] = currentColorMask[3] = true; mFogColor.d = -1; diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 1db6602a5..8aa4d0093 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -81,6 +81,7 @@ class FRenderState bool mGlowEnabled; bool mSplitEnabled; bool mClipLineEnabled; + bool mClipLineShouldBeActive; bool mBrightmapEnabled; bool mColorMask[4]; bool currentColorMask[4]; @@ -201,6 +202,11 @@ public: return mClipLineEnabled; } + bool GetClipLineShouldBeActive() + { + return mClipLineShouldBeActive; + } + void SetClipHeight(float height, float direction); void SetNormal(FVector3 norm) @@ -326,6 +332,11 @@ public: glDisable(GL_CLIP_DISTANCE0); } } + else + { + // this needs to be flagged because in this case per-sector plane rendering needs to be disabled if a clip plane is active. + mClipLineShouldBeActive = on; + } } void EnableBrightmap(bool on) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 39ab921b4..1810508bc 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -167,7 +167,7 @@ void FDrawInfo::ProcessLights(GLFlat *flat, bool istrans) { flat->dynlightindex = GLRenderer->mLights->GetIndexPtr(); - if (flat->sector->ibocount > 0 && !gl_render_subsectors) + if (flat->sector->ibocount > 0 && !gl_render_subsectors && !gl_RenderState.GetClipLineShouldBeActive()) { SetupSectorLights(flat, GLPASS_LIGHTSONLY, nullptr); } @@ -214,7 +214,7 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool if (gl.legacyMode) processlights = false; auto vcount = flat->sector->ibocount; - if (vcount > 0 && !gl_render_subsectors) + if (vcount > 0 && !gl_render_subsectors && !gl_RenderState.GetClipLineShouldBeActive()) { if (processlights) SetupSectorLights(flat, GLPASS_ALL, &dli); drawcalls.Clock();