From 2583aa4a68b3c998f9e26af7ce92e696ebf6473d Mon Sep 17 00:00:00 2001 From: brennen Date: Tue, 18 Mar 2025 02:37:43 -0500 Subject: [PATCH] Add error check for reflection probe invalid atlas index. --- drivers/gles3/rasterizer_scene_gles3.cpp | 2 +- drivers/gles3/storage/light_storage.cpp | 3 +++ servers/rendering/renderer_rd/storage_rd/light_storage.cpp | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index d04142dea18..c582e15b534 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -2494,7 +2494,7 @@ void RasterizerSceneGLES3::render_scene(const Ref &p_render_ } GLuint fbo = 0; - if (is_reflection_probe) { + if (is_reflection_probe && GLES3::LightStorage::get_singleton()->reflection_probe_has_atlas_index(render_data.reflection_probe)) { fbo = GLES3::LightStorage::get_singleton()->reflection_probe_instance_get_framebuffer(render_data.reflection_probe, render_data.reflection_probe_pass); } else { rb->set_apply_color_adjustments_in_post(apply_color_adjustments_in_post); diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp index 4815722d016..f58f769b3e4 100644 --- a/drivers/gles3/storage/light_storage.cpp +++ b/drivers/gles3/storage/light_storage.cpp @@ -1032,6 +1032,7 @@ GLuint LightStorage::reflection_probe_instance_get_texture(RID p_instance) { ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas); ERR_FAIL_NULL_V(atlas, 0); + ERR_FAIL_COND_V(rpi->atlas_index < 0, 0); return atlas->reflections[rpi->atlas_index].radiance; } @@ -1043,6 +1044,8 @@ GLuint LightStorage::reflection_probe_instance_get_framebuffer(RID p_instance, i ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas); ERR_FAIL_NULL_V(atlas, 0); + ERR_FAIL_COND_V(rpi->atlas_index < 0, 0); + return atlas->reflections[rpi->atlas_index].fbos[p_index]; } diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp index bc5ad566cf1..8f319d430aa 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp @@ -1663,6 +1663,8 @@ RID LightStorage::reflection_probe_instance_get_framebuffer(RID p_instance, int ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas); ERR_FAIL_NULL_V(atlas, RID()); + ERR_FAIL_COND_V_MSG(rpi->atlas_index < 0, RID(), "Reflection probe atlas index invalid. Maximum amount of reflection probes in use (" + itos(atlas->count) + ") may have been exceeded, reflections will not display properly. Consider increasing Rendering > Reflections > Reflection Atlas > Reflection Count in the Project Settings."); + return atlas->reflections[rpi->atlas_index].fbs[p_index]; } @@ -1886,7 +1888,7 @@ void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_use } } } - ERR_FAIL_COND_MSG(lm->array_index < 0, "Maximum amount of lightmaps in use (" + itos(lightmap_textures.size()) + ") has been exceeded, lightmap will nod display properly."); + ERR_FAIL_COND_MSG(lm->array_index < 0, "Maximum amount of lightmaps in use (" + itos(lightmap_textures.size()) + ") has been exceeded, lightmap will not display properly."); lightmap_textures.write[lm->array_index] = t->rd_texture; }