summaryrefslogtreecommitdiff
path: root/gfx/gl/sceneRenderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl/sceneRenderer.cpp')
-rw-r--r--gfx/gl/sceneRenderer.cpp8
1 files changed, 7 insertions, 1 deletions
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::mat4>(), glm::vec3 {0.5F})
+ * glm::scale(glm::identity<glm::mat4>(), glm::vec3 {0.5F});
+
void
SceneRenderer::DirectionalLightProgram::setDirectionalLight(
const RGB & c, const Direction3D & d, const GlobalPosition3D & p, const std::span<const glm::mat4x4> 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<GLuint>(lvp.size()));
- glUniform(lightViewProjectionLoc, lvp);
+ glUniform(lightViewProjectionLoc, std::span<const glm::mat4> {lvp * toTextureSpace});
}