Skip to content

Commit 35a2d78

Browse files
committed
Merge pull request godotengine#104302 from brennennen/reflection_probe_count_error_check
Add error check for reflection probe invalid atlas index.
2 parents 7e0b813 + 2583aa4 commit 35a2d78

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

drivers/gles3/rasterizer_scene_gles3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
24942494
}
24952495

24962496
GLuint fbo = 0;
2497-
if (is_reflection_probe) {
2497+
if (is_reflection_probe && GLES3::LightStorage::get_singleton()->reflection_probe_has_atlas_index(render_data.reflection_probe)) {
24982498
fbo = GLES3::LightStorage::get_singleton()->reflection_probe_instance_get_framebuffer(render_data.reflection_probe, render_data.reflection_probe_pass);
24992499
} else {
25002500
rb->set_apply_color_adjustments_in_post(apply_color_adjustments_in_post);

drivers/gles3/storage/light_storage.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ GLuint LightStorage::reflection_probe_instance_get_texture(RID p_instance) {
10321032

10331033
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
10341034
ERR_FAIL_NULL_V(atlas, 0);
1035+
ERR_FAIL_COND_V(rpi->atlas_index < 0, 0);
10351036

10361037
return atlas->reflections[rpi->atlas_index].radiance;
10371038
}
@@ -1043,6 +1044,8 @@ GLuint LightStorage::reflection_probe_instance_get_framebuffer(RID p_instance, i
10431044

10441045
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
10451046
ERR_FAIL_NULL_V(atlas, 0);
1047+
ERR_FAIL_COND_V(rpi->atlas_index < 0, 0);
1048+
10461049
return atlas->reflections[rpi->atlas_index].fbos[p_index];
10471050
}
10481051

servers/rendering/renderer_rd/storage_rd/light_storage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,8 @@ RID LightStorage::reflection_probe_instance_get_framebuffer(RID p_instance, int
16631663

16641664
ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
16651665
ERR_FAIL_NULL_V(atlas, RID());
1666+
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.");
1667+
16661668
return atlas->reflections[rpi->atlas_index].fbs[p_index];
16671669
}
16681670

@@ -1886,7 +1888,7 @@ void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_use
18861888
}
18871889
}
18881890
}
1889-
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.");
1891+
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.");
18901892

18911893
lightmap_textures.write[lm->array_index] = t->rd_texture;
18921894
}

0 commit comments

Comments
 (0)