From 592f84b548e882c3ab974561456cba3cf0084d58 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 1 Jun 2015 10:47:26 +0200 Subject: [PATCH 1/7] Implemented the the initilization of the shadow render queue.(#10) --- game/graphics.cc | 43 ++++++++++++++++++++++++++++++++++++++++--- game/graphics.hh | 8 ++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/game/graphics.cc b/game/graphics.cc index f252c60..ae4f8be 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -197,6 +197,7 @@ void Graphics::init(Level* level) { lightingShader->setUniform("fogColorRise", level->getFogColourRise()); lightingShader->setUniform("fogColorNight", level->getFogColourNight()); lightingShader->setUniform("ambientColor", level->getAmbientLight()); + if(level->getDirectionalLight()) { lightingShader->setUniform("directionalLightVector", level->getDirectionalLight()->getPosition()); @@ -333,13 +334,14 @@ void Graphics::render(double time) double nextLightUpdate = lastLightUpdate + lightUpdateDelay; if (time >= nextLightUpdate) { - updateLights(); + //updateLights(); lastLightUpdate = time; } // At first render shadows std::vector depthViewProjectionMatrices = std::vector(framebuffer_directional.size()); if (renderShadows) { + /*depthCubeShader->use(); // render depth textures for point lights glViewport(0, 0, cube_size, cube_size); glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(1.571f, (float)cube_size/(float)cube_size, 0.1f, 50.0f); @@ -365,7 +367,7 @@ void Graphics::render(double time) printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); } } - } + }*/ glViewport(0, 0, windowSize.x, windowSize.y); @@ -599,7 +601,7 @@ void Graphics::updateLights() { if (closestLights->size() > 0) { lightingShader->use(); lightingShader->setUniform("lightCount", (int) closestLights->size()); - lightingShader->setUniform("maxShadowRenderCount", std::min((int) closestLights->size(), (int)maxShadowRenderCount)); + lightingShader->setUniform("maxShadowRenderCount", min((int)closestLights->size(), maxShadowSampleCount)); // Build light position array glm::vec3 lightSources[closestLights->size()]; @@ -778,3 +780,38 @@ bool Graphics::getRenderWorld() { void Graphics::enqueueObjects(std::vector>* queue){ renderQueue.push_back(queue); } + +void Graphics::initShadowRenderQueue() { + int maxLights = min((int)closestLights->size(), maxShadowSampleCount); + shadowRenderQueue = std::vector(maxLights); + glViewport(0, 0, cube_size, cube_size); + glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(1.571f, (float)cube_size/(float)cube_size, 0.1f, 50.0f); + glm::vec3 looking_directions[6] = {glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(-1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), + glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)}; + glm::vec3 upvectors[6] = {glm::vec3(0.0f, -1.0f, 0.0f),glm::vec3(0.0f, -1.0f, 0.0f),glm::vec3(0.0f, 0.0f, -1.0f), + 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 = 0; iat(i); + shadowRenderQueue.at(i).priority = farPlane - glm::distance(level->getCameraCenter()->getPosition(), closestLights->at(i)->getPosition()); + shadowRenderQueue.at(i).currentPriority = 0; + // render depth textures for point lights + depthCubeShader->use(); + // 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)->getObjectName(), 0); + glClear(GL_DEPTH_BUFFER_BIT); + glm::mat4 viewMatrix = glm::lookAt(shadowRenderQueue.at(i).light->getPosition(), + shadowRenderQueue.at(i).light->getPosition() + looking_directions[i_face], upvectors[i_face]); + glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix; + std::vector viewMatrixVector = std::vector(); + viewMatrixVector.push_back(viewMatrix); + level->render(depthCubeShader, false, shadowRenderQueue.at(i).light->getPosition(), 1, &depthViewProjectionMatrix_face, &viewMatrixVector); + if (!framebuffer_cube->isFrameBufferObjectComplete()) { + printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); + } + } + } +} diff --git a/game/graphics.hh b/game/graphics.hh index ec1c815..0e63f7b 100644 --- a/game/graphics.hh +++ b/game/graphics.hh @@ -11,6 +11,12 @@ using namespace ACGL::OpenGL; +struct ShadowRenderQueueSlot{ + shared_ptr light; + int priority; + int currentPriority; +}; + class Graphics { public: Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane, int cube_size, @@ -89,6 +95,8 @@ class Graphics { SharedVertexArrayObject debug_vao; SharedShaderProgram debugShader; std::vector>*> renderQueue; + std::vector shadowRenderQueue; + void initShadowRenderQueue(); }; #endif From 90dbd52acafc32ee2fcb8a6c0e6496b4f4cee01b Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 1 Jun 2015 15:47:30 +0200 Subject: [PATCH 2/7] Implemented rendering of shadow render queue (#10). --- game/graphics.cc | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/game/graphics.cc b/game/graphics.cc index ae4f8be..09135cf 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -341,7 +341,28 @@ void Graphics::render(double time) // At first render shadows std::vector depthViewProjectionMatrices = std::vector(framebuffer_directional.size()); if (renderShadows) { - /*depthCubeShader->use(); + // update priorities + for(unsigned int i = 0; i, int, int>> renderQueue = + std::vector, int, int>>(maxShadowRenderCount); + for(unsigned int i = 0; i std::get<1>(renderQueue.at(j)) && ! enqueued){ + renderQueue.at(j) = std::make_tuple(shadowRenderQueue.at(i).light, shadowRenderQueue.at(i).currentPriority, i); + enqueued = true; + } + } + if (enqueued) { + shadowRenderQueue.at(i).currentPriority = 0; + } + } + + depthCubeShader->use(); // render depth textures for point lights glViewport(0, 0, cube_size, cube_size); glm::mat4 depthProjectionMatrix_pointlights = glm::perspective(1.571f, (float)cube_size/(float)cube_size, 0.1f, 50.0f); @@ -352,22 +373,23 @@ void Graphics::render(double time) framebuffer_cube->bind(); - for (unsigned int i_pointlight = 0; i_pointlightsize() && i_pointlight < maxShadowRenderCount; i_pointlight++) { + for (unsigned int i_pointlight = 0; i_pointlight < renderQueue.size(); 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); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, + depth_cubeMaps.at(std::get<2>(renderQueue.at(i_pointlight)))->getObjectName(), 0); glClear(GL_DEPTH_BUFFER_BIT); - glm::mat4 viewMatrix = glm::lookAt(closestLights->at(i_pointlight)->getPosition(), - closestLights->at(i_pointlight)->getPosition() + looking_directions[i_face], upvectors[i_face]); + glm::mat4 viewMatrix = glm::lookAt(std::get<0>(renderQueue.at(i_pointlight))->getPosition(), + std::get<0>(renderQueue.at(i_pointlight))->getPosition() + looking_directions[i_face], upvectors[i_face]); glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix; - std::vector viewMatrixVector = std::vector(); - viewMatrixVector.push_back(viewMatrix); - level->render(depthCubeShader, false, closestLights->at(i_pointlight)->getPosition(), 1, &depthViewProjectionMatrix_face, &viewMatrixVector); + std::vector viewMatrixVector = std::vector(1); + viewMatrixVector.at(0) = viewMatrix; + level->render(depthCubeShader, false, std::get<0>(renderQueue.at(i_pointlight))->getPosition(), 1, &depthViewProjectionMatrix_face, &viewMatrixVector); if (!framebuffer_cube->isFrameBufferObjectComplete()) { printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); } } - }*/ + } glViewport(0, 0, windowSize.x, windowSize.y); @@ -795,7 +817,8 @@ void Graphics::initShadowRenderQueue() { for(unsigned int i = 0; iat(i); - shadowRenderQueue.at(i).priority = farPlane - glm::distance(level->getCameraCenter()->getPosition(), closestLights->at(i)->getPosition()); + float distance = glm::distance(level->getCameraCenter()->getPosition(), closestLights->at(i)->getPosition()); + shadowRenderQueue.at(i).priority = (int) 100*std::exp(5.0f - 0.1f * distance); shadowRenderQueue.at(i).currentPriority = 0; // render depth textures for point lights depthCubeShader->use(); From b280ad8c1228f6eecafa1c3e92f5e4deaf2d496a Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 1 Jun 2015 16:17:37 +0200 Subject: [PATCH 3/7] Small performance optimization. --- game/graphics.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/game/graphics.cc b/game/graphics.cc index 09135cf..12fedfd 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -352,9 +352,10 @@ void Graphics::render(double time) for(unsigned int i = 0; i std::get<1>(renderQueue.at(j)) && ! enqueued){ + if (shadowRenderQueue.at(i).currentPriority > std::get<1>(renderQueue.at(j))){ renderQueue.at(j) = std::make_tuple(shadowRenderQueue.at(i).light, shadowRenderQueue.at(i).currentPriority, i); enqueued = true; + break; } } if (enqueued) { From ea194309ef372e757542db0bee3be33d06662830 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 1 Jun 2015 22:35:05 +0200 Subject: [PATCH 4/7] Moving shadows of flames correctly with wind. --- data/shader/phong.fsh | 2 +- game/graphics.cc | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/data/shader/phong.fsh b/data/shader/phong.fsh index 88c5207..ee2a029 100644 --- a/data/shader/phong.fsh +++ b/data/shader/phong.fsh @@ -272,7 +272,7 @@ void main() for(int i = 0; ibind(); for (unsigned int i_pointlight = 0; i_pointlight < renderQueue.size(); i_pointlight++) { // render each side of the cube + glm::vec3 position = glm::vec3(0.0f); + if (std::get<0>(renderQueue.at(i_pointlight))->isFlame()) { + position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); + position = glm::vec3(position.x + 0.75f*wind.x, position.y, position.z + 0.75f*wind.y); + } + else { + position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); + } 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(std::get<2>(renderQueue.at(i_pointlight)))->getObjectName(), 0); glClear(GL_DEPTH_BUFFER_BIT); - glm::mat4 viewMatrix = glm::lookAt(std::get<0>(renderQueue.at(i_pointlight))->getPosition(), - std::get<0>(renderQueue.at(i_pointlight))->getPosition() + looking_directions[i_face], upvectors[i_face]); + glm::mat4 viewMatrix = glm::lookAt(position, position + looking_directions[i_face], upvectors[i_face]); glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix; std::vector viewMatrixVector = std::vector(1); viewMatrixVector.at(0) = viewMatrix; From 819584ef1553a64acd43c233a099edd4d48f2e78 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Tue, 2 Jun 2015 00:18:22 +0200 Subject: [PATCH 5/7] Implemented updating of shadow render queue. Doesn't work satisfactory right now. (#10) --- CMakeLists.txt | 4 +- game/graphics.cc | 116 ++++++++++++++++++++++++++++++++--------------- game/level.cc | 2 + 3 files changed, 83 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d72a5b9..ead39d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,8 @@ ADD_DEFINITIONS(-DNO_SPACE_NAVIGATOR_SUPPORT) SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -DSAXUM_DEBUG -g") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -DSAXUM_DEBUG -g") -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2") +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -DNDEBUG") set(dir ${CMAKE_CURRENT_SOURCE_DIR}/binaries) set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) diff --git a/game/graphics.cc b/game/graphics.cc index 54e124d..71cb56f 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -180,8 +180,6 @@ void Graphics::init(Level* level) { bindTextureUnits(); - updateLights(); - // set shader variables that stay the same across the runtime of the application skydomeShader->use(); skydomeShader->setUniform("farPlane", farPlane); @@ -211,12 +209,14 @@ void Graphics::init(Level* level) { depthCubeShader->setUniform("farPlane", farPlane); level->sortObjects(Material::getAllTextures()->size()); + #ifdef SAXUM_DEBUG std::cout << "There were " << Material::getAllTextures()->size() << " materials used in this level." << std::endl; #endif initShadowRenderQueue(); + updateLights(); } void Graphics::bindTextureUnits(){ @@ -334,7 +334,7 @@ void Graphics::render(double time) double nextLightUpdate = lastLightUpdate + lightUpdateDelay; if (time >= nextLightUpdate) { - //updateLights(); + updateLights(); lastLightUpdate = time; } @@ -375,26 +375,29 @@ void Graphics::render(double time) framebuffer_cube->bind(); for (unsigned int i_pointlight = 0; i_pointlight < renderQueue.size(); i_pointlight++) { - // render each side of the cube - glm::vec3 position = glm::vec3(0.0f); - if (std::get<0>(renderQueue.at(i_pointlight))->isFlame()) { - position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); - position = glm::vec3(position.x + 0.75f*wind.x, position.y, position.z + 0.75f*wind.y); - } - else { - position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); - } - 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(std::get<2>(renderQueue.at(i_pointlight)))->getObjectName(), 0); - glClear(GL_DEPTH_BUFFER_BIT); - glm::mat4 viewMatrix = glm::lookAt(position, position + looking_directions[i_face], upvectors[i_face]); - glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix; - std::vector viewMatrixVector = std::vector(1); - viewMatrixVector.at(0) = viewMatrix; - level->render(depthCubeShader, false, std::get<0>(renderQueue.at(i_pointlight))->getPosition(), 1, &depthViewProjectionMatrix_face, &viewMatrixVector); - if (!framebuffer_cube->isFrameBufferObjectComplete()) { - printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); + // check if queue points to a existing light + if (std::get<0>(renderQueue.at(i_pointlight))) { + // render each side of the cube + glm::vec3 position = glm::vec3(0.0f); + if (std::get<0>(renderQueue.at(i_pointlight))->isFlame()) { + position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); + position = glm::vec3(position.x + 0.75f*wind.x, position.y, position.z + 0.75f*wind.y); + } + else { + position = std::get<0>(renderQueue.at(i_pointlight))->getPosition(); + } + 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(std::get<2>(renderQueue.at(i_pointlight)))->getObjectName(), 0); + glClear(GL_DEPTH_BUFFER_BIT); + glm::mat4 viewMatrix = glm::lookAt(position, position + looking_directions[i_face], upvectors[i_face]); + glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * viewMatrix; + std::vector viewMatrixVector = std::vector(1); + viewMatrixVector.at(0) = viewMatrix; + level->render(depthCubeShader, false, std::get<0>(renderQueue.at(i_pointlight))->getPosition(), 1, &depthViewProjectionMatrix_face, &viewMatrixVector); + if (!framebuffer_cube->isFrameBufferObjectComplete()) { + printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); + } } } } @@ -627,12 +630,52 @@ void Graphics::render(double time) } void Graphics::updateLights() { + std::vector> oldClosestLights = std::vector>(*closestLights); closestLights = level->getClosestLights(); if (closestLights->size() > 0) { lightingShader->use(); lightingShader->setUniform("lightCount", (int) closestLights->size()); lightingShader->setUniform("maxShadowRenderCount", min((int)closestLights->size(), maxShadowSampleCount)); + // find new closest lights for the shadow render queue + unsigned int i = 0; + std::vector> compareClosestLights = std::vector>(*closestLights); + while(igetCameraCenter()->getPosition(), shadowRenderQueue.at(i).light->getPosition()); + shadowRenderQueue.at(i).priority = (int) 100*std::exp(5.0f - 0.1f * distance); + } + // Build light position array glm::vec3 lightSources[closestLights->size()]; for(unsigned int i = 0; isize(); i++) { @@ -654,20 +697,20 @@ void Graphics::updateLights() { } glUniform1fv(lightingShader->getUniformLocation("lightIntensities"), sizeof(lightIntensities), (GLfloat*) lightIntensities); - } - // set directional Light - bool isFlame[closestLights->size()]; - closestFlames = std::vector(); - for (unsigned int i = 0; isize(); i++) { - if (closestLights->at(i)->isFlame()) { - closestFlames.push_back(closestLights->at(i)->getFlame()); - isFlame[i] = true; - } - else { - isFlame[i] = false; + + bool isFlame[closestLights->size()]; + closestFlames = std::vector(); + for (unsigned int i = 0; isize(); i++) { + if (closestLights->at(i)->isFlame()) { + closestFlames.push_back(closestLights->at(i)->getFlame()); + isFlame[i] = true; + } + else { + isFlame[i] = false; + } } + glUniform1iv(lightingShader->getUniformLocation("isFlame"), sizeof(isFlame), (GLint*) isFlame); } - glUniform1iv(lightingShader->getUniformLocation("isFlame"), sizeof(isFlame), (GLint*) isFlame); } void Graphics::saveWindowSize(glm::uvec2 windowSize) { @@ -812,6 +855,7 @@ void Graphics::enqueueObjects(std::vector>* queue){ } void Graphics::initShadowRenderQueue() { + closestLights = level->getClosestLights(); int maxLights = min((int)closestLights->size(), maxShadowSampleCount); shadowRenderQueue = std::vector(maxLights); glViewport(0, 0, cube_size, cube_size); @@ -825,8 +869,6 @@ void Graphics::initShadowRenderQueue() { for(unsigned int i = 0; iat(i); - float distance = glm::distance(level->getCameraCenter()->getPosition(), closestLights->at(i)->getPosition()); - shadowRenderQueue.at(i).priority = (int) 100*std::exp(5.0f - 0.1f * distance); shadowRenderQueue.at(i).currentPriority = 0; // render depth textures for point lights depthCubeShader->use(); diff --git a/game/level.cc b/game/level.cc index 6d51bc1..3497ce7 100644 --- a/game/level.cc +++ b/game/level.cc @@ -462,5 +462,7 @@ std::vector>* Level::getClosestLights() { closestLights = std::vector>(&closestLights[0], &closestLights[15]); } + // sort pointers for faster comparisons + std::sort(closestLights.begin(), closestLights.end()); return &closestLights; } From e8c1dee3b53ff3063b22db5aa0c45650cd7fd439 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Tue, 2 Jun 2015 00:33:55 +0200 Subject: [PATCH 6/7] Improved scheduling of point lights for the render queue by fixing a bug. --- game/graphics.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/game/graphics.cc b/game/graphics.cc index 71cb56f..09f11a2 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -353,6 +353,9 @@ void Graphics::render(double time) bool enqueued = false; for(unsigned int j = 0; j std::get<1>(renderQueue.at(j))){ + if (j Date: Tue, 2 Jun 2015 17:36:55 +0200 Subject: [PATCH 7/7] Fixing the rendering of the shadows. Closes #10. --- game/graphics.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/game/graphics.cc b/game/graphics.cc index 09f11a2..96cdef4 100644 --- a/game/graphics.cc +++ b/game/graphics.cc @@ -680,32 +680,32 @@ void Graphics::updateLights() { } // Build light position array - glm::vec3 lightSources[closestLights->size()]; - for(unsigned int i = 0; isize(); i++) { - lightSources[i] = closestLights->at(i)->getPosition(); + glm::vec3 lightSources[shadowRenderQueue.size()]; + for(unsigned int i = 0; igetPosition(); } glUniform3fv(lightingShader->getUniformLocation("lightSources"), sizeof(lightSources), (GLfloat*) lightSources); // Build light colour array - glm::vec3 lightColours[closestLights->size()]; - for(unsigned int i = 0; isize(); i++) { - lightColours[i] = closestLights->at(i)->getColour(); + glm::vec3 lightColours[shadowRenderQueue.size()]; + for(unsigned int i = 0; igetColour(); } glUniform3fv(lightingShader->getUniformLocation("lightColors"), sizeof(lightColours), (GLfloat*) lightColours); // Build light attenuation array - float lightIntensities[closestLights->size()]; - for(unsigned int i = 0; isize(); i++) { - lightIntensities[i] = closestLights->at(i)->getIntensity(); + float lightIntensities[shadowRenderQueue.size()]; + for(unsigned int i = 0; igetIntensity(); } glUniform1fv(lightingShader->getUniformLocation("lightIntensities"), sizeof(lightIntensities), (GLfloat*) lightIntensities); - bool isFlame[closestLights->size()]; + bool isFlame[shadowRenderQueue.size()]; closestFlames = std::vector(); - for (unsigned int i = 0; isize(); i++) { - if (closestLights->at(i)->isFlame()) { - closestFlames.push_back(closestLights->at(i)->getFlame()); + for(unsigned int i = 0; iisFlame()) { + closestFlames.push_back(shadowRenderQueue.at(i).light->getFlame()); isFlame[i] = true; } else {