From 282b386e6fb36e2fa6b572ffb8d0595d57f47dbd Mon Sep 17 00:00:00 2001 From: Anselme Date: Fri, 25 Aug 2017 19:30:11 +0200 Subject: [PATCH] more verifications to force stencil good behaviour (bad boy) --- src/deferredpipeline.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/deferredpipeline.cpp b/src/deferredpipeline.cpp index 5f07f7f..cee38e9 100644 --- a/src/deferredpipeline.cpp +++ b/src/deferredpipeline.cpp @@ -148,13 +148,15 @@ void DeferredPipeline::renderGL(Scene *scene) glClearColor(0.0f, 0.0f, 0.0f, 1.f); glClearDepth(1.0f); glClearStencil(0); + glStencilMask(0xFF); + glDisable(GL_SCISSOR_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glStencilMask(0x01); glStencilFunc(GL_ALWAYS, 0x01, 0x01); // always draw fragments (ignore the stencil buffer values for now) // draw skybox if(m_skybox != nullptr) { - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); m_skybox->renderGL(m_camera); glClear(GL_DEPTH_BUFFER_BIT); } @@ -204,12 +206,12 @@ void DeferredPipeline::renderGL(Scene *scene) { shader->bind(); shader->bindInteger(shader->getLocation("emissionBuffer"), GBuffer::EMISSION); - glStencilFunc(GL_EQUAL, 1, 0x01); + glStencilFunc(GL_EQUAL, 0, 0x01); SparrowRenderer::drawQuad(); } // loop on light sources - glStencilFunc(GL_EQUAL, 0, 0x01); + glStencilFunc(GL_EQUAL, 0x01, 0x01); for(SceneIterator* lightIt = scene->getLights(); lightIt->isValid(); lightIt->next()) {