diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index a22c25e2d1..b5ef31e366 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -291,7 +291,6 @@ bool GLPortal::Start(bool usestencil, bool doquery) planestack.Push(gl_RenderState.GetClipHeightTop()); planestack.Push(gl_RenderState.GetClipHeightBottom()); glDisable(GL_CLIP_DISTANCE0); - glDisable(GL_CLIP_DISTANCE1); gl_RenderState.SetClipHeightBottom(-65536.f); gl_RenderState.SetClipHeightTop(65536.f); @@ -360,7 +359,7 @@ void GLPortal::End(bool usestencil) if (f > -65535.f) glEnable(GL_CLIP_DISTANCE0); planestack.Pop(f); gl_RenderState.SetClipHeightTop(f); - if (f < 65535.f) glEnable(GL_CLIP_DISTANCE1); + if (f < 65535.f) glEnable(GL_CLIP_DISTANCE0); if (usestencil) { @@ -808,17 +807,17 @@ void GLPlaneMirrorPortal::DrawContents() if (PlaneMirrorMode < 0) { gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everything with a z lower than the portal's ceiling - glEnable(GL_CLIP_DISTANCE1); + gl_RenderState.SetClipHeightBottom(-65536.f); } else { gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor - glEnable(GL_CLIP_DISTANCE0); + gl_RenderState.SetClipHeightTop(65536.f); } + glEnable(GL_CLIP_DISTANCE0); GLRenderer->DrawScene(); glDisable(GL_CLIP_DISTANCE0); - glDisable(GL_CLIP_DISTANCE1); gl_RenderState.SetClipHeightBottom(-65536.f); gl_RenderState.SetClipHeightTop(65536.f); PlaneMirrorFlag--; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 75f814887b..0aef2d35af 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -45,8 +45,14 @@ void main() gl_Position = ProjectionMatrix * eyeCoordPos; // clip planes used for reflective flats - gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; - gl_ClipDistance[1] = uClipHeightTop - worldcoord.y; + if (uClipHeightBottom > -65536.0) + { + gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom; + } + else if (uClipHeightTop < 65536.0) + { + gl_ClipDistance[0] = uClipHeightTop - worldcoord.y; + } gl_ClipDistance[2] = worldcoord.y - uClipSplit.x; gl_ClipDistance[3] = uClipSplit.y - worldcoord.y;