summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-28 16:16:00 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-28 16:21:25 +0000
commit309fc1480209bf101b6884f3b5ec64c348be7abe (patch)
tree1ada3d46fb5c785f50ecb4d96ac4afe9b01e8fee /gfx
parentChange default light direction (diff)
downloadilt-309fc1480209bf101b6884f3b5ec64c348be7abe.tar.bz2
ilt-309fc1480209bf101b6884f3b5ec64c348be7abe.tar.xz
ilt-309fc1480209bf101b6884f3b5ec64c348be7abe.zip
Light camera centre not required, view camera position suffices
Diffstat (limited to 'gfx')
-rw-r--r--gfx/gl/shadowMapper.cpp6
1 files changed, 1 insertions, 5 deletions
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);
}