From 1d58b128db3a4b9eff55031993390f8488878587 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 10 Oct 2024 01:10:45 +0100 Subject: Generate stencils as views offset from light direction --- gfx/gl/shadowStenciller.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'gfx/gl/shadowStenciller.cpp') 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 -namespace { - static constexpr std::array 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 {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); }; } -- cgit v1.2.3