Scrolling 3 layer starfield textures gets me from 60 -> 40 FPS

Apprentice
Posts: 7
Joined: 2009.08
Post: #1
I need to draw the background for a 2D space game. I need to implement 3 layers of stars: one distant layer (moving really slow) in the background, one layer of far away stars (moving slow) and one layer of close stars (moving normal) on top of the other two.

The way i first tried this was using 3 textures of 320 x 480 that were transparent pngs of the stars. I used GL_BLEND and SRC_ALPHA, ONE_MINUS_SRC_ALPHA.

The results were not great even on the 3GS. On the first generation devices the FPS dropped to 40..50 so i think i'm doing this the wrong way.

When i disable the GL_BLEND everything works great even on the 1st gen devices and the FPS is back to 60 again... so it's must be the fact that i'm trying to belnd large transparent textures.

The problem is i don't know how to do it some other way...

Should i draw only the first nebula like an opaque texture and then try to emulate the middle and top star layer with small points moving around the screen?

Is there any other approach on the blending issue? How can i speed up the rendering process? Is one big texture (tileset) the answer?
Quote this message in a reply
⌘-R in Chief
Posts: 1,253
Joined: 2002.05
Post: #2
If the vast majority of the texture is transparent, you might be better off trying to create the star field in code by rendering each star individually. There'll be less pixel fill requirements. You may have to compromise on the appearance though to achieve the lowest performance hit.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #3
Full-screen textures with blending on iPhone have always knocked off a bunch of frame rate for me. I don't know of any good way around it, other than what FreakSoftware suggests, which is to render smaller translucent objects if you can, so fill requirement is lower. So yeah, obviously the nebula needs to be there, but you might find it better to render the stars individually.
Quote this message in a reply
Member
Posts: 353
Joined: 2002.04
Post: #4
AnotherJake Wrote:Full-screen textures with blending on iPhone have always knocked off a bunch of frame rate for me. I don't know of any good way around it, other than what FreakSoftware suggests, which is to render smaller translucent objects if you can, so fill requirement is lower. So yeah, obviously the nebula needs to be there, but you might find it better to render the stars individually.

And presumambly the nebula doesn't need to have blending because it is the very background layer?
Quote this message in a reply
Apprentice
Posts: 7
Joined: 2009.08
Post: #5
monteboyd Wrote:And presumambly the nebula doesn't need to have blending because it is the very background layer?

The nebula will be opaque so there's no need for blending there.
Quote this message in a reply
Post Reply