diff --git a/Escape-the-Dawn/Renderer.cpp b/Escape-the-Dawn/Renderer.cpp index 7ad43ed..3b9ff21 100644 --- a/Escape-the-Dawn/Renderer.cpp +++ b/Escape-the-Dawn/Renderer.cpp @@ -9,7 +9,7 @@ Renderer::Renderer() m_SunPosition = glm::vec3(0, 10, 10); m_SunTarget = glm::vec3(0, 0, 0); m_SunProjection = glm::ortho(-20, 20, -20, 20, -10, 20); - Lights = 512; + Lights = 0; } void Renderer::Initialize() @@ -187,6 +187,7 @@ void Renderer::DrawScene() m_ShaderProgram.Bind(); glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthBiasMVP)); + glUniform1i(glGetUniformLocation(m_ShaderProgram.GetHandle(), "numberOfLights"), Lights); glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "position"), Lights, Light_position.data()); glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "specular"), Lights, Light_specular.data()); glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "diffuse"), Lights, Light_diffuse.data()); diff --git a/Escape-the-Dawn/Renderer.h b/Escape-the-Dawn/Renderer.h index 263a99d..ca15901 100644 --- a/Escape-the-Dawn/Renderer.h +++ b/Escape-the-Dawn/Renderer.h @@ -29,7 +29,6 @@ public: glm::mat4 projectionMatrix; int HEIGHT, WIDTH; - float Lights; struct ModelData { @@ -40,6 +39,7 @@ public: }; std::vector ModelsToRender; + int Lights; std::vector Light_position; std::vector Light_specular; std::vector Light_diffuse; diff --git a/Escape-the-Dawn/Shaders/Fragment.glsl b/Escape-the-Dawn/Shaders/Fragment.glsl index 9482278..3514159 100644 --- a/Escape-the-Dawn/Shaders/Fragment.glsl +++ b/Escape-the-Dawn/Shaders/Fragment.glsl @@ -6,15 +6,15 @@ uniform mat4 view; layout(binding=0) uniform sampler2D texture0; layout(binding=1) uniform sampler2D shadowMap; -const int numberOfLights = 128; - -uniform vec3 position[numberOfLights]; -uniform vec3 specular[numberOfLights]; -uniform vec3 diffuse[numberOfLights]; -uniform float constantAttenuation[numberOfLights]; -uniform float linearAttenuation[numberOfLights]; -uniform float quadraticAttenuation[numberOfLights]; -uniform float spotExponent[numberOfLights]; +const int maxNumberOfLights = 82; +uniform int numberOfLights; +uniform vec3 position[maxNumberOfLights]; +uniform vec3 specular[maxNumberOfLights]; +uniform vec3 diffuse[maxNumberOfLights]; +uniform float constantAttenuation[maxNumberOfLights]; +uniform float linearAttenuation[maxNumberOfLights]; +uniform float quadraticAttenuation[maxNumberOfLights]; +uniform float spotExponent[maxNumberOfLights]; in VertexData { vec3 Position;