diff --git a/application.cc b/application.cc index b16e9c0..a3290f5 100644 --- a/application.cc +++ b/application.cc @@ -5,7 +5,7 @@ Application::Application() { Loader loader = Loader(); //load the config.xml loader.loadConfig(this); - graphics = Graphics(glm::uvec2(windowWidth, windowHeight), 0.1f, farPlane, shadowCubeSize); + graphics = Graphics(glm::uvec2(windowWidth, windowHeight), 0.1f, farPlane, shadowCubeSize, maxShadowRenderCount); } void Application::init() @@ -122,3 +122,7 @@ void Application::setHeightmapPath(std::string heightmapPath) { void Application::setLevelXmlPath(std::string levelXmlPath) { this->levelXmlPath = levelXmlPath; } + +void Application::setMaxShadowRenderCount(int count) { + this->maxShadowRenderCount = count; +} diff --git a/application.hh b/application.hh index 0a58d84..169a664 100644 --- a/application.hh +++ b/application.hh @@ -22,6 +22,7 @@ class Application { void setWindowHeight(int windowHeight); void setShadowCubeSize(int shadowCubeSize); void setFarPlane(float farPlane); + void setMaxShadowRenderCount(int count); void setCompositionsPath(std::string compositionsPath); void setShaderPath(std::string shaderPath); void setGeometryPath(std::string geometryPath); @@ -38,6 +39,7 @@ class Application { int windowWidth; int windowHeight; int shadowCubeSize; + int maxShadowRenderCount; float farPlane; std::string compositionsPath; std::string shaderPath; diff --git a/data/config.xml b/data/config.xml index fd1c30f..fc95c9d 100644 --- a/data/config.xml +++ b/data/config.xml @@ -7,6 +7,8 @@ 150.0 +10 + ../Levels/ObjectSetups/Compositions.xml Shader/ diff --git a/graphics.cc b/graphics.cc index 958e292..3362e17 100644 --- a/graphics.cc +++ b/graphics.cc @@ -11,11 +11,14 @@ using namespace ACGL::OpenGL; const double lightUpdateDelay = 0.5f; -Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane, int cube_size) { +Graphics::Graphics(glm::uvec2 windowSize, float nearPlane, + float farPlane, int cube_size, + unsigned int maxShadowRenderCount) { this->windowSize = windowSize; this->nearPlane = nearPlane; this->farPlane = farPlane; this->cube_size = cube_size; + this->maxShadowRenderCount = maxShadowRenderCount; } Graphics::Graphics() { @@ -109,7 +112,7 @@ void Graphics::render(double time) glm::vec3(0.0f, 0.0f, -1.0f),glm::vec3(0.0f, -1.0f, 0.0f),glm::vec3(0.0f, -1.0f, 0.0f)}; framebuffer_cube->bind(); - for (unsigned int i_pointlight = 0; i_pointlightsize(); i_pointlight++) { + for (unsigned int i_pointlight = 0; i_pointlightsize() && i_pointlight < maxShadowRenderCount; i_pointlight++) { // render each side of the cube for (int i_face = 0; i_face<6; i_face++) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0); diff --git a/graphics.hh b/graphics.hh index 67a3beb..1876899 100644 --- a/graphics.hh +++ b/graphics.hh @@ -10,7 +10,7 @@ class Graphics { public: - Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane, int cube_size); + Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane, int cube_size, unsigned int maxShadowRenderCount); Graphics(); void init(Level* level); void render(double time); @@ -38,6 +38,7 @@ class Graphics { std::vector depth_cubeMaps; ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube; int cube_size; + unsigned int maxShadowRenderCount; Level* level; int number_of_texture_units = 0; }; diff --git a/loader.cc b/loader.cc index 2c49802..a65dbc8 100644 --- a/loader.cc +++ b/loader.cc @@ -5,7 +5,7 @@ Loader::Loader() { } void Loader::loadConfig(Application* application) { - int windowWidth, windowHeight, shadowCubeSize; + int windowWidth, windowHeight, shadowCubeSize, maxShadowRenderCount; float farPlane; std::string compositionsPath, shaderPath, geometryPath, texturePath, scriptPath, heightmapPath, levelXmlPath; XMLDocument* config = new XMLDocument(); @@ -20,6 +20,7 @@ void Loader::loadConfig(Application* application) { errorCheck(resolution->FirstChildElement("height")->QueryIntText(&windowHeight)); errorCheck(config->FirstChildElement("shadowCubeSize")->QueryIntText(&shadowCubeSize)); errorCheck(config->FirstChildElement("farPlane")->QueryFloatText(&farPlane)); + errorCheck(config->FirstChildElement("maxShadowRenderCount")->QueryIntText(&maxShadowRenderCount)); const char* charCompositionsPath = config->FirstChildElement("compositionsPath")->GetText(); if(charCompositionsPath == NULL){ @@ -74,6 +75,7 @@ void Loader::loadConfig(Application* application) { application->setWindowHeight(windowHeight); application->setShadowCubeSize(shadowCubeSize); application->setFarPlane(farPlane); + application->setMaxShadowRenderCount(maxShadowRenderCount); application->setCompositionsPath(compositionsPath); application->setShaderPath(shaderPath); application->setGeometryPath(geometryPath);