Changed cube map shadows sampler to a sampler array.

This commit is contained in:
Faerbit 2015-02-09 14:26:04 +01:00
parent b4e92371db
commit 705d9e3875
4 changed files with 12 additions and 6 deletions

View File

@ -6,8 +6,8 @@ add_subdirectory(converter)
PROJECT(MarbleRaceGroupC)
# ACGL setup
SET(ACGL_OPENGL_SUPPORT CORE_32)
ADD_DEFINITIONS(-DACGL_OPENGL_VERSION_32)
SET(ACGL_OPENGL_SUPPORT CORE_40)
ADD_DEFINITIONS(-DACGL_OPENGL_VERSION_40)
ADD_DEFINITIONS(-DACGL_OPENGL_PROFILE_CORE)
# create the newest availabe OpenGL context, independent of the ACGL version:
#ADD_DEFINITIONS(-DGLFW_OPENGL_LATEST_VERSION)

View File

@ -9,7 +9,7 @@ out vec4 oColor;
uniform sampler2D uTexture;
uniform sampler2DShadow shadowMap;
uniform samplerCubeShadow shadowMap_cube;
uniform samplerCubeShadow shadowMap_cube[1];
uniform vec3 ambientColor;
uniform float ambientFactor;
uniform float diffuseFactor;
@ -113,7 +113,7 @@ void main()
specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess), 0.0, 1.0)
*specularFactor*intensity*lightColors[i];
if (i == 0) {
visibility = samplePointShadow(shadowMap_cube, lightDirection);
visibility = samplePointShadow(shadowMap_cube[0], lightDirection);
}
}
/*float value = texture(shadowMap_cube, lightDirection);

View File

@ -66,6 +66,9 @@ void Graphics::init(Level* level) {
}
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &number_of_texture_units);
printf("Your graphics card supports %d texture units.\n", number_of_texture_units);
}
glm::uvec2 Graphics::getWindowSize() {
@ -98,7 +101,6 @@ void Graphics::render(double time)
std::vector<glm::mat4> viewMatrixVector = std::vector<glm::mat4>();
viewMatrixVector.push_back(viewMatrix);
level->render(depthShader, false, &depthViewProjectionMatrix_face, &viewMatrixVector);
level->render(depthShader, false, &viewMatrix);
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
}
@ -125,7 +127,10 @@ void Graphics::render(double time)
lightingShader->use();
if (level->getLights()->size() > 0) {
lightingShader->setTexture("shadowMap_cube", depth_cubeMaps.at(0), 4);
glActiveTexture(GL_TEXTURE0+2);
glBindTexture(GL_TEXTURE_CUBE_MAP, depth_cubeMaps.at(0)->getObjectName());
GLint textureUnits[1] = {2};
glUniform1iv(lightingShader->getUniformLocation("shadowMap_cube"), 1, textureUnits);
}
//set lighting parameters

View File

@ -33,6 +33,7 @@ class Graphics {
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
static const int cube_size;
Level* level;
int number_of_texture_units = 0;
};
#endif