From a0257a4e8330da9c00fe009ede978a4a9fb85793 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 30 Dec 2022 14:56:13 +0000 Subject: Add directional light to pointlight test, fix setting of GL_DEPTH_TEST Fixes issue where directional light prevented pointlights from working --- gfx/gl/sceneRenderer.cpp | 4 +--- gfx/gl/shadowMapper.cpp | 1 - test/test-render.cpp | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index de96571..ee6d927 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -74,8 +74,6 @@ SceneRenderer::render(const SceneProvider & scene) const // Illumination pass glDrawBuffer(GL_COLOR_ATTACHMENT3); - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, gPosition); @@ -84,6 +82,7 @@ SceneRenderer::render(const SceneProvider & scene) const glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadowMapper); scene.environment(shader, *this); + glDisable(GL_DEPTH_TEST); scene.lights(shader); // Lighting pass @@ -123,7 +122,6 @@ SceneRenderer::setDirectionalLight( glBindVertexArray(displayVAO); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindVertexArray(0); - glEnable(GL_DEPTH_TEST); } } diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index f1beb82..5715c0e 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -61,7 +61,6 @@ ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const C glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glViewport(0, 0, size.x, size.y); glClear(GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); glCullFace(GL_FRONT); auto bandViewExtents = shadowBands * [&camera](auto distance) { diff --git a/test/test-render.cpp b/test/test-render.cpp index 8f8fd06..76b8e6a 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(pointlight) environment(const SceneShader &, const SceneRenderer & r) const override { r.setAmbientLight({0.2F, 0.2F, 0.2F}); - r.setDirectionalLight({}, down, *this); + r.setDirectionalLight({0.2F, 0.2F, 0.2F}, west + down, *this); } void lights(const SceneShader & shader) const override -- cgit v1.2.3