Description
Godot version
4.1.2 stable
System information
macOS, Android. All renderers
Issue description
After adding a GPUParticles2D node to our project, I was surprised to find it suddenly running at 10FPS on Android. Disabling particle turbulence brought the FPS back to the normal 90. Turns out the real culprit is not the turbulence itself, but this conditional check for collision in the particle shader:
if (!COLLIDED) {
float vel_mag = length(VELOCITY);
float vel_infl = clamp(mix(turbulence_influence_min, turbulence_influence_max, rand_from_seed(alt_seed)) * turbulence_influence, 0.0, 1.0);
VELOCITY = mix(VELOCITY, normalize(noise_direction) * vel_mag * (1.0 + (1.0 - vel_infl) * 0.2), vel_infl);
}
This check gets generated even when collision is disabled. Luckily I don't need collision and simply removing it solved the issue (I've included this fixed version of the particles in the MRP). However, it's still odd that this is so slow in the first place. Replacing the if statement with a ternary or a step expression did not help.
The problem is not only on mobile - running the example project on my M1 Mac, I get a drop from 1500 FPS to 600 after enabling turbulence on a default particle system emitting only 1 particle. Also happens regardless of rendering backend. Have not confirmed on iOS or Windows.
I assume it applies to 3D too, but didn't check.
Steps to reproduce
Run MRP scene, should run well at first.
Then enable turbulence and observe FPS drop.
Activity