From 839bf2ab51c4ec55f06b4224716c564451758072 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 7 Jan 2023 15:41:04 +0000 Subject: Only generate the first N shadow maps which are useful Note: we don't yet optimise the use of the shadow map texture, each still renders into its own corner --- gfx/gl/camera.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gfx/gl/camera.cpp') diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index b52eca7..2ea326d 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -34,19 +34,19 @@ Camera::upFromForward(const glm::vec3 & forward) return glm::cross(forward, right); } -std::array +std::array Camera::extentsAtDist(const float dist) const { - const auto clampToSeaFloor = [this](const glm::vec3 & target) { + const auto clampToSeaFloor = [this, dist](const glm::vec3 & target) { if (target.z < -1.5f) { const auto vec = glm::normalize(target - position); constexpr glm::vec3 seafloor {0, 0, -1.5}; float outdist; if (glm::intersectRayPlane(position, vec, seafloor, ::up, outdist)) { - return vec * outdist + position; + return (vec * outdist + position) ^ outdist; } } - return target; + return target ^ dist; }; const auto depth = -(2.f * (dist - near) * far) / (dist * (near - far)) - 1.f; static constexpr const std::array extents {-1.F, 1.F}; -- cgit v1.2.3