summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/shadowStenciller.cpp10
-rw-r--r--gfx/gl/shadowStenciller.h4
2 files changed, 8 insertions, 6 deletions
diff --git a/gfx/gl/shadowStenciller.cpp b/gfx/gl/shadowStenciller.cpp
index 55ad8e1..89b61cc 100644
--- a/gfx/gl/shadowStenciller.cpp
+++ b/gfx/gl/shadowStenciller.cpp
@@ -10,8 +10,6 @@
#include "maths.h"
#include <stdexcept>
-template<typename T> constexpr T STENCIL_ANGLES = 8;
-
ShadowStenciller::ShadowStenciller() :
shadowCaster {shadowStencil_vs, shadowStencil_gs, shadowStencil_fs}, viewProjections {}
{
@@ -24,9 +22,11 @@ ShadowStenciller::ShadowStenciller() :
void
ShadowStenciller::setLightDirection(const LightDirection & lightDir)
{
- 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);
- };
+ viewProjections = [&lightDir]<GLint... Ep>(std::integer_sequence<GLint, Ep...>) {
+ constexpr float STEP = two_pi / STENCIL_ANGLES<decltype(two_pi)>;
+ return std::array {
+ rotate_pitch(half_pi - lightDir.position().y) * rotate_yaw((Ep * STEP) - lightDir.position().x)...};
+ }(std::make_integer_sequence<GLint, STENCIL_ANGLES<GLint>>());
}
glTexture
diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h
index 03efced..ac83eb1 100644
--- a/gfx/gl/shadowStenciller.h
+++ b/gfx/gl/shadowStenciller.h
@@ -9,6 +9,8 @@ class LightDirection;
class ShadowStenciller {
public:
+ template<typename T> static constexpr T STENCIL_ANGLES = 8;
+
ShadowStenciller();
[[nodiscard]]
@@ -21,5 +23,5 @@ private:
Program shadowCaster;
Program::RequiredUniformLocation viewProjectionLoc {shadowCaster, "viewProjection"};
- std::array<glm::mat4, 8> viewProjections;
+ std::array<glm::mat4, STENCIL_ANGLES<size_t>> viewProjections;
};