summaryrefslogtreecommitdiff
path: root/gfx/gl/camera.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-01-07 15:41:04 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-01-07 15:41:04 +0000
commit839bf2ab51c4ec55f06b4224716c564451758072 (patch)
tree63800794b1bcff504947cde45472d0c893f0aeda /gfx/gl/camera.cpp
parentmin/mag filter for shadow mapper depth map texture (diff)
downloadilt-839bf2ab51c4ec55f06b4224716c564451758072.tar.bz2
ilt-839bf2ab51c4ec55f06b4224716c564451758072.tar.xz
ilt-839bf2ab51c4ec55f06b4224716c564451758072.zip
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
Diffstat (limited to 'gfx/gl/camera.cpp')
-rw-r--r--gfx/gl/camera.cpp8
1 files changed, 4 insertions, 4 deletions
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<glm::vec3, 4>
+std::array<glm::vec4, 4>
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};