summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/storage_rd
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2023-02-14 14:37:47 -0800
committerYuri Sizov <yuris@humnom.net>2023-04-24 16:28:28 +0200
commit27df8b93aa3055d707421222eb9176964e294096 (patch)
treeb6a541c2a1ee3dc211a7fc12c91b21d3e65e516b /servers/rendering/renderer_rd/storage_rd
parent95f50274534563dbcb27e6ed3fcfa25a77f366e9 (diff)
Properly calculate lifetime_split for particles
(cherry picked from commit f35ca4a9c735e49d496c4e733e7dc9a072841f92)
Diffstat (limited to 'servers/rendering/renderer_rd/storage_rd')
-rw-r--r--servers/rendering/renderer_rd/storage_rd/particles_storage.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
index 3ed5d7dda8..1f6ec75df1 100644
--- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp
@@ -1193,7 +1193,7 @@ void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p
}
copy_push_constant.order_by_lifetime = (particles->draw_order == RS::PARTICLES_DRAW_ORDER_LIFETIME || particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME);
- copy_push_constant.lifetime_split = MIN(particles->amount * particles->phase, particles->amount - 1);
+ copy_push_constant.lifetime_split = (MIN(int(particles->amount * particles->phase), particles->amount - 1) + 1) % particles->amount;
copy_push_constant.lifetime_reverse = particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME;
copy_push_constant.frame_remainder = particles->interpolate ? particles->frame_remainder : 0.0;
@@ -1511,7 +1511,7 @@ void ParticlesStorage::update_particles() {
}
copy_push_constant.order_by_lifetime = (particles->draw_order == RS::PARTICLES_DRAW_ORDER_LIFETIME || particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME);
- copy_push_constant.lifetime_split = MIN(particles->amount * particles->phase, particles->amount - 1);
+ copy_push_constant.lifetime_split = (MIN(int(particles->amount * particles->phase), particles->amount - 1) + 1) % particles->amount;
copy_push_constant.lifetime_reverse = particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME;
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();