diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-28 15:13:01 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-28 15:13:05 +0000 |
commit | 80cfd4e0d5e928c2ffed9c4510441fb950908665 (patch) | |
tree | 480f819d4bb7eaf7ad6f86c9a2f9bce3c91b09c2 /gfx/gl/sceneRenderer.cpp | |
parent | Render some train bodies to test shadowing (diff) | |
download | ilt-80cfd4e0d5e928c2ffed9c4510441fb950908665.tar.bz2 ilt-80cfd4e0d5e928c2ffed9c4510441fb950908665.tar.xz ilt-80cfd4e0d5e928c2ffed9c4510441fb950908665.zip |
Initial support for multiple shadow maps in the same texture
Diffstat (limited to 'gfx/gl/sceneRenderer.cpp')
-rw-r--r-- | gfx/gl/sceneRenderer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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<const glm::mat4x4> 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<GLuint>(lvp.size())); + glUniformMatrix4fv(lightViewProjectionLoc, static_cast<GLsizei>(lvp.size()), GL_FALSE, glm::value_ptr(lvp.front())); + glUniform4fv(lightViewShadowMapRegionLoc, 1, glm::value_ptr(shadowMapRegions)); } |