Added maxShadowRenderCount. Controls how many shadows get rendered.
This commit is contained in:
parent
30284977da
commit
d7d45682a0
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
<farPlane>150.0</farPlane>
|
||||
|
||||
<maxShadowRenderCount>10</maxShadowRenderCount>
|
||||
|
||||
<compositionsPath>../Levels/ObjectSetups/Compositions.xml</compositionsPath>
|
||||
|
||||
<shaderPath>Shader/</shaderPath>
|
||||
|
@ -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_pointlight<closestLights->size(); i_pointlight++) {
|
||||
for (unsigned int i_pointlight = 0; i_pointlight<closestLights->size() && 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);
|
||||
|
@ -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<ACGL::OpenGL::SharedTextureCubeMap> depth_cubeMaps;
|
||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
||||
int cube_size;
|
||||
unsigned int maxShadowRenderCount;
|
||||
Level* level;
|
||||
int number_of_texture_units = 0;
|
||||
};
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user