Only rendering sun shadows when the sun is actually shining.
This commit is contained in:
parent
93f87cc9c5
commit
185371d78c
@ -253,11 +253,13 @@ void Graphics::render(double time)
|
||||
glViewport(0, 0, windowSize.x, windowSize.y);
|
||||
|
||||
std::vector<glm::mat4> depthViewProjectionMatrices = std::vector<glm::mat4>(framebuffer_directional.size());
|
||||
float sunAngle = glm::dot(glm::vec3(0.0f, 1.0f, 0.0f), glm::normalize(level->getDirectionalLight()->getPosition()));
|
||||
glm::vec3 sunVector = (level->getCameraCenter()->getPosition() + level->getDirectionalLight()->getPosition());
|
||||
|
||||
for (unsigned int i = 0; i<framebuffer_directional.size(); i++) {
|
||||
framebuffer_directional.at(i)->bind();
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
if (sunAngle > 0.0f) {
|
||||
float projection_size = 0.0f;
|
||||
switch(i) {
|
||||
case 0:
|
||||
@ -273,6 +275,7 @@ void Graphics::render(double time)
|
||||
depthViewProjectionMatrices.at(i) = glm::ortho<float>(-projection_size, projection_size, -projection_size, projection_size, -farPlane/1.5f, farPlane/1.5f) *
|
||||
glm::lookAt(sunVector, level->getCameraCenter()->getPosition(), glm::vec3(0,1,0));
|
||||
level->render(depthShader, false, &depthViewProjectionMatrices.at(i));
|
||||
}
|
||||
if (!framebuffer_directional.at(i)->isFrameBufferObjectComplete()) {
|
||||
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user