mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-20 18:42:17 +00:00
- fixed: The stencil cap may never write to the depth buffer.
Due to the way nested portals work this will block rendering of the nested cap entriely and cause some visual glitches when looking straight up or down in such a sector. # Conflicts: # src/gl/scene/gl_portal.cpp
This commit is contained in:
parent
d36c839475
commit
c519239a1b
2 changed files with 19 additions and 8 deletions
|
@ -138,7 +138,7 @@ void GLPortal::ClearScreen()
|
|||
// DrawPortalStencil
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void GLPortal::DrawPortalStencil()
|
||||
void GLPortal::DrawPortalStencil(int pass)
|
||||
{
|
||||
if (mPrimIndices.Size() == 0)
|
||||
{
|
||||
|
@ -158,8 +158,11 @@ void GLPortal::DrawPortalStencil()
|
|||
}
|
||||
if (NeedCap() && lines.Size() > 1)
|
||||
{
|
||||
if (pass == STP_AllInOne) glDepthMask(false);
|
||||
else if (pass == STP_DepthRestore) glDepthRange(1, 1);
|
||||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4);
|
||||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4);
|
||||
if (pass == STP_DepthRestore) glDepthRange(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +213,7 @@ bool GLPortal::Start(bool usestencil, bool doquery)
|
|||
}
|
||||
else doquery = false; // some kind of error happened
|
||||
|
||||
DrawPortalStencil();
|
||||
DrawPortalStencil(STP_Stencil);
|
||||
|
||||
glEndQuery(GL_SAMPLES_PASSED);
|
||||
|
||||
|
@ -220,7 +223,7 @@ bool GLPortal::Start(bool usestencil, bool doquery)
|
|||
glDepthMask(true); // enable z-buffer again
|
||||
glDepthRange(1, 1);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
DrawPortalStencil();
|
||||
DrawPortalStencil(STP_DepthClear);
|
||||
|
||||
// set normal drawing mode
|
||||
gl_RenderState.EnableTexture(true);
|
||||
|
@ -254,7 +257,7 @@ bool GLPortal::Start(bool usestencil, bool doquery)
|
|||
// Note: We must draw the stencil with z-write enabled here because there is no second pass!
|
||||
|
||||
glDepthMask(true);
|
||||
DrawPortalStencil();
|
||||
DrawPortalStencil(STP_AllInOne);
|
||||
glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil
|
||||
gl_RenderState.EnableTexture(true);
|
||||
|
@ -373,7 +376,7 @@ void GLPortal::End(bool usestencil)
|
|||
// first step: reset the depth buffer to max. depth
|
||||
glDepthRange(1, 1); // always
|
||||
glDepthFunc(GL_ALWAYS); // write the farthest depth value
|
||||
DrawPortalStencil();
|
||||
DrawPortalStencil(STP_DepthClear);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -385,7 +388,7 @@ void GLPortal::End(bool usestencil)
|
|||
glDepthRange(0, 1);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
|
||||
glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil
|
||||
DrawPortalStencil();
|
||||
DrawPortalStencil(STP_DepthRestore);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
|
||||
|
@ -433,7 +436,7 @@ void GLPortal::End(bool usestencil)
|
|||
gl_RenderState.BlendFunc(GL_ONE, GL_ZERO);
|
||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
gl_RenderState.Apply();
|
||||
DrawPortalStencil();
|
||||
DrawPortalStencil(STP_DepthRestore);
|
||||
gl_RenderState.SetEffect(EFF_NONE);
|
||||
gl_RenderState.EnableTexture(true);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,15 @@ public:
|
|||
static bool inskybox;
|
||||
|
||||
private:
|
||||
void DrawPortalStencil();
|
||||
|
||||
enum
|
||||
{
|
||||
STP_Stencil,
|
||||
STP_DepthClear,
|
||||
STP_DepthRestore,
|
||||
STP_AllInOne
|
||||
};
|
||||
void DrawPortalStencil(int pass);
|
||||
|
||||
DVector3 savedviewpath[2];
|
||||
DVector3 savedViewPos;
|
||||
|
|
Loading…
Reference in a new issue