diff options
author | clayjohn <claynjohn@gmail.com> | 2022-12-22 11:30:59 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2022-12-22 11:30:59 -0700 |
commit | 4d301ee21e54752ee6076547eb94385cb52e1fe2 (patch) | |
tree | 85285fe91813f016156cbe6ac6b8616b31ff1ae9 /servers/rendering/renderer_rd/shaders | |
parent | c547c4ef5908b9d591497e40217200ecb12e0ebd (diff) |
Check for disabled particle trail particle before initializing particle trail
Diffstat (limited to 'servers/rendering/renderer_rd/shaders')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/particles.glsl | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/servers/rendering/renderer_rd/shaders/particles.glsl b/servers/rendering/renderer_rd/shaders/particles.glsl index f787b74dab..a609076e2c 100644 --- a/servers/rendering/renderer_rd/shaders/particles.glsl +++ b/servers/rendering/renderer_rd/shaders/particles.glsl @@ -243,8 +243,14 @@ void main() { if (params.trail_size > 1) { if (params.trail_pass) { + if (particle >= params.total_particles * (params.trail_size - 1)) { + return; + } particle += (particle / (params.trail_size - 1)) + 1; } else { + if (particle >= params.total_particles) { + return; + } particle *= params.trail_size; } } @@ -298,17 +304,17 @@ void main() { PARTICLE.flags = PARTICLE_FLAG_TRAILED | ((frame_history.data[0].frame & PARTICLE_FRAME_MASK) << PARTICLE_FRAME_SHIFT); //mark it as trailed, save in which frame it will start PARTICLE.xform = particles.data[src_idx].xform; } - - if (bool(PARTICLE.flags & PARTICLE_FLAG_TRAILED) && ((PARTICLE.flags >> PARTICLE_FRAME_SHIFT) == (FRAME.frame & PARTICLE_FRAME_MASK))) { //check this is trailed and see if it should start now - // we just assume that this is the first frame of the particle, the rest is deterministic - PARTICLE.flags = PARTICLE_FLAG_ACTIVE | (particles.data[src_idx].flags & (PARTICLE_FRAME_MASK << PARTICLE_FRAME_SHIFT)); - return; //- this appears like it should be correct, but it seems not to be.. wonder why. - } if (!bool(particles.data[src_idx].flags & PARTICLE_FLAG_ACTIVE)) { // Disable the entire trail if the parent is no longer active. PARTICLE.flags = 0; return; } + if (bool(PARTICLE.flags & PARTICLE_FLAG_TRAILED) && ((PARTICLE.flags >> PARTICLE_FRAME_SHIFT) == (FRAME.frame & PARTICLE_FRAME_MASK))) { //check this is trailed and see if it should start now + // we just assume that this is the first frame of the particle, the rest is deterministic + PARTICLE.flags = PARTICLE_FLAG_ACTIVE | (particles.data[src_idx].flags & (PARTICLE_FRAME_MASK << PARTICLE_FRAME_SHIFT)); + return; //- this appears like it should be correct, but it seems not to be.. wonder why. + } + } else { PARTICLE.flags &= ~PARTICLE_FLAG_STARTED; } |