@@ -1495,12 +1495,15 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
14951495
14961496 RD::get_singleton ()->draw_command_begin_label (" Reflection probe render" );
14971497
1498- if (LightStorage::get_singleton ()->reflection_probe_get_update_mode (rpi->probe ) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection .is_valid () && atlas->size != 256 ) {
1498+ const bool update_always = LightStorage::get_singleton ()->reflection_probe_get_update_mode (rpi->probe ) == RS::REFLECTION_PROBE_UPDATE_ALWAYS;
1499+ if (update_always && atlas->reflection .is_valid () && atlas->size != 256 ) {
14991500 WARN_PRINT (" ReflectionProbes set to UPDATE_ALWAYS must have an atlas size of 256. Please update the atlas size in the ProjectSettings." );
15001501 reflection_atlas_set_size (p_reflection_atlas, 256 , atlas->count );
15011502 }
15021503
1503- if (LightStorage::get_singleton ()->reflection_probe_get_update_mode (rpi->probe ) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection .is_valid () && atlas->reflections [0 ].data .layers [0 ].mipmaps .size () != 8 ) {
1504+ const bool update_mode_changed = atlas->update_always != update_always && atlas->reflection .is_valid ();
1505+ const bool real_time_mipmaps_different = update_always && atlas->reflection .is_valid () && atlas->reflections [0 ].data .layers [0 ].mipmaps .size () != 8 ;
1506+ if (update_mode_changed || real_time_mipmaps_different) {
15041507 // Invalidate reflection atlas, need to regenerate
15051508 RD::get_singleton ()->free (atlas->reflection );
15061509 atlas->reflection = RID ();
@@ -1517,7 +1520,7 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
15171520
15181521 if (atlas->reflection .is_null ()) {
15191522 int mipmaps = MIN (RendererSceneRenderRD::get_singleton ()->get_sky ()->roughness_layers , Image::get_image_required_mipmaps (atlas->size , atlas->size , Image::FORMAT_RGBAH) + 1 );
1520- mipmaps = LightStorage::get_singleton ()-> reflection_probe_get_update_mode (rpi-> probe ) == RS::REFLECTION_PROBE_UPDATE_ALWAYS ? 8 : mipmaps; // always use 8 mipmaps with real time filtering
1523+ mipmaps = update_always ? 8 : mipmaps; // always use 8 mipmaps with real time filtering
15211524 {
15221525 // reflection atlas was unused, create:
15231526 RD::TextureFormat tf;
@@ -1540,7 +1543,7 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
15401543 }
15411544 atlas->reflections .resize (atlas->count );
15421545 for (int i = 0 ; i < atlas->count ; i++) {
1543- atlas->reflections .write [i].data .update_reflection_data (atlas->size , mipmaps, false , atlas->reflection , i * 6 , LightStorage::get_singleton ()-> reflection_probe_get_update_mode (rpi-> probe ) == RS::REFLECTION_PROBE_UPDATE_ALWAYS , RendererSceneRenderRD::get_singleton ()->get_sky ()->roughness_layers , RendererSceneRenderRD::get_singleton ()->_render_buffers_get_color_format ());
1546+ atlas->reflections .write [i].data .update_reflection_data (atlas->size , mipmaps, false , atlas->reflection , i * 6 , update_always , RendererSceneRenderRD::get_singleton ()->get_sky ()->roughness_layers , RendererSceneRenderRD::get_singleton ()->_render_buffers_get_color_format ());
15441547 for (int j = 0 ; j < 6 ; j++) {
15451548 atlas->reflections .write [i].fbs [j] = RendererSceneRenderRD::get_singleton ()->reflection_probe_create_framebuffer (atlas->reflections .write [i].data .layers [0 ].mipmaps [0 ].views [j], atlas->depth_buffer );
15461549 }
@@ -1551,6 +1554,7 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
15511554 atlas->depth_fb = RD::get_singleton ()->framebuffer_create (fb);
15521555
15531556 atlas->render_buffers ->configure_for_reflections (Size2i (atlas->size , atlas->size ));
1557+ atlas->update_always = update_always;
15541558 }
15551559
15561560 if (rpi->atlas_index == -1 ) {
0 commit comments