From 80cfd4e0d5e928c2ffed9c4510441fb950908665 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 28 Dec 2022 15:13:01 +0000 Subject: Initial support for multiple shadow maps in the same texture --- gfx/gl/sceneRenderer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gfx/gl/sceneRenderer.cpp') diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index 1d7507a..0fcf471 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -129,16 +129,21 @@ SceneRenderer::setDirectionalLight( SceneRenderer::DirectionalLightProgram::DirectionalLightProgram() : Program {lightingShader_vs, directionalLight_fs}, directionLoc {*this, "lightDirection"}, - colourLoc {*this, "lightColour"}, lightViewProjectionLoc {*this, "lightViewProjection"} + colourLoc {*this, "lightColour"}, lightViewProjectionLoc {*this, "lightViewProjection"}, + lightViewProjectionCountLoc {*this, "lightViewProjectionCount"}, lightViewShadowMapRegionLoc { + *this, "shadowMapRegion"} { } void SceneRenderer::DirectionalLightProgram::setDirectionalLight( - const glm::vec3 & c, const glm::vec3 & d, const glm::mat4x4 & lvp) const + const glm::vec3 & c, const glm::vec3 & d, const std::span lvp) const { + constexpr glm::vec4 shadowMapRegions {0.5F, 0.5F, 0.5F, 0.5F}; glUniform3fv(colourLoc, 1, glm::value_ptr(c)); const auto nd = glm::normalize(d); glUniform3fv(directionLoc, 1, glm::value_ptr(nd)); - glUniformMatrix4fv(lightViewProjectionLoc, 1, GL_FALSE, glm::value_ptr(lvp)); + glUniform1ui(lightViewProjectionCountLoc, static_cast(lvp.size())); + glUniformMatrix4fv(lightViewProjectionLoc, static_cast(lvp.size()), GL_FALSE, glm::value_ptr(lvp.front())); + glUniform4fv(lightViewShadowMapRegionLoc, 1, glm::value_ptr(shadowMapRegions)); } -- cgit v1.2.3