summaryrefslogtreecommitdiff
path: root/gfx/gl/sceneRenderer.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-10-06 12:48:40 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-10-06 14:03:33 +0100
commit10998a8302b3d7651b4afc046311961eb2dea2c8 (patch)
tree1b58847ae898f9d3c7fa807bfcaa4b4103d6f35f /gfx/gl/sceneRenderer.cpp
parentAdd LightDirection class (diff)
downloadilt-10998a8302b3d7651b4afc046311961eb2dea2c8.tar.bz2
ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.tar.xz
ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.zip
Use LightDirection for calculating/passing all light dir components
Diffstat (limited to 'gfx/gl/sceneRenderer.cpp')
-rw-r--r--gfx/gl/sceneRenderer.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp
index 7aace49..b2a7d78 100644
--- a/gfx/gl/sceneRenderer.cpp
+++ b/gfx/gl/sceneRenderer.cpp
@@ -114,7 +114,8 @@ SceneRenderer::setAmbientLight(const RGB & colour) const
}
void
-SceneRenderer::setDirectionalLight(const RGB & colour, const Direction3D & direction, const SceneProvider & scene) const
+SceneRenderer::setDirectionalLight(
+ const RGB & colour, const LightDirection & direction, const SceneProvider & scene) const
{
if (colour.r > 0 || colour.g > 0 || colour.b > 0) {
const auto lvp = shadowMapper.update(scene, direction, camera);
@@ -128,7 +129,7 @@ SceneRenderer::setDirectionalLight(const RGB & colour, const Direction3D & direc
glBindTexture(GL_TEXTURE_2D_ARRAY, shadowMapper);
glViewport(0, 0, size.x, size.y);
dirLight.use();
- dirLight.setDirectionalLight(colour, direction, camera.getPosition(), lvp);
+ dirLight.setDirectionalLight(colour, direction.vector(), camera.getPosition(), lvp);
renderQuad();
}
}
@@ -154,8 +155,7 @@ SceneRenderer::DirectionalLightProgram::setDirectionalLight(
return toTextureSpaceMat * m;
};
glUniform(colourLoc, c);
- const auto nd = glm::normalize(d);
- glUniform(directionLoc, nd);
+ glUniform(directionLoc, d);
glUniform(lightPointLoc, p);
glUniform(lightViewProjectionCountLoc, static_cast<GLuint>(lvp.size()));
glUniform(lightViewProjectionLoc, std::span<const glm::mat4> {lvp * toTextureSpace});