I found awhile ago by experimentation there is a cost from offscreen Orx objects on iOS (it decreases FPS).
Based on this, I have an object that I want to keep offscreen, but in existence. It "slides up" onto the visible screen via FX, but it needs to already be in existence when the FX is applied. Otherwise, there's a delay while the object is created.
I don't want a mostly offscreen object to affect game performance, though. I was thinking I could capture the object's render start event and simply return false if the object is offscreen. Am I correct in thinking this should prevent the performance hit?
If so, is there an easier way to do this than processing the event manually. i.e. with the Orx API?
The object in question is a 269kb .png with round corners, so transparency is required. I could try to optimize the size of the texture so it loads faster, if that proves easier than what I'm trying to do in code.
Comments
Well, it all depends where the performance hit was. If it was the actual rendering itself, yes, it would cut it. It it was the fact that the object existed and was parsed by the renderer, then no.
Unfortunately no, you have to return orxFALSE for the orxRENDER_EVENT_OBJECT_START to bypass its rendering.
If the transparency is only used for the round corners you have two options:
- cut the objects so that only the corners are alpha blended and the other parts, all rectangular, are not blended
- use a shader that will discard the corner pixels (ie. the transparent ones) and writes the other ones (2 lines shader).
Not sure which one will have the less performance impact but they're worth a try, especially the shader one.
I wouldn't try to have the texture loaded lazily when you need it, but you can unlink/relink the orxGRAPHIC of your object at will if need be (this way the texture stays in memory but the object won't get rendered as it doesn't have a graphic).
What are the differences between canceling the object's rendering event and unlinking its orxGRAPHIC?
Removing the orxGRAPHIC should be slightly more efficient, if any, but is a bit more of a constraint as you need to keep a reference to it in order to put link it again with your object whereas the event listener is maybe slightly less code.
of course you'll need to delete the orxGRAPHIC at some point.
if rendering is the issue, you can try to compress the texture with PVRTC, and/or split the opaque areas and transparent areas and use blending only for transparents areas.
Thanks for the info about PVRTC, too. I'll look into that.