- Home /
Is it possible to change 1000 particles's positions in several particle systems without being too laggy on mobile?
I'm trying to recreate this by making it 3D, and on mobile. I've gotten my generating fractal code and particle system looping all set up, but it's super laggy on my computer.
Currently works as follows: 1. Instantiate 10 Prefabs of Particle Systems(each has say 1000 particles) 2. Within each prefab, I loop through each particle and adjust their position to create a fractal orbit 3. Emit 1000 particles repeat
Answer by tanoshimi · Jun 02, 2015 at 05:05 PM
Not really, no. Particle systems require a reasonable amount of processing power, and mobile devices are, well, primarily designed for making phone calls. If you must do it this way, I'd use a coroutine to spread out the cost of adjusting particles so that each one is only updated one frame in four, say. Other than that, you simply need to rethink your architecture.
Thanks! I would really like to implement this website on mobile, but I'm not very familiar with great design ideas. Perhaps you could shed some more light on some alternatives? I'll try implementing the coroutines to spread the adjustment of the particles. But, it doesn't seem like it'll be enough. Are there any other things I can do?
Your game is a pipeline: it has a constant flow of data, starting at the player input and ending with the output rendered to screen. Along the way are a number of steps including all your game logic, physics calculations, audio processing, particle systems yada yada..
The speed at which data can flow through this entire pipeline is deter$$anonymous$$ed by the slowest component - the bottleneck - at which the most amount of data is trying to be pushed through the narrowest part of the pipe. So to optimise your game (or, in fact, any software application) you first need to work out what the bottleneck is. Trying to optimise anything other than the bottleneck is pointless. Unity comes with a profiler that will tell you how long each function takes to execute. Now, if your bottleneck is CPU-bound, it might be that you can move some of the particle calculations onto the GPU ins$$anonymous$$d (by, e.g. uploading a texture that encodes the various particle properties). If you're memory bandwidth bound, you could compress your textures. On a mobile device, you're more likely to be fillrate bound, in which case you need to reduce overdraw and simplify your shaders as much as possible - not using alpha transparency, for example.
But, without knowing what the bottleneck is first, you'd just be guessing.
Right. I've done the profiler part and figured out that it is the generation of the new positions for the particles that is causing a lag spike. The loop basically goes through each particle in the given system and adjusts their position one by one before setting the new particles to the system. It's quite slow, but I'm not sure if there's any other way about this? Do you have insight on this?
Your answer
Follow this Question
Related Questions
[Solved] Reverse animation help 2 Answers
How to loop an animation in reverse? 0 Answers
How can use C# to make a loop run at maximum speed without stalling game time? 3 Answers
Nested for-loop freezing Unity 0 Answers
Trouble checking against array objects 0 Answers