Used the empty sprite and got 60FPS instead of the 45FPS I usually had.
No idea why but thanks for this post.
Best approach for full-screen background image on iPad
(84 posts) (42 voices)-
Posted 1 year ago #
-
I'm going to try the empty sprite trick but the only thing that works for me right now is to load the background as part of the same spritesheet as the other sprites on the screen. I know it's not a practical solution for most of you. My game has about 250 sprites and a static background.
Also, I've tried the splitting image idea but it didn't work on my case.
Posted 1 year ago # -
i tried to scale little image with function "CCSprite scale" but nothing changed.. fps not increased.
Posted 1 year ago # -
I'm not sure all is sunshine and roses with this FPS trick (although it could be an easy fix). I tried the hack mentioned and noticed that my sprites were updating in "spurts". My node structure goes: Game Sprites -> Spritesheet -> Background Sprite -> Dummy Sprite -> Scene
Previously they would move at a constant pace, but after making the change suggested, they stay in one place for a few seconds, then quickly move to catch up (with their chipmunk body).
So whatever is causing the FPS increase seems to be doing so by causing less updates, maybe less visits to the node? In any case, hopefully a fix can be found. I can live with the solid 30fps I've got now, but would definitely prefer to run at 60.
If nobody else has the problem, then maybe it's just something with my setup, but I was careful to make the change in isolation and the effect was immediate and obvious.
Posted 1 year ago # -
If I use two images 1024x512 and 1024x256, should I also use two empty sprites for each of them ??
Posted 1 year ago # -
mostly a holdover from before I was using spritesheets for my sprites, I just inserted the spritesheet in between the sprites and their parent. my game is simple enough in terms of layers that I could probably switch over easily. I just wasn't aware there was a significant performance boost to be had by adding the background to the spritesheet, I figured that came from moving my numerous active/animated sprites to a spritesheet. I'll definitely give it a shot, and try yaoligang's trick again afterwards.
Posted 1 year ago # -
I was using 2 images 1024x512 and 1024x256 and my frame rate was 45/49
just added that empty sprite and now is 60. :)Seems like Voodoo to me. Sure that this black magick is really better performing instead of just showing a nicer framerate but really is stuttering/the same?
Posted 1 year ago # -
There is no need to do some kind of magic or voodoo :). Just follow the spritesheet solution in the topic below, where you load up your full screen image into a spritesheet, create 4 sprites from it and than show it as your background :
http://www.cocos2d-iphone.org/forum/topic/7601
Our game, "FastBall 2 for IPad" was getting 47/50 FPS before this approach, meaning while showing directly 1024*768 image on the background and after the spritesheet solution, we got constant 60 FPS.
Posted 1 year ago # -
Hello,
I red all your posts and that was very interresting.
I have a performance problem too.I created a new thread here:
http://www.cocos2d-iphone.org/forum/topic/8520Posted 1 year ago # -
@Ozden79; this technique worked for me quite nicely. Previously in my simple match game I was getting around 48fps on most menu screens, dropping to around 38-42fps when I have around 25 sprites, bitmap fonts etc on the main game screen.
By splitting my background into 4 quads of 512x384 each, my FPS went back to 60 on the device. Simulator performance is still 15-30fps of course but we all know you can't rely on that as an indicator.
Thanks again.
Posted 1 year ago # -
We have the performance problem with the iPad now, too.
Our findings are that filling the whole screen with a sprite is possible at nearly 60Hz, however the iPad is already at its limit. Adding any more sprites will decrease the frame rate. It does not matter if we have a fullscreen bg image or just a small sprite and zoom into this sprite (or scale the sprite up). Filling the screen with smaller separate sprites is nearly the same.
Seems like the fillrate is the problem here.
Doing the same on the iPhone4 which has the same gfx processor and nearly the same amount of pixels results in steady 60 Hz. Even after adding some more sprites to draw. Its a big difference.
Tiling the bg sprite cannot be the solution as a scaled up smaller sprite does have the same problems.
Is there no way around this problem??
Posted 1 year ago # -
I can say for certain that tiling your background as separate sprites that are all placed in the same CCSpriteSheet will improve the performance greatly. I use 12 sprites each 256*256 to create a full background with an additional 70+ sprites (all running actions at the same time) and have no problems maintaining 60fps on the iPad.
Though I will say, in another test I did with a full background, also tiled but with an alpha channel for cutout "windows" and placed over a CCColorLayer, my performance dropped to ~30fps, and nothing I tried would bring that back up.
Posted 1 year ago # -
I made some more tests.
I draw 2 fullscreen images over each other. The iPhone4 has a renderer utilization of 55%. The iPad has 100% (it a bit lower than 100, but the framerate is already dropping to 45fps)
Tiling the bg image into 256x256 pieces gives for the iPhone4 an utilization of 52% and for the iPad 63%. So in this case they behave the same. The iPad has some more pixels to draw, so it has a slightly higher utilization of the renderer.
I get the same values for tiling the bg into 512x512 pieces.
Zooming into the scene does not make a difference.
PVR or PNG does not make a difference.I will have to investigate this further as I have still a huge performance difference between iPhone4 and iPad when running the real game scene. Even after tiling the bg.
Posted 1 year ago # -
Did you try all the pixel formats for PVR? I found 4444 and 5551 a tad faster in my project.
Posted 1 year ago # -
Setting the pixel format with CCTexture2D:: setDefaultAlphaPixelFormat is not valid for PVR images. So it should not make a difference what you use here.
edit: seems like this is supported now. I tried different ones, but without any difference.
Posted 1 year ago # -
Ok, I made another observation. This was mentioned some posts earlier in this thread.
Tiling of the bg image does not improve performance! What is improving it is putting the bg into s sprite batch node. I was doing this when I tried the tiling so I drew the wrong conclusions.
I will open a bug/feature report for this as clearly there is room for optimizations for the iPad. Drawing a single sprite should not be faster when I put this sprite into a batch node.
Posted 1 year ago # -
Ive just got an iPad and been coming up against the same problems, Ive have everything batched in 1 batch(apart from 2 bitmapFonts). I use one 1024x768 part of the atlas for the BG, and then I cover it with a grid of hexagons that covers about 60-70% of the screen and then a number of small enemy on screen. I'm then tilting the camera a bit based on the players position on the grid.
I'm getting no more than 30fps, without the background its just about 60fps. Is this something i can fix or has the iPad just not got enough fill rate to handle this art style...
Please advise, this kind of stuff i always struggle with not being a proper programmer(artist attempting to code)...
Thanks as always, Dave
Posted 1 year ago # -
What you are doing should run at 60Hz. Take a look at the renderer utilization with Instruments when you remove the BG. Maybe its already close to 100%. If so the BG is not your real problem.
Posted 1 year ago # -
Im not exactly sure what you're doing when you say tiling the background (my project is isometric view)... but tiling is essential to performance for me. I use small tiles and hide / unload them when they go offscreen. Can't this be done in a 2d side scroll as well? Compared to using fullscreen sized sprites back to back, 64x64 tiles would cut fill rates by 30-40% as less time is wasted drawing offscreen.
Posted 1 year ago # -
I have not tested the impact of tiling when there a big parts of a sprite offscreen. I made this test some time ago and I did not see any performance difference. I will take a deeper look at this.
My recent tests on the iPad show however that the renderer utilization does not change when zooming into my background sprite.
Posted 1 year ago # -
I spoke with a friend of mine who seemed surprised that fill rate is affected by drawing off screen. Maybe the difference I'm seeing in my project is just due to the call overhead etc. Can anyone confirm or deny before I rerun some tests?
Posted 1 year ago # -
Since this thread seems to keep floating to the top, thought I'd post a link to another thread I started regarding OS 4.2 and full-screen backgrounds:
Full Screen Backgrounds in OS 4.2
Obviously this doesn't help anyone targeting 3.2 right now, but it's interesting nonetheless. I guess some things have been done behind the scenes to optimize graphics on the iPad with the updated OS.
I'd be curious to know if anyone testing 4.2 has had similar results.
Posted 1 year ago #
Reply
You must log in to post.