summaryrefslogtreecommitdiff
path: root/gfx/gl/shadowStenciller.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-03-04 03:12:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2026-03-04 03:12:26 +0000
commit5273a03417b0bb1b1f9f0baabee22466c8ea440c (patch)
treeef13d3639f54bd62db95dccfa34c54e30e2f9f74 /gfx/gl/shadowStenciller.cpp
parentCalculate an appropriate billboardSize and useMeshClipDist (diff)
downloadilt-5273a03417b0bb1b1f9f0baabee22466c8ea440c.tar.bz2
ilt-5273a03417b0bb1b1f9f0baabee22466c8ea440c.tar.xz
ilt-5273a03417b0bb1b1f9f0baabee22466c8ea440c.zip
Update stencils and billboards less often
No need to update these every frame when little of nothing has changed. Instead, track the angle previously rendered and updated only when the new angle has diverged sufficiently from this. Larger updates update more frequently.
Diffstat (limited to 'gfx/gl/shadowStenciller.cpp')
-rw-r--r--gfx/gl/shadowStenciller.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/gfx/gl/shadowStenciller.cpp b/gfx/gl/shadowStenciller.cpp
index 7a0fc9b..19c8bef 100644
--- a/gfx/gl/shadowStenciller.cpp
+++ b/gfx/gl/shadowStenciller.cpp
@@ -10,7 +10,7 @@
#include <stdexcept>
ShadowStenciller::ShadowStenciller() :
- shadowCaster {shadowStencil_vert, shadowStencil_geom, shadowStencil_frag}, viewProjections {}
+ shadowCaster {shadowStencil_vert, shadowStencil_geom, shadowStencil_frag}, lightDir {}, viewProjections {}
{
glDebugScope _ {fbo};
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -22,6 +22,7 @@ ShadowStenciller::ShadowStenciller() :
void
ShadowStenciller::setLightDirection(const LightDirection & lightDir)
{
+ this->lightDir = lightDir.position();
viewProjections = [&lightDir]<GLint... Ep>(std::integer_sequence<GLint, Ep...>) {
constexpr float STEP = two_pi / STENCIL_ANGLES<decltype(two_pi)>;
return std::array {rotate_pitch<4>(half_pi - lightDir.position().y)
@@ -29,6 +30,12 @@ ShadowStenciller::setLightDirection(const LightDirection & lightDir)
}(std::make_integer_sequence<GLint, STENCIL_ANGLES<GLint>>());
}
+Direction2D
+ShadowStenciller::getLightDirection() const
+{
+ return lightDir;
+}
+
glTexture
ShadowStenciller::createStencilTexture(GLsizei width, GLsizei height)
{