diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-06 12:48:40 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-06 14:03:33 +0100 |
commit | 10998a8302b3d7651b4afc046311961eb2dea2c8 (patch) | |
tree | 1b58847ae898f9d3c7fa807bfcaa4b4103d6f35f /gfx/gl/shadowStenciller.cpp | |
parent | Add LightDirection class (diff) | |
download | ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.tar.bz2 ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.tar.xz ilt-10998a8302b3d7651b4afc046311961eb2dea2c8.zip |
Use LightDirection for calculating/passing all light dir components
Diffstat (limited to 'gfx/gl/shadowStenciller.cpp')
-rw-r--r-- | gfx/gl/shadowStenciller.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gfx/gl/shadowStenciller.cpp b/gfx/gl/shadowStenciller.cpp index da2b3a0..ae4012a 100644 --- a/gfx/gl/shadowStenciller.cpp +++ b/gfx/gl/shadowStenciller.cpp @@ -3,6 +3,7 @@ #include "gfx/gl/shaders/fs-shadowStencil.h" #include "gfx/gl/shaders/gs-shadowStencil.h" #include "gfx/gl/shaders/vs-shadowStencil.h" +#include "gfx/lightDirection.h" #include "gfx/models/mesh.h" #include "glArrays.h" #include "gl_traits.h" @@ -26,10 +27,9 @@ ShadowStenciller::ShadowStenciller() : } void -ShadowStenciller::setLightDirection(const Direction3D & lightDir, const Direction3D & lightDirUp) +ShadowStenciller::setLightDirection(const LightDirection & lightDir) { - lightDirMat = glm::lookAt(-lightDir, {}, lightDirUp); - viewProjections = angles * [this](const auto & a) { + viewProjections = angles * [lightDirMat = rotate_pitch(lightDir.position().y)](const auto & a) { return lightDirMat * a; }; } @@ -68,10 +68,11 @@ ShadowStenciller::renderStencil(const glTexture & stencil, const MeshBase & mesh glViewport(0, 0, 256, 256); const auto & centre = mesh.getDimensions().centre; const auto & size = mesh.getDimensions().size; - const auto extentsMat - = glm::translate(glm::ortho(-size, size, -size, size, -size, size), {-centre.x, -centre.z, -centre.y}); - glUniform(viewProjectionLoc, std::span<const glm::mat4> {viewProjections * [&](const auto & vp) { - return extentsMat * vp; + glUniform(viewProjectionLoc, + std::span<const glm::mat4> {viewProjections * + [extentsMat = glm::translate(glm::ortho(-size, size, -size, size, -size, size), -centre)]( + const auto & vp) { + return vp * extentsMat; }}); mesh.Draw(); } |