From 20822ee87d284b84e53058f120feb07c3eec11d6 Mon Sep 17 00:00:00 2001 From: SonerSound Date: Sat, 13 Jul 2019 23:01:17 +0100 Subject: [PATCH] Fix inconsistent lighting in GLES2 Issue was possibily being caused by duplicating a light even when that light was not in the render_light_instances array. (cherry picked from commit 545bf86d39ea3c68ed38e14a5018231295bed922) --- drivers/gles2/rasterizer_scene_gles2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 5600cc0328f..2a18db0453b 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -1110,8 +1110,8 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G LightInstance *li = light_instance_owner.getornull(e->instance->light_instances[i]); - if (li->light_index >= render_light_instance_count) { - continue; // too many + if (li->light_index >= render_light_instance_count || render_light_instances[li->light_index] != li) { + continue; // too many or light_index did not correspond to the light instances to be rendered } if (copy) {