0

I'd like to fill the background of my app with animated clouds. I did some research and stumbled upon the perlin noise algorithm which seems to be fitting. However even in the first test it was extremely expensive to generate a 512x512 (2D) cloud map. I tried simplex noise but it didn't fix it.

According to http://freespace.virgin.net/hugo.elias/models/m_clouds.htm generating clouds is done by adding some perlin/simplex noise maps together. Impossible to do it on a iPhone in my app: I need fluid graphics (my optimistic expectation is 60 FPS on an A4).

So my question: Is there a lighter algorithm to generate animated clouds that does not make my frame rate drop too much?

Thanks in advance!

Paul

Paul
  • 1,295
  • 2
  • 11
  • 26

2 Answers2

2

Pre-generate the clouds and create 2d sprites using core animation or otherwise. You can then animate these around cheaply. You may not get 60 fps, but you should get close depending on how complex movement you want or what other animations are going on at the time. Either way, it's going to be faster than generating clouds yourself.

jer
  • 20,094
  • 5
  • 45
  • 69
  • True. But I'm not sure whether it is random enough. We will see if there is somebody else who knows a light realtime generation algorithm. – Paul Jul 05 '11 at 14:36
  • Define N paths, where N is an acceptable number. Play your animation and after it completes, select a random path for your next animation. I think this should provide a sufficient level of randomness coupled with M number of pre-rendered cloud images. – jer Jul 05 '11 at 14:45
  • I accepted Kyle's answer because it was a tiny little bit more detailed and he needs some reputations points: you have 9,000 more. Nevertheless your answer was good. Thank you! :) – Paul Jul 05 '11 at 21:09
  • No worries, it's not a game for me, I just want people to get an answer they're happy with. :) – jer Jul 06 '11 at 13:14
2

Unless all you're doing is generating clouds you'll definitely want them precomputed. Perlin noise can make for nice 2d animations by traversing a set of 3d data, but you could just scroll a 2d image of some noise or a fractal like is generated by the diamond-square algorithm. Either way, you should probably precompute it.

If you want some more variation, I would experiment with putting a noise filter over the precomputed clouds.

Kyle
  • 1,978
  • 1
  • 18
  • 30
  • Seems like the way to go. I will still wait some time for answers. Thanks for pointing me to the diamond-square algorithm. Did not know it existed before. – Paul Jul 05 '11 at 14:46