Changed cube map shadows sampler to a sampler array.
This commit is contained in:
parent
b4e92371db
commit
705d9e3875
@ -6,8 +6,8 @@ add_subdirectory(converter)
|
|||||||
PROJECT(MarbleRaceGroupC)
|
PROJECT(MarbleRaceGroupC)
|
||||||
|
|
||||||
# ACGL setup
|
# ACGL setup
|
||||||
SET(ACGL_OPENGL_SUPPORT CORE_32)
|
SET(ACGL_OPENGL_SUPPORT CORE_40)
|
||||||
ADD_DEFINITIONS(-DACGL_OPENGL_VERSION_32)
|
ADD_DEFINITIONS(-DACGL_OPENGL_VERSION_40)
|
||||||
ADD_DEFINITIONS(-DACGL_OPENGL_PROFILE_CORE)
|
ADD_DEFINITIONS(-DACGL_OPENGL_PROFILE_CORE)
|
||||||
# create the newest availabe OpenGL context, independent of the ACGL version:
|
# create the newest availabe OpenGL context, independent of the ACGL version:
|
||||||
#ADD_DEFINITIONS(-DGLFW_OPENGL_LATEST_VERSION)
|
#ADD_DEFINITIONS(-DGLFW_OPENGL_LATEST_VERSION)
|
||||||
|
@ -9,7 +9,7 @@ out vec4 oColor;
|
|||||||
|
|
||||||
uniform sampler2D uTexture;
|
uniform sampler2D uTexture;
|
||||||
uniform sampler2DShadow shadowMap;
|
uniform sampler2DShadow shadowMap;
|
||||||
uniform samplerCubeShadow shadowMap_cube;
|
uniform samplerCubeShadow shadowMap_cube[1];
|
||||||
uniform vec3 ambientColor;
|
uniform vec3 ambientColor;
|
||||||
uniform float ambientFactor;
|
uniform float ambientFactor;
|
||||||
uniform float diffuseFactor;
|
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)
|
specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess), 0.0, 1.0)
|
||||||
*specularFactor*intensity*lightColors[i];
|
*specularFactor*intensity*lightColors[i];
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
visibility = samplePointShadow(shadowMap_cube, lightDirection);
|
visibility = samplePointShadow(shadowMap_cube[0], lightDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*float value = texture(shadowMap_cube, lightDirection);
|
/*float value = texture(shadowMap_cube, lightDirection);
|
||||||
|
@ -66,6 +66,9 @@ void Graphics::init(Level* level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
|
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() {
|
glm::uvec2 Graphics::getWindowSize() {
|
||||||
@ -98,7 +101,6 @@ void Graphics::render(double time)
|
|||||||
std::vector<glm::mat4> viewMatrixVector = std::vector<glm::mat4>();
|
std::vector<glm::mat4> viewMatrixVector = std::vector<glm::mat4>();
|
||||||
viewMatrixVector.push_back(viewMatrix);
|
viewMatrixVector.push_back(viewMatrix);
|
||||||
level->render(depthShader, false, &depthViewProjectionMatrix_face, &viewMatrixVector);
|
level->render(depthShader, false, &depthViewProjectionMatrix_face, &viewMatrixVector);
|
||||||
level->render(depthShader, false, &viewMatrix);
|
|
||||||
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
|
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
|
||||||
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
|
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
|
||||||
}
|
}
|
||||||
@ -125,7 +127,10 @@ void Graphics::render(double time)
|
|||||||
lightingShader->use();
|
lightingShader->use();
|
||||||
|
|
||||||
if (level->getLights()->size() > 0) {
|
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
|
//set lighting parameters
|
||||||
|
@ -33,6 +33,7 @@ class Graphics {
|
|||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
||||||
static const int cube_size;
|
static const int cube_size;
|
||||||
Level* level;
|
Level* level;
|
||||||
|
int number_of_texture_units = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user