diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-12-11 20:11:23 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-12-11 20:16:22 +0000 |
commit | daed922f23daa8a8e2659d8aea7864cccd5e08c7 (patch) | |
tree | e8a1c949f3341f331408d91826038ab63346e32d /gfx/gl/shadowMapper.cpp | |
parent | Helper for testing integer vector approximations (diff) | |
download | ilt-daed922f23daa8a8e2659d8aea7864cccd5e08c7.tar.bz2 ilt-daed922f23daa8a8e2659d8aea7864cccd5e08c7.tar.xz ilt-daed922f23daa8a8e2659d8aea7864cccd5e08c7.zip |
Integer camera
Diffstat (limited to 'gfx/gl/shadowMapper.cpp')
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 66905df..deb0630 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -79,12 +79,12 @@ constexpr std::array<std::array<TextureRelRegion, ShadowMapper::SHADOW_BANDS>, S {0.25F, 0.25F, 0.75F, 0.75F}, // upper right }}, }}; -constexpr std::array<float, ShadowMapper::SHADOW_BANDS + 1> shadowBands { - 1000.F, - 250000.F, - 750000.F, - 2500000.F, - 10000000.F, +constexpr std::array<GlobalDistance, ShadowMapper::SHADOW_BANDS + 1> shadowBands { + 1000, + 250000, + 750000, + 2500000, + 10000000, }; static_assert(viewports.size() == shadowMapRegions.size()); static_assert(shadowBands.size() == shadowMapRegions.size() + 1); @@ -114,7 +114,7 @@ ShadowMapper::getBandViewExtents(const Camera & camera, const glm::mat4 & lightV bandViewExtents.emplace_back(extents * [&lightView](const auto & e) -> Position3D { return lightView * glm::vec4(Position3D {e}, 1); }); - if (std::none_of(extents.begin(), extents.end(), [targetDist = dist * 0.99F](const glm::vec4 & e) { + if (std::none_of(extents.begin(), extents.end(), [targetDist = dist - 1](const auto & e) { return e.w > targetDist; })) { break; @@ -130,8 +130,8 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const glClear(GL_DEPTH_BUFFER_BIT); glCullFace(GL_FRONT); - const auto lightView = glm::lookAt(camera.getPosition(), camera.getPosition() + dir, up); const auto lightViewDir = glm::lookAt(origin, dir, up); + const auto lightView = lightViewDir * glm::translate(RelativePosition3D {-camera.getPosition()}); const auto lightViewPoint = camera.getPosition(); const auto bandViewExtents = getBandViewExtents(camera, lightView); |