Define common limits for light sources count
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <glad/gl.h>
|
||||
@@ -64,9 +65,11 @@ void Renderer::draw_scene(const Scene& scene, const Camera& camera,
|
||||
shader->set_vec3("u_directional_light.diffuse", env.directional_light.diffuse);
|
||||
shader->set_vec3("u_directional_light.specular", env.directional_light.specular);
|
||||
|
||||
// Note: current limit is set to MAX_POINT_LIGHT_COUNT (8)
|
||||
// TODO: Define this limits in a common header file
|
||||
int point_count = std::min(static_cast<int>(env.point_lights.size()), 8);
|
||||
if (env.point_lights.size() > MAX_POINT_LIGHTS) {
|
||||
std::cerr << "WARNING: RENDERER: Maximum number of point lights exceeded"
|
||||
<< " (" << MAX_POINT_LIGHTS << ")" << std::endl;
|
||||
}
|
||||
int point_count = std::min(static_cast<int>(env.point_lights.size()), MAX_POINT_LIGHTS);
|
||||
shader->set_int("u_point_light_count", point_count);
|
||||
for (int i = 0; i < point_count; ++i) {
|
||||
std::string prefix = "u_point_lights[" + std::to_string(i) + "].";
|
||||
@@ -81,9 +84,11 @@ void Renderer::draw_scene(const Scene& scene, const Camera& camera,
|
||||
shader->set_vec3(prefix + "specular", env.point_lights[i].specular);
|
||||
}
|
||||
|
||||
// Note: current limit is set to MAX_SPOT_LIGHT_COUNT (8)
|
||||
// TODO: Define this limits in a common header file
|
||||
int spot_count = std::min(static_cast<int>(env.spot_lights.size()), 8);
|
||||
if (env.spot_lights.size() > MAX_SPOT_LIGHTS) {
|
||||
std::cerr << "WARNING: RENDERER: Maximum number of spot lights exceeded"
|
||||
<< " (" << MAX_POINT_LIGHTS << ")" << std::endl;
|
||||
}
|
||||
int spot_count = std::min(static_cast<int>(env.spot_lights.size()), MAX_SPOT_LIGHTS);
|
||||
shader->set_int("u_spot_light_count", spot_count);
|
||||
for (int i = 0; i < spot_count; ++i) {
|
||||
std::string prefix = "u_spot_lights[" + std::to_string(i) + "].";
|
||||
|
||||
Reference in New Issue
Block a user