Android opengles glBindTexture() calls - android

My game already consists of an atlas the size of 1024x1024 as I am aware that is the max size for a texture. The problem is I need about 1-2 more of these 1024x1024 textures. That should give me 3 glBindTexture() calls which I know is huge performance drag. I have not tested it yet because I am having other problems currently but would this slow my application by a considerable amount? Is there another solution?

If you are worried about any performance loss, I'd recommend you to profile your application so you really can see where your application's bottleneck is, and then come back if it turns out to be horrible.
Three big atlas textures are still better than many small textures that you bind over and over again.

Currently my game has around 6 512x512 texture atlases and I still dont require any loading screens on any phone so far. Although if you are going to do a lot of binding you may want to look into making a Batcher class that will submit all of your vertices to the GPU at one, it will speed up your application considerably

Related

Antialiasing on OpenGL ES 2.0

How can I do antialiasing on triangles on the entire render? Should I put it on the fragmentShader? Is there any other good solution to improve this sort of thing?
Here is my "view", with very crispy edges (not very nice).
After doing some Deep research, I found that It's in fact pretty simple, and the most comonly done is to render like there was a screen 4 times bigger (or even more than 4 times). After rendering to this much more bigger screen, the GPU will take the avarege of that area and set the pixel color based on that.
It's pretty easy to enable this with this library:
https://code.google.com/p/gdc2011-android-opengl/source/browse/trunk/src/com/example/gdc11/MultisampleConfigChooser.java
However,you should keep in mind, that it will spent 4 or more times time to render everything, meaning more time to process, and perhaps, less FPS...
Also, if you are emulating an android device with OpenGL, find out if your GPU supports this kind of Multisampling. Mine for example, doesen't (Tegra).
Here is the final result, with and without multisampling:

Optimal way to fit images in an atlas?

The AndEngine framework for Android has a way to load textures into an atlas. The atlas way of loading textures was new to me and so I looked into it. From what I've read around the forums, an atlas is a large rectangular region of image data where the width and height have to be powers of 2 (although they don't have to be equal, i.e. you can have a 512x1024 if you want). Textures are loaded into this region and this is used to keep them all in memory during the lifetime of the app. It allocates all of that space even if you don't use some of it.
With that in mind, what process can I use to optimally place an arbitrary number of graphics into the same atlas? I don't plan to do this at runtime within the app, but once all the graphics for my game have been created, I was hoping I could run the images and their sizes through some algorithm to determine how big to make the atlas and where each image should be loaded in it. Once I know those things, I can hard code their location for my game.
This is not an AndEngine or even Android specific question. I'm sure there are other graphics oriented frameworks that load textures this way.
I was about to post the question on Math.StackExchange.com but instead I found that it was already asked and already answered. There's even a link to a CodeProject article that does this for CSS Sprites.
EDIT: What I ended up doing in the long run was using a program called TexturePacker. Not only did it pack the images, it produced files to be used in AndEngine (as well as other supported platforms) and made the whole process easier for me.

Drawing large background image with libgdx - best practices?

I am trying to write a libgdx livewallpaper (OpenGL ES 2.0) which will display a unique background image (non splittable into sprites).
I want to target tablets, so I need to somehow be able to display at least 1280x800 background image on top of which a lot more action will also happen, so I need it to render as fast as possible.
Now I have only basic knowledge both about libgdx and about opengl es, so I do not know what is the best way to approach this.
By googling I found some options:
split texture into smaller textures. It seems like GL_MAX_TEXTURE_SIZE on most devices is at least 1024x1024, but I do not want to hit max, so maybe I can use 512x512, but wouldn't that mean drawing a lot of tiles, rebinding many textures on every frame => low performance?
libgdx has GraphicsTileMaps which seems to be the tool to automate drawing tiles. But it also has support for many features (mapping info to tiles) that I do not need, maybe it would be better to use splitting by hand?
Again, the main point here is performance for me - because drawing background is expected to be the most basic thing, more animation will be on top of it!
And with tablet screen growing in size I expect soon I'll need to be able to comfortably render even bigger image sizes :)
Any advice is greatly appreciated! :)
Many tablets (and some celphones) support 2048 textures. Drawing it in one piece will be the fastest option. If you still need to be 100% sure, you can divide your background into 2 pieces whenever GL_MAX_TEXTURE happens to be smaller (640x400).
'Future' tables will surely support bigger textures, so don't worry so much about it.
For the actual drawing just create a libgdx mesh which uses VBOs whenever possible! ;)
Two things you dindn't mention will be very important to the performance. The texture filter (GL_NEAREST is the ugliest if you don't do a pixel perfect mapping, but the fastest), and the texture format (RGBA_8888 would be the best and slowest, you can downgrade it until it suits your needs - At least you can remove alpha, can't you?).
You can also research on compressed formats which will reduce the fillrate considerably!
I suggest you start coding something, and then tune the performance up. This particular problem you have is not that hard to optimize later.

Loading large textures in AndEngine

In a game we're developing we need to animate a large sprite, of size 485x485 and the animation has about 30 frames. We have a problem animating such artifacts. I have tried some solutions as listed below, but unfortunately we haven't been able to come up with a solution yet.
Tiling
It looks like putting every frame in one big tile is not an option because:
The texture size needs to be a power of two, so it shows up as black on most devices
When I make the texture size a power of two, it becomes too big for most devices too handle
Recommended maximum texture size of AndEngine seems to be 1024x1024.
Seperate sprites
The other option is loading each texture, and thus each frame, seperately and putting it in a Sprite (as described here). This works quite well and toggling the visibility of each sprite at the right time causes the user to see the animation.
The problem with this method is that loading the whole animation takes quite some time. This is not visible when initially loading the game because of the loading screen, but later in the game the animation needs to be changed and the game needs then about 2-3 seconds to load. Putting a loading screen up is not an option.
Loading on seperate thread
I tried to put loading the textures in a seperate, newly created thread, but even while the thread loads the textures the drawing of the game seems to be paused.
Other options?
I don't know any option, and it appears no one else tried to animate a texture greater than 50x50 pixels because it is very difficult to find anyone with a similar case.
My question is: Is it even properly possible to animate large textures in AndEngine?
I think your problem is going to run up against device limitiations, not andengine limitations. Designing for mobile, there are few android devices that could run that.
However, you may be able to come up with an alternative solution using VertexShaders and FramentShaders. This si an important features of Andengine GLES2
Here is an article describing that approach:
http://code.zynga.com/2011/11/mesh-compression-in-dream-zoo/

Using large textures with opengl on android

What is the best way to go about using large textures with opengl on android?
I want to load some background images for my game with my target resolution being 480x800. Going by the recommended 512x512 resolution cap, I've tried scaling the images down to 240x400 and having opengl scale them back up, but that looks like trash and I would rather keep them as high-res as possible. I've seen one or two other people talking about using 512x1024 so I'm wondering:
How many phones would actually have trouble handling these image sizes?
Would it be better to risk an OOM and use 512x1024 textures, or risk a performance hit by splitting the images in two and increasing opengl calls?
For consideration: In general I will only be using two other 512x512 atlases at a time (aside from the background), with a maximum of three on menu screens where framerate isn't important.
Thanks!
I've experimented using large textures for for planets in my game. With two 1024x1024 hemispheres per planet and probably only one or max two planets visible at a time. Once in game, they render fine on my somewhat dated ZTE Blade running 2.1.
However, the load times were terrible (talking an extra 10 to 30 seconds for two large textures to load).

Categories

Resources