diff --git a/Levels/ObjectSetups/Compositions.xml b/Levels/ObjectSetups/Compositions.xml
index b0fda56..0af3f5a 100644
--- a/Levels/ObjectSetups/Compositions.xml
+++ b/Levels/ObjectSetups/Compositions.xml
@@ -7,6 +7,9 @@
0.0
0.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.0
8.0
@@ -21,6 +24,9 @@
0.0
1.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
25.0
@@ -35,6 +41,9 @@
0.0
0.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.0
0.0
@@ -49,6 +58,9 @@
0.0
0.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.0
0.0
@@ -87,6 +99,9 @@
0.0
0.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -95,6 +110,9 @@
2.0
0.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -103,6 +121,9 @@
1.0
3.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -117,6 +138,9 @@
0.0
3
0.0
+ 0.0
+ 0.0
+ 0.0
1.0
1.0
@@ -125,6 +149,9 @@
0.0
2
0.0
+ 0.0
+ 0.0
+ 0.0
1.0
0.0
@@ -139,6 +166,9 @@
0.0
20.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -153,6 +183,9 @@
0.0
20.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -161,6 +194,9 @@
0.0
18.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -169,6 +205,9 @@
0.0
15.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
@@ -177,6 +216,9 @@
0.0
12.0
0.0
+ 0.0
+ 0.0
+ 0.0
1.5
0.0
diff --git a/Shader/phong.fsh b/Shader/phong.fsh
index 0f566c9..71f4121 100644
--- a/Shader/phong.fsh
+++ b/Shader/phong.fsh
@@ -47,7 +47,6 @@ vec2 poissonDisk[16] = vec2[](
);
float sampleDirectionalShadow(sampler2DShadow shadowMap, vec4 shadowCoord) {
- float nearPlane = 0.1;
float visibility = 1.0;
float bias = 0.001*tan(acos(clamp(dot(vNormal, -directionalLightVector), 0.0, 1.0)));
bias = clamp(bias, 0.0, 0.01);
@@ -121,7 +120,7 @@ void main()
vec3 finalColor = specularColor + diffuseColor + ambientColor;
float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition));
float fogFactor = clamp((1.0 - ((farPlane - 35.0) -distanceCameraCenter)/30.0), 0.0, 1.0);
- fogFactor *= clamp((1.0-((fragPosition.y-8.0)/30.0)), 0.0, 1.0);
+ fogFactor *= clamp((1.0-((fragPosition.y-40.0)/30.0)), 0.0, 1.0);
vec4 texture = texture(uTexture, vTexCoord).rgba;
oColor = vec4(finalColor, 1.0f)*texture;
diff --git a/graphics.cc b/graphics.cc
index af4f696..f264a3f 100644
--- a/graphics.cc
+++ b/graphics.cc
@@ -61,6 +61,15 @@ void Graphics::init(Level* level) {
}
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
+
+ depthTexture_cube = SharedTexture2D( new Texture2D(windowSize, GL_DEPTH_COMPONENT16));
+ depthTexture_cube->setMinFilter(GL_NEAREST);
+ depthTexture_cube->setMagFilter(GL_NEAREST);
+ depthTexture_cube->setWrapS(GL_CLAMP_TO_EDGE);
+ depthTexture_cube->setWrapT(GL_CLAMP_TO_EDGE);
+ depthTexture_cube->setCompareMode(GL_COMPARE_REF_TO_TEXTURE);
+ framebuffer_cube2 = SharedFrameBufferObject(new FrameBufferObject());
+ framebuffer_cube2->setDepthTexture(depthTexture_cube);
}
GLFWwindow* Graphics::getWindow() {
@@ -86,11 +95,20 @@ void Graphics::render()
for (unsigned int i_pointlight = 0; i_pointlight<1 && i_pointlightgetLights()->size(); i_pointlight++) {
// render each side of the cube
for (int i_face = 0; i_face<6; i_face++) {
+ framebuffer_cube2->bind();
+ glClear(GL_DEPTH_BUFFER_BIT);
+ framebuffer_cube->bind();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);
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);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_cube->getObjectName());
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_cube2->getObjectName());
+ glBlitFramebuffer(0, 0, cube_size, cube_size, cube_size, cube_size, 0, 0, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_cube2->getObjectName());
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_cube->getObjectName());
+ glBlitFramebuffer(0, 0, cube_size, cube_size, 0, 0, cube_size, cube_size, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
}
diff --git a/graphics.hh b/graphics.hh
index bb37a19..d9f92a3 100644
--- a/graphics.hh
+++ b/graphics.hh
@@ -32,6 +32,8 @@ class Graphics {
ACGL::OpenGL::SharedFrameBufferObject framebuffer;
std::vector depth_cubeMaps;
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
+ ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube2;
+ ACGL::OpenGL::SharedTexture2D depthTexture_cube;
static const int cube_size;
Level* level;
};
diff --git a/level.cc b/level.cc
index 58da1af..5ed0edb 100644
--- a/level.cc
+++ b/level.cc
@@ -221,7 +221,11 @@ void Level::load() {
* glm::rotate(compRot.z, glm::vec3(0.0f, 0.0f, 1.0f))
* glm::vec4(objectOffset, 0);
glm::vec3 objectPosition = compPos + glm::vec3(rotatedObjectOffset.x,rotatedObjectOffset.y,rotatedObjectOffset.z);
- Object* object = new Object(model, material, objectPosition, compRot);
+ glm::vec3 objectRot;
+ errorCheck(xmlObject->FirstChildElement("xRot")->QueryFloatText(&objectRot[0]));
+ errorCheck(xmlObject->FirstChildElement("yRot")->QueryFloatText(&objectRot[1]));
+ errorCheck(xmlObject->FirstChildElement("zRot")->QueryFloatText(&objectRot[2]));
+ Object* object = new Object(model, material, objectPosition, compRot+objectRot);
objects.push_back(object);
//create an identifier for this object
std::vector objectIdentifier = std::vector(4);
@@ -425,7 +429,7 @@ void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjectionMatrix, std::vector* shadowVPs) {
for(unsigned int i = 0; irender(shader, lightingPass, viewProjectionMatrix, shadowVPs);
}
}