summaryrefslogtreecommitdiff
path: root/gfx/gl/shadowStenciller.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-10-10 01:10:45 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-10-10 01:10:45 +0100
commit1d58b128db3a4b9eff55031993390f8488878587 (patch)
tree712120ebf78693dab9733ccc5d883968157e7763 /gfx/gl/shadowStenciller.cpp
parentUse foliage yaw rotation to select shadow stencil layer (diff)
downloadilt-1d58b128db3a4b9eff55031993390f8488878587.tar.bz2
ilt-1d58b128db3a4b9eff55031993390f8488878587.tar.xz
ilt-1d58b128db3a4b9eff55031993390f8488878587.zip
Generate stencils as views offset from light direction
Diffstat (limited to 'gfx/gl/shadowStenciller.cpp')
-rw-r--r--gfx/gl/shadowStenciller.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/gfx/gl/shadowStenciller.cpp b/gfx/gl/shadowStenciller.cpp
index ae4012a..30a67a7 100644
--- a/gfx/gl/shadowStenciller.cpp
+++ b/gfx/gl/shadowStenciller.cpp
@@ -10,13 +10,6 @@
#include "maths.h"
#include <stdexcept>
-namespace {
- static constexpr std::array<float, 8> anglesEigthPi {-3, -2, -1, 0, 1, 2, 3, 4};
- static const auto angles = anglesEigthPi * [](auto ep) {
- return rotate_yaw(ep * quarter_pi);
- };
-}
-
ShadowStenciller::ShadowStenciller() :
shadowCaster {shadowStencil_vs, shadowStencil_gs, shadowStencil_fs}, viewProjections {}
{
@@ -29,8 +22,8 @@ ShadowStenciller::ShadowStenciller() :
void
ShadowStenciller::setLightDirection(const LightDirection & lightDir)
{
- viewProjections = angles * [lightDirMat = rotate_pitch(lightDir.position().y)](const auto & a) {
- return lightDirMat * a;
+ viewProjections = std::array<float, 8> {0, 1, 2, 3, 4, 5, 6, 7} * [&lightDir](const auto & ep) {
+ return rotate_pitch(half_pi - lightDir.position().y) * rotate_yaw((ep * quarter_pi) - lightDir.position().x);
};
}