diff options
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 31 | ||||
-rw-r--r-- | gfx/gl/shadowMapper.h | 6 |
2 files changed, 27 insertions, 10 deletions
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index ab4ac50..040010f 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -134,11 +134,14 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const const auto lightViewDir = glm::lookAt({}, dir, up); const auto lightViewPoint = camera.getPosition(); const auto bandViewExtents = getBandViewExtents(camera, lightViewDir); + fixedPoint.setViewPoint(lightViewPoint); + dynamicPoint.setViewPoint(lightViewPoint); + dynamicPointInst.setViewPoint(lightViewPoint); Definitions out; std::transform(bandViewExtents.begin(), std::prev(bandViewExtents.end()), std::next(bandViewExtents.begin()), DefinitionsInserter {out}, - [&scene, this, bands = bandViewExtents.size() - 2, &out, &lightViewPoint, &lightViewDir]( + [&scene, this, bands = bandViewExtents.size() - 2, &out, &lightViewDir]( const auto & near, const auto & far) { const auto extents_minmax = [extents = std::span {near.begin(), far.end()}](auto && comp) { const auto mm = std::minmax_element(extents.begin(), extents.end(), comp); @@ -150,9 +153,9 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const }(extents_minmax(CompareBy {0}), extents_minmax(CompareBy {1}), extents_minmax(CompareBy {2})); const auto lightViewDirProjection = lightProjection * lightViewDir; - fixedPoint.setViewProjection(lightViewPoint, lightViewDirProjection); - dynamicPoint.setViewProjection(lightViewPoint, lightViewDirProjection); - dynamicPointInst.setViewProjection(lightViewPoint, lightViewDirProjection); + fixedPoint.setViewProjection(lightViewDirProjection); + dynamicPoint.setViewProjection(lightViewDirProjection); + dynamicPointInst.setViewProjection(lightViewDirProjection); const auto & viewport = viewports[bands][out.maps]; glViewport(size.x >> viewport.x, size.y >> viewport.y, size.x >> viewport.z, size.y >> viewport.w); @@ -172,14 +175,20 @@ ShadowMapper::FixedPoint::FixedPoint(const Shader & vs) : } void -ShadowMapper::FixedPoint::setViewProjection(const GlobalPosition3D viewPoint, const glm::mat4 & viewProjection) const +ShadowMapper::FixedPoint::setViewPoint(const GlobalPosition3D viewPoint) const { use(); - glUniform(viewProjectionLoc, viewProjection); glUniform(viewPointLoc, viewPoint); } void +ShadowMapper::FixedPoint::setViewProjection(const glm::mat4 & viewProjection) const +{ + use(); + glUniform(viewProjectionLoc, viewProjection); +} + +void ShadowMapper::FixedPoint::use() const { glUseProgram(*this); @@ -192,14 +201,20 @@ ShadowMapper::DynamicPoint::DynamicPoint() : } void -ShadowMapper::DynamicPoint::setViewProjection(const GlobalPosition3D viewPoint, const glm::mat4 & viewProjection) const +ShadowMapper::DynamicPoint::setViewPoint(const GlobalPosition3D viewPoint) const { glUseProgram(*this); - glUniform(viewProjectionLoc, viewProjection); glUniform(viewPointLoc, viewPoint); } void +ShadowMapper::DynamicPoint::setViewProjection(const glm::mat4 & viewProjection) const +{ + glUseProgram(*this); + glUniform(viewProjectionLoc, viewProjection); +} + +void ShadowMapper::DynamicPoint::use(const Location & location) const { glUseProgram(*this); diff --git a/gfx/gl/shadowMapper.h b/gfx/gl/shadowMapper.h index d1e4e10..065db4f 100644 --- a/gfx/gl/shadowMapper.h +++ b/gfx/gl/shadowMapper.h @@ -27,7 +27,8 @@ public: class FixedPoint : public Program { public: FixedPoint(const Shader & vs); - void setViewProjection(const GlobalPosition3D, const glm::mat4 &) const; + void setViewPoint(const GlobalPosition3D) const; + void setViewProjection(const glm::mat4 &) const; void use() const; private: @@ -37,7 +38,8 @@ public: class DynamicPoint : public Program { public: DynamicPoint(); - void setViewProjection(const GlobalPosition3D, const glm::mat4 &) const; + void setViewPoint(const GlobalPosition3D) const; + void setViewProjection(const glm::mat4 &) const; void use(const Location &) const; void setModel(const Location &) const; |