From 66047d123769245e3b5cb8bbe748aefb13db16d4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 28 Dec 2022 19:36:00 +0000 Subject: Generate 4 bands of shadow maps --- gfx/gl/shadowMapper.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'gfx/gl/shadowMapper.cpp') diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index b41a53b..f1beb82 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -33,17 +33,29 @@ ShadowMapper::ShadowMapper(const glm::ivec2 & s) : size {s} glBindFramebuffer(GL_FRAMEBUFFER, 0); } -constexpr std::array viewports {{ - {31, 31, 0, 0}, +constexpr std::array viewports {{ + {31, 31, 1, 1}, + {1, 31, 1, 1}, + {31, 1, 1, 1}, + {1, 1, 1, 1}, }}; -constexpr std::array shadowMapRegions { - {{0.5F, 0.5F, 0.5F, 0.5F}}, +constexpr std::array shadowMapRegions {{ + {0.25F, 0.25F, 0.25F, 0.25F}, + {0.25F, 0.25F, 0.75F, 0.25F}, + {0.25F, 0.25F, 0.25F, 0.75F}, + {0.25F, 0.25F, 0.75F, 0.75F}, +}}; +constexpr std::array shadowBands { + 1.F, + 250.F, + 750.F, + 2500.F, + 10000.F, }; -constexpr std::array shadowBands {1.F, 1000.F}; static_assert(viewports.size() == shadowMapRegions.size()); static_assert(shadowBands.size() == shadowMapRegions.size() + 1); -ShadowMapper::Definitions<1> +ShadowMapper::Definitions ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const Camera & camera) const { glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); @@ -61,8 +73,8 @@ ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const C for (auto & e : viewExtents) { e = lightView * glm::vec4(e, 1); } - Definitions<1> out; - for (std::size_t band = 0; band < viewports.size(); ++band) { + Definitions out; + for (std::size_t band = 0; band < SHADOW_BANDS; ++band) { const auto extents_minmax = [extents = viewExtents.subspan(band * 4, 8)](auto && comp) { const auto mm = std::minmax_element(extents.begin(), extents.end(), comp); return std::make_pair(comp.get(*mm.first), comp.get(*mm.second)); -- cgit v1.2.3