- Home /
Tips for particles on IOS
Hi all- I'm looking for tips to get a lot of particles moving on screen as efficiently as possible in Unity.
I'm working on a top down (e.g. 2.5d) space game and want a star field of sorts. It needs to be performant on IOS. The trouble is that the game area zooms in and out, so to create enough stars to cover the game area, I'm looking at thousands of particles. This works fine in the editor, but on the device, it's naturally too slow to really work. The stars are important part of the gameplay as they add a sense of movement (see this videoclip of my play area & camera style to get a sense of what I mean by zooming in and out http://www.youtube.com/watch?v=mAhNL0y5W9U)
Some things that make this different from the standard particle question:
I'm trying to fill a space, 4000x4000x4000, where in one view, you may see as much as 2000x2000x4000 of it. Because it zooms in and out, I can't see a way of improving performance by culling what's not in view.
There is practically no overdraw as they're tiny discrete stars.
I've tried various other ways to get stars in there (the most disasterous was 3 x full-screen single transparent planes with starfield texture, attempting to give a sense of depth)
Some subquestions:
Assuming a starfield of say 500 stars-- would it be better to give them high energy (so they stay around permanently), or a min/max energy range (to potentially halve the number of particles drawn on screen at a given point in time)
I'm currently using an additive mobile shader- presumably this is my best bet?
Is there some sort of camera trick I could do to better manage the need for lots of stars to be visible when zoomed in, but, relative to the area visible, less stars visible when zoomed out?
Would it be worth trying to individually manipulate / recycle 100-150 particles to redistribute them based on how zoomed in you are?
Any useful thoughts added as answers to this thread will be voted up by me. I'll also do a post-mortem comment to the eventual approach I took.
Answer by demize2010 · May 23, 2011 at 09:23 AM
Hey man,
Sounds like a lot of particles your throwing around there, I'm not 100% sure if your going to find much joy on mobile devices without hardware acceleration there.
My advice would be to use the Skybox with some foreground objects / planes to give depth ;)
It's not too bad with circa 300-500 particles- just that's not enough when zoomed in, to give a sense of speed that I want. :)
I've mainly been working on Android but we have a strict limit of no more then 50 particles on screen from all emitters - and that's only if they are to dieing fast as well ;)
I think because there is zero overdraw, and the scene practically has nothing else in it (besides a planet and two spaceships), it isn't so bad. I'll benchmark the fps vs particles at lunch, but I recall I've been getting > 45 fps with a good number of particles.
Probably be best to create a shader that will generate a moving star-field for you and the you are drawing a single quad or a sky box perhaps.
Answer by Kiloblargh · Jul 02, 2013 at 04:20 PM
Don't use particles for your stars. Just don't.
I made a good looking global 3d starfield by instantiating quads of random size (based on actual stats of visible star magnitude) with a star texture using Random.OnUnitSphere and then making them all face the center; then moving them far away and combining the mesh.
Here's an idea- Since yours is a 2d scroller, make the stars on a big cylinder instead of a big sphere, then rotate the cylinder counterclockwise as you accelerate forward, clockwise when you go back, and move its center closer or farther from the camera when you zoom in and out on the ship. It might be a good idea to have one camera that sees nothing but stars, and a lower one that sees only nebulae (on an inward facing cylinder with a seamless texture map) that can be low-res because nebulae are blurry. But the stars will appear sharp at any zoom level.
Stars shouldn't have parallax anyway- you can only ever be close enough to one star (the sun of the planet you're flying by) to see it move differently relative to the other stars; and no way you're traveling at warp speed while dodging and shooting stuff.
But you can add dust clouds, asteroids, etc. that are closer and do move with parrallax.
Thanks :) I should say it's a multidirectional 2d game, see here: http://www.youtube.com/watch?v=H__YPbXelrk for an older vid. In the end I opted for distant planes, and that worked fine. I wasn't concerned with realism regarding parallax- just wanted a sense of depth. Space graphics toolkit provided the necessary juice.
Your answer
Follow this Question
Related Questions
ParticleSystem behaving differently on iOS 1 Answer
3D starfield with shuriken 3 Answers
Bad slowdown with particles on iOS 1 Answer
Lighting in AR for iOS 0 Answers
drawcalls using particles on ios 1 Answer