From a01f1d9e834719046fbdec02a5147d2e55722bac Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 29 Jan 2024 01:56:42 +0000 Subject: Remove the complications from previously storing several shadow maps in the texture --- gfx/gl/shadowMapper.cpp | 69 +++---------------------------------------------- 1 file changed, 3 insertions(+), 66 deletions(-) (limited to 'gfx/gl/shadowMapper.cpp') diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index f3d5dea..4dbee8d 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -40,48 +40,6 @@ ShadowMapper::ShadowMapper(const TextureAbsCoord & s) : glBindFramebuffer(GL_FRAMEBUFFER, 0); } -constexpr std::array, ShadowMapper::SHADOW_BANDS> viewports {{ - {{ - {31, 31, 0, 0}, // full - }}, - {{ - {31, 31, 0, 1}, // lower half - {31, 1, 0, 1}, // upper half - }}, - {{ - {31, 31, 0, 1}, // lower half - {31, 1, 1, 1}, // upper left - {1, 1, 1, 1}, // upper right - }}, - {{ - {31, 31, 1, 1}, // lower left - {1, 31, 1, 1}, // lower right - {31, 1, 1, 1}, // upper left - {1, 1, 1, 1}, // upper right - }}, -}}; -constexpr std::array, ShadowMapper::SHADOW_BANDS> - shadowMapRegions {{ - {{ - {0.5F, 0.5F, 0.5F, 0.5F}, // full - }}, - {{ - {0.5F, 0.25F, 0.5F, 0.25F}, // lower half - {0.5F, 0.25F, 0.5F, 0.75F}, // upper half - }}, - {{ - {0.5F, 0.25F, 0.5F, 0.25F}, // lower half - {0.25F, 0.25F, 0.25F, 0.75F}, // upper left - {0.25F, 0.25F, 0.75F, 0.75F}, // upper right - }}, - - {{ - {0.25F, 0.25F, 0.25F, 0.25F}, // lower left - {0.25F, 0.25F, 0.75F, 0.25F}, // lower right - {0.25F, 0.25F, 0.25F, 0.75F}, // upper left - {0.25F, 0.25F, 0.75F, 0.75F}, // upper right - }}, - }}; constexpr std::array shadowBands { 1000, 250000, @@ -89,24 +47,6 @@ constexpr std::array shadowBands 2500000, 10000000, }; -static_assert(viewports.size() == shadowMapRegions.size()); -static_assert(shadowBands.size() == shadowMapRegions.size() + 1); - -struct DefinitionsInserter { - auto - operator++() - { - return out.maps++; - }; - - auto - operator*() - { - return std::tie(out.projections[out.maps], out.regions[out.maps]); - } - - ShadowMapper::Definitions & out; -}; std::vector> ShadowMapper::getBandViewExtents(const Camera & camera, const glm::mat4 & lightViewDir) @@ -139,7 +79,7 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const const auto bandViewExtents = getBandViewExtents(camera, lightViewDir); Definitions out; std::transform(bandViewExtents.begin(), std::prev(bandViewExtents.end()), std::next(bandViewExtents.begin()), - DefinitionsInserter {out}, + std::back_inserter(out), [bands = bandViewExtents.size() - 2, &lightViewDir](const auto & near, const auto & far) mutable { const auto extents_minmax = [extents = std::span {near.begin(), far.end()}](auto && comp) { const auto mm = std::minmax_element(extents.begin(), extents.end(), comp); @@ -150,13 +90,10 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const return glm::ortho(x.first, x.second, y.first, y.second, -z.second, -z.first); }(extents_minmax(CompareBy {0}), extents_minmax(CompareBy {1}), extents_minmax(CompareBy {2})); - const auto lightViewDirProjection = lightProjection * lightViewDir; - - return std::make_pair(lightViewDirProjection, shadowMapRegions[0][0]); + return lightProjection * lightViewDir; }); - std::span vps {out.projections.data(), out.maps}; for (const auto p : std::initializer_list {&fixedPoint, &dynamicPoint, &dynamicPointInst}) { - p->setView(vps, lightViewPoint); + p->setView(out, lightViewPoint); } scene.shadows(*this); -- cgit v1.2.3