From 41021b07be6d4b570c81d2fb0c4d71d90e9d9ed2 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Thu, 22 Dec 2022 12:04:34 -0700 Subject: Avoid updating particles during 2D rendering In 2D the particle uniform set isn't obtained until the render pass. So in 2D just avoid rendering if not updated yet. --- .../renderer_rd/forward_clustered/render_forward_clustered.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'servers/rendering/renderer_rd/forward_clustered') diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index c853ae6c69..0cfe639480 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -3598,6 +3598,10 @@ void RenderForwardClustered::_geometry_instance_update(RenderGeometryInstance *p } ginstance->transforms_uniform_set = particles_storage->particles_get_instance_buffer_uniform_set(ginstance->data->base, scene_shader.default_shader_rd, TRANSFORMS_UNIFORM_SET); + if (particles_storage->particles_get_frame_counter(ginstance->data->base) == 0) { + // Particles haven't been cleared or updated, update once now to ensure they are ready to render. + particles_storage->update_particles(); + } } else if (ginstance->data->base_type == RS::INSTANCE_MESH) { if (mesh_storage->skeleton_is_valid(ginstance->data->skeleton)) { ginstance->transforms_uniform_set = mesh_storage->skeleton_get_3d_uniform_set(ginstance->data->skeleton, scene_shader.default_shader_rd, TRANSFORMS_UNIFORM_SET); -- cgit v1.2.3