summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-22 20:56:28 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-22 20:56:28 +0000
commitab264cdca7cfb9b47a7ff1f28cd843aab0eda96f (patch)
treeda824f3342eed061d3db5041f4f4df8362172a43
parentInvert shadow mapper orthographic project z... because glmOrtho is 'helpful' (diff)
downloadilt-ab264cdca7cfb9b47a7ff1f28cd843aab0eda96f.tar.bz2
ilt-ab264cdca7cfb9b47a7ff1f28cd843aab0eda96f.tar.xz
ilt-ab264cdca7cfb9b47a7ff1f28cd843aab0eda96f.zip
No need for the range hack, the shadow box is just centred around the origin
-rw-r--r--gfx/gl/shadowMapper.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp
index 65c77c5..5691de9 100644
--- a/gfx/gl/shadowMapper.cpp
+++ b/gfx/gl/shadowMapper.cpp
@@ -36,8 +36,6 @@ ShadowMapper::ShadowMapper(const glm::ivec2 & s) : size {s}
glm::mat4x4
ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const Camera & camera) const
{
- constexpr auto BACK_OFF = 3600.f;
- const glm::vec3 range = glm::normalize(dir) * BACK_OFF;
auto viewExtents = camera.extentsAtDist(1) + camera.extentsAtDist(1000);
const auto extents_minmax = [&viewExtents](auto && comp) {
const auto mm = std::minmax_element(viewExtents.begin(), viewExtents.end(), comp);
@@ -48,7 +46,7 @@ ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const C
return glm::vec3 {midpoint(x), midpoint(y), midpoint(z)};
}(extents_minmax(CompareBy {0}), extents_minmax(CompareBy {1}), extents_minmax(CompareBy {2}));
- const auto lightView = glm::lookAt(centre, centre + range, up);
+ const auto lightView = glm::lookAt(centre, centre + dir, up);
for (auto & e : viewExtents) {
e = lightView * glm::vec4(e, 1);
}