Moving shadows of flames correctly with wind.

This commit is contained in:
Faerbit 2015-06-01 22:35:05 +02:00
parent b280ad8c12
commit ea194309ef
2 changed files with 10 additions and 3 deletions

View File

@ -272,7 +272,7 @@ void main()
for(int i = 0; i<lightCount; i++) {
vec3 lightPos = vec3(0.0, 0.0, 0.0);
if (isFlame[i] == true) {
lightPos = vec3(lightSources[i].x + movement.y , lightSources[i].y, lightSources[i].z + movement.x);
lightPos = vec3(lightSources[i].x + 0.75*movement.y , lightSources[i].y, lightSources[i].z + 0.75*movement.x);
}
else {
lightPos = lightSources[i];

View File

@ -376,12 +376,19 @@ void Graphics::render(double time)
framebuffer_cube->bind();
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<glm::mat4> viewMatrixVector = std::vector<glm::mat4>(1);
viewMatrixVector.at(0) = viewMatrix;