From 892513f81ed68e05d4dedb99f51de5bc46cab6b2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 28 Jan 2024 02:25:11 +0000 Subject: Geometry shader for single pass shadow maps 2D array texture, 4 levels, geometry shader outputs to each layer for a specific band, single scene rendering. Pending massive tidy up. --- gfx/gl/sceneRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gfx/gl/sceneRenderer.cpp') diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index 4c96902..b60d9af 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -81,7 +81,7 @@ SceneRenderer::render(const SceneProvider & scene) const glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, gNormal); glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, shadowMapper); + glBindTexture(GL_TEXTURE_2D_ARRAY, shadowMapper); scene.environment(shader, *this); glDisable(GL_DEPTH_TEST); scene.lights(shader); -- cgit v1.2.3 From a01f1d9e834719046fbdec02a5147d2e55722bac Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 29 Jan 2024 01:56:42 +0000 Subject: Remove the complications from previously storing several shadow maps in the texture --- gfx/gl/sceneRenderer.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'gfx/gl/sceneRenderer.cpp') diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index b60d9af..2dd1760 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -116,7 +116,7 @@ SceneRenderer::setDirectionalLight(const RGB & colour, const Direction3D & direc glBindFramebuffer(GL_FRAMEBUFFER, gBufferIll); glViewport(0, 0, size.x, size.y); dirLight.use(); - dirLight.setDirectionalLight(colour, direction, camera.getPosition(), lvp.projections, lvp.regions, lvp.maps); + dirLight.setDirectionalLight(colour, direction, camera.getPosition(), lvp); renderQuad(); } } @@ -133,21 +133,18 @@ SceneRenderer::DirectionalLightProgram::DirectionalLightProgram() : Program {lighting_vs, directionalLight_fs}, directionLoc {*this, "lightDirection"}, colourLoc {*this, "lightColour"}, lightPointLoc {*this, "lightPoint"}, lightViewProjectionLoc {*this, "lightViewProjection"}, - lightViewProjectionCountLoc {*this, "lightViewProjectionCount"}, - lightViewShadowMapRegionLoc {*this, "shadowMapRegion"} + lightViewProjectionCountLoc {*this, "lightViewProjectionCount"} { } void -SceneRenderer::DirectionalLightProgram::setDirectionalLight(const RGB & c, const Direction3D & d, - const GlobalPosition3D & p, const std::span lvp, - const std::span shadowMapRegions, std::size_t maps) const +SceneRenderer::DirectionalLightProgram::setDirectionalLight( + const RGB & c, const Direction3D & d, const GlobalPosition3D & p, const std::span lvp) const { glUniform(colourLoc, c); const auto nd = glm::normalize(d); glUniform(directionLoc, nd); glUniform(lightPointLoc, p); - glUniform(lightViewProjectionCountLoc, static_cast(maps)); + glUniform(lightViewProjectionCountLoc, static_cast(lvp.size())); glUniform(lightViewProjectionLoc, lvp); - glUniform(lightViewShadowMapRegionLoc, shadowMapRegions); } -- cgit v1.2.3 From 72ec5dd096a3110e8085919f4c0e3320ef176657 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 30 Jan 2024 22:13:56 +0000 Subject: Adjust light view projection matrix upfront Saves doing it per pixel, per region later --- gfx/gl/sceneRenderer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gfx/gl/sceneRenderer.cpp') diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index 2dd1760..517d51e 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -137,14 +137,20 @@ SceneRenderer::DirectionalLightProgram::DirectionalLightProgram() : { } +const auto toTextureSpaceMat = glm::translate(glm::identity(), glm::vec3 {0.5F}) + * glm::scale(glm::identity(), glm::vec3 {0.5F}); + void SceneRenderer::DirectionalLightProgram::setDirectionalLight( const RGB & c, const Direction3D & d, const GlobalPosition3D & p, const std::span lvp) const { + const auto toTextureSpace = [](const glm::mat4 & m) { + return toTextureSpaceMat * m; + }; glUniform(colourLoc, c); const auto nd = glm::normalize(d); glUniform(directionLoc, nd); glUniform(lightPointLoc, p); glUniform(lightViewProjectionCountLoc, static_cast(lvp.size())); - glUniform(lightViewProjectionLoc, lvp); + glUniform(lightViewProjectionLoc, std::span {lvp * toTextureSpace}); } -- cgit v1.2.3