From 309fc1480209bf101b6884f3b5ec64c348be7abe Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 28 Dec 2022 16:16:00 +0000 Subject: Light camera centre not required, view camera position suffices --- gfx/gl/shadowMapper.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'gfx/gl/shadowMapper.cpp') diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 2586982..9c8a4c9 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -47,12 +47,8 @@ ShadowMapper::update(const SceneProvider & scene, const glm::vec3 & dir, const C const auto mm = std::minmax_element(viewExtents.begin(), viewExtents.end(), comp); return std::make_pair(comp.get(*mm.first), comp.get(*mm.second)); }; - // Find camera view centre - const auto centre = [](const auto & x, const auto & y, const auto & z) { - 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 + dir, up); + const auto lightView = glm::lookAt(camera.getPosition(), camera.getPosition() + dir, up); for (auto & e : viewExtents) { e = lightView * glm::vec4(e, 1); } -- cgit v1.2.3