From ea194309ef372e757542db0bee3be33d06662830 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 1 Jun 2015 22:35:05 +0200 Subject: [PATCH] Moving shadows of flames correctly with wind. --- data/shader/phong.fsh | 2 +- game/graphics.cc | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/data/shader/phong.fsh b/data/shader/phong.fsh index 88c5207..ee2a029 100644 --- a/data/shader/phong.fsh +++ b/data/shader/phong.fsh @@ -272,7 +272,7 @@ void main() for(int i = 0; ibind(); for (unsigned int i_pointlight = 0; i_pointlight < renderQueue.size(); i_pointlight++) { // render each side of the cube + glm::vec3 position = glm::vec3(0.0f); + if (std::get<0>(renderQueue.at(i_pointlight))->isFlame()) { + position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); + position = glm::vec3(position.x + 0.75f*wind.x, position.y, position.z + 0.75f*wind.y); + } + else { + position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); + } for (int i_face = 0; i_face<6; i_face++) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(std::get<2>(renderQueue.at(i_pointlight)))->getObjectName(), 0); glClear(GL_DEPTH_BUFFER_BIT); - glm::mat4 viewMatrix = glm::lookAt(std::get<0>(renderQueue.at(i_pointlight))->getPosition(), - std::get<0>(renderQueue.at(i_pointlight))->getPosition() + looking_directions[i_face], upvectors[i_face]); + glm::mat4 viewMatrix = glm::lookAt(position, position + looking_directions[i_face], upvectors[i_face]); glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix; std::vector viewMatrixVector = std::vector(1); viewMatrixVector.at(0) = viewMatrix;