Tried correcting an error. Unsure if it will work.

This commit is contained in:
Faerbit 2015-01-31 20:02:23 +01:00
parent 823528b75a
commit 05dca4516b
4 changed files with 14 additions and 3 deletions

View File

@ -1,7 +1,9 @@
#version 150
in vec4 fragPosition;
out float fragmentDepth;
void main() {
fragmentDepth = gl_FragCoord.z;
fragmentDepth = fragPosition.z;
}

View File

@ -5,7 +5,11 @@ in vec3 aNormal;
in vec3 aTexcoord;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelViewMatrix;
out vec4 fragPosition;
void main() {
fragPosition = modelViewMatrix * vec4(aPosition, 1.0);
gl_Position = modelViewProjectionMatrix * vec4(aPosition, 1.0);
}

View File

@ -120,7 +120,9 @@ void Graphics::render(double time)
viewMatrix[3][0], viewMatrix[3][1], viewMatrix[3][2], viewMatrix[3][3]
);
}
level->render(depthShader, false, &depthViewProjectionMatrix_face);
std::vector<glm::mat4> vector = std::vector<glm::mat4>();
vector.push_back(viewMatrix);
level->render(depthShader, false, &depthViewProjectionMatrix_face, &vector);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_cube->getObjectName());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_cube_mirror->getObjectName());
glBlitFramebuffer(0, 0, cube_size, cube_size, cube_size, cube_size, 0, 0, GL_DEPTH_BUFFER_BIT, GL_NEAREST);

View File

@ -23,7 +23,7 @@ void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
shader->setUniform("shininess", material.getShininess());
shader->setTexture("uTexture", material.getReference(), 0);
// set model matrix
shader->setUniform( "modelMatrix", modelMatrix);
shader->setUniform("modelMatrix", modelMatrix);
// set shadowMVPs
glm::mat4 shadowMVPs[5];
for(unsigned int i = 0; (i<shadowVPs->size() && i<5); i++) {
@ -32,6 +32,9 @@ void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glUniformMatrix4fv(shader->getUniformLocation("shadowMVPs"),
sizeof(shadowMVPs), false, (GLfloat*) shadowMVPs);
}
else {
//shader->setUniform("modelViewMatrix", shadowVPs->at(0) * modelMatrix);
}
glm::mat4 mvp = (*viewProjectionMatrix) * modelMatrix;
shader->setUniform("modelViewProjectionMatrix", mvp);
// draw