- it's really not necessary to waste two clip planes for reflective surfaces because only one can be active at any time.

This commit is contained in:
Christoph Oelckers 2016-01-27 12:30:55 +01:00
parent 3c16a23865
commit 47db3252f4
2 changed files with 12 additions and 7 deletions

View file

@ -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--;

View file

@ -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;