From 916fafa028b0bc8c8b0abec8c072722907d85f43 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 25 Nov 2023 14:08:45 +0000 Subject: Send position and rotation matrix to GPU separately in shadowmapper dynamic --- gfx/gl/shadowMapper.cpp | 9 ++++----- gfx/gl/shadowMapper.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'gfx') diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 190f20e..4a8d7ec 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -179,7 +179,8 @@ ShadowMapper::FixedPoint::use() const } ShadowMapper::DynamicPoint::DynamicPoint() : - Program {shadowDynamicPoint_vs}, viewProjectionLoc {*this, "viewProjection"}, modelLoc {*this, "model"} + Program {shadowDynamicPoint_vs}, viewProjectionLoc {*this, "viewProjection"}, modelLoc {*this, "model"}, + modelPosLoc {*this, "modelPos"} { } @@ -195,13 +196,11 @@ ShadowMapper::DynamicPoint::use(const Location & location) const { glUseProgram(*this); setModel(location); - const auto model = glm::translate(location.pos) * rotate_ypr(location.rot); - glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); } void ShadowMapper::DynamicPoint::setModel(const Location & location) const { - const auto model = glm::translate(location.pos) * rotate_ypr(location.rot); - glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); + glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(rotate_ypr(location.rot))); + glUniform3fv(modelPosLoc, 1, glm::value_ptr(location.pos)); } diff --git a/gfx/gl/shadowMapper.h b/gfx/gl/shadowMapper.h index d54734c..b53a7f1 100644 --- a/gfx/gl/shadowMapper.h +++ b/gfx/gl/shadowMapper.h @@ -44,6 +44,7 @@ public: private: RequiredUniformLocation viewProjectionLoc; RequiredUniformLocation modelLoc; + RequiredUniformLocation modelPosLoc; }; FixedPoint fixedPoint, dynamicPointInst; -- cgit v1.2.3