Light generation algorithm for clouds on the iOS platform
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. 开发者_JAVA技巧
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
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.
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.
精彩评论