diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-17 03:41:51 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-17 03:41:51 +0100 |
commit | d99f1249e861c665710c5d8da0351e525c9f2116 (patch) | |
tree | 99c5623ea7f638f9e3e93f6a93ec192025747f9f /gfx/gl | |
parent | Simple constexpr pow function (diff) | |
download | ilt-d99f1249e861c665710c5d8da0351e525c9f2116.tar.bz2 ilt-d99f1249e861c665710c5d8da0351e525c9f2116.tar.xz ilt-d99f1249e861c665710c5d8da0351e525c9f2116.zip |
Better shadowBands sizes
Still a bit arbitrary, but calculated now to scale across the required range
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 4f7eac1..1b95aa3 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -52,13 +52,15 @@ ShadowMapper::ShadowMapper(const TextureAbsCoord & s) : glBindFramebuffer(GL_FRAMEBUFFER, 0); } -constexpr std::array<GlobalDistance, ShadowMapper::SHADOW_BANDS + 1> shadowBands { - 1000, - 250000, - 750000, - 2500000, - 10000000, -}; +constexpr auto shadowBands + = []<GlobalDistance... ints>(const float scaleFactor, std::integer_sequence<GlobalDistance, ints...>) { + const auto base = 10'000'000 / pow(scaleFactor, sizeof...(ints) - 1); + return std::array {1, static_cast<GlobalDistance>((base * pow(scaleFactor, ints)))...}; + }(6.6F, std::make_integer_sequence<GlobalDistance, ShadowMapper::SHADOW_BANDS>()); + +static_assert(shadowBands.front() == 1); +static_assert(shadowBands.back() == 10'000'000); +static_assert(shadowBands.size() == ShadowMapper::SHADOW_BANDS + 1); std::vector<std::array<RelativePosition3D, 4>> ShadowMapper::getBandViewExtents(const Camera & camera, const glm::mat4 & lightViewDir) |