Moving shadows of flames correctly with wind.
This commit is contained in:
parent
b280ad8c12
commit
ea194309ef
@ -272,7 +272,7 @@ void main()
|
|||||||
for(int i = 0; i<lightCount; i++) {
|
for(int i = 0; i<lightCount; i++) {
|
||||||
vec3 lightPos = vec3(0.0, 0.0, 0.0);
|
vec3 lightPos = vec3(0.0, 0.0, 0.0);
|
||||||
if (isFlame[i] == true) {
|
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 {
|
else {
|
||||||
lightPos = lightSources[i];
|
lightPos = lightSources[i];
|
||||||
|
@ -376,12 +376,19 @@ void Graphics::render(double time)
|
|||||||
framebuffer_cube->bind();
|
framebuffer_cube->bind();
|
||||||
for (unsigned int i_pointlight = 0; i_pointlight < renderQueue.size(); i_pointlight++) {
|
for (unsigned int i_pointlight = 0; i_pointlight < renderQueue.size(); i_pointlight++) {
|
||||||
// render each side of the cube
|
// 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++) {
|
for (int i_face = 0; i_face<6; i_face++) {
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + 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);
|
depth_cubeMaps.at(std::get<2>(renderQueue.at(i_pointlight)))->getObjectName(), 0);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
glm::mat4 viewMatrix = glm::lookAt(std::get<0>(renderQueue.at(i_pointlight))->getPosition(),
|
glm::mat4 viewMatrix = glm::lookAt(position, position + looking_directions[i_face], upvectors[i_face]);
|
||||||
std::get<0>(renderQueue.at(i_pointlight))->getPosition() + looking_directions[i_face], upvectors[i_face]);
|
|
||||||
glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix;
|
glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix;
|
||||||
std::vector<glm::mat4> viewMatrixVector = std::vector<glm::mat4>(1);
|
std::vector<glm::mat4> viewMatrixVector = std::vector<glm::mat4>(1);
|
||||||
viewMatrixVector.at(0) = viewMatrix;
|
viewMatrixVector.at(0) = viewMatrix;
|
||||||
|
Loading…
Reference in New Issue
Block a user