Revert "Not using pointlight shadows."

This reverts commit e00cb787c8.
This commit is contained in:
Faerbit 2014-12-15 22:00:23 +01:00
parent ebb7045753
commit 5ad46dd5e9
2 changed files with 10 additions and 10 deletions

View File

@ -13,7 +13,7 @@ uniform sampler2D uTexture;
uniform sampler2DShadow shadowMap_near;
uniform sampler2DShadow shadowMap_middle;
uniform sampler2DShadow shadowMap_far;
//uniform samplerCubeShadow shadowMap_cube;
uniform samplerCubeShadow shadowMap_cube;
uniform vec3 ambientColor;
uniform float ambientFactor;
uniform float diffuseFactor;
@ -111,7 +111,7 @@ void main()
vec3 cameraVector = normalize(camera - vec3(fragPosition));
specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess), 0.0, 1.0)
*specularFactor*intensity*lightColors[i];
//visibility = samplePointShadow(shadowMap_cube, lightDirection);
visibility = samplePointShadow(shadowMap_cube, lightDirection);
}
}

View File

@ -72,7 +72,7 @@ void Graphics::init(Level* level) {
/*depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(level->getLights()->size());
for (unsigned int i = 0; i<depth_cubeMaps.size(); i++) {*/
/*depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(1);
depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(1);
for (unsigned int i = 0; i<1; i++) {
depth_cubeMaps.at(i) = SharedTextureCubeMap(new TextureCubeMap(glm::vec2(cube_size, cube_size), GL_DEPTH_COMPONENT16));
depth_cubeMaps.at(i)->setMinFilter(GL_NEAREST);
@ -80,7 +80,7 @@ void Graphics::init(Level* level) {
depth_cubeMaps.at(i)->setWrapS(GL_CLAMP_TO_EDGE);
depth_cubeMaps.at(i)->setWrapT(GL_CLAMP_TO_EDGE);
depth_cubeMaps.at(i)->setCompareMode(GL_COMPARE_REF_TO_TEXTURE);
}*/
}
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
}
@ -98,12 +98,12 @@ void Graphics::render()
// At first render shadows
depthShader->use();
// render depth textures for point lights
/*glViewport(0, 0, cube_size, cube_size);
glViewport(0, 0, cube_size, cube_size);
glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(1.571f, (float)cube_size/(float)cube_size, 0.1f, farPlane);
glm::vec3 looking_directions[6] = {glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(-1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f),
glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)};*/
glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)};
/*framebuffer_cube->bind();
framebuffer_cube->bind();
//for (unsigned int i_pointlight = 0; i_pointlight<level->getLights()->size(); i_pointlight++) {
for (unsigned int i_pointlight = 0; i_pointlight<1; i_pointlight++) {
// render each side of the cube
@ -112,12 +112,12 @@ void Graphics::render()
glClear(GL_DEPTH_BUFFER_BIT);
glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * glm::lookAt(level->getLights()->at(i_pointlight).getPosition(),
level->getLights()->at(i_pointlight).getPosition() + looking_directions[i_face], glm::vec3(0.0f, 1.0f, 0.0f));
//level->render(depthShader, false, &depthViewProjectionMatrix_face);
level->render(depthShader, false, &depthViewProjectionMatrix_face);
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
}
}
}*/
}
// render depth texture for sun
glViewport(0, 0, windowSize.x, windowSize.y);
// near pass
@ -185,7 +185,7 @@ void Graphics::render()
glUniform1fv(lightingShader->getUniformLocation("lightIntensities"),
sizeof(lightIntensities), (GLfloat*) lightIntensities);
//lightingShader->setTexture("shadowMap_cube", depth_cubeMaps.at(0), 4);
lightingShader->setTexture("shadowMap_cube", depth_cubeMaps.at(0), 4);
}
// set directional Light
if(level->getDirectionalLight()) {