- Home /
Texture atlases on iphone
I'm using IOS Basic version of unity and am trying to reduce draw calls to keep a scene nice and zippy.
I understand my version of UNITY doesn't support static batching... not exactly sure how it relates to textures / texture atlases though. All of my objects pretty much use the same basic material, different textures, and I am pretty sure I can work out how to combine them into one texture using photoshop and the like. What I can't figure out is how to use that texture on multiple objects, (is it only available programmatically?) and whether it would actually make any difference?
My game is a simple space 2d shooter, but unfortunately it's generating 18-21 draw calls, 11.5k tris, 16.2k verts, vram from 4.9-21MB and VBO total of 89 - 1.1MB
This translates to some strange jerkiness on my iPhone.
Many thanks, Mike
Draw calls aren't your problem. Reduce the VRA$$anonymous$$ your textures use, via size change or more compression.
Will do. That's very interesting- are drawcalls not such a big deal any more?
Jessy, if you cut'n'paste your comment as an answer, I'll mark it as answered, thanks.
Answer by Jessy · Oct 12, 2010 at 05:15 PM
Draw calls aren't your problem (Under 30 is generally considered reasonable for even the oldest iOS devices.). Reduce the VRAM your textures use, via size change or more compression.
For whatever reason, GUI Textures do not batch (which is apparently less of an issue with rendering improvements in 3.0, but still true). However, without seeing your project, my assumption is that reducing draw calls isn't going to do much, if anything, for your framerate.
Personally, I do use textured meshes for my 2D elements, and Text Meshes (because they also batch, unlike GUI Text), but I mainly do it for the versatility of what can be achieved with meshes. An example of this, is, yes, moving UVs over an atlas, which, if you're changing your GUI a lot, will probably result in an improvement over using a bunch of smaller textures. While using atlases is likely to reduce draw calls, the benefit for a low draw call game like yours will most likely lie in removing the need to switch materials/textures, which, as far as I understand, is a significantly slower operation than a draw call. (Either way, it does take up cycles and should be avoided if only for battery life you save. ;-) )
If you're not switching the textures used in the GUI much, you're probably best to leave your method as is, assuming it's easy for you to deal with.
As I'm using Unity IOS basic, I worry that the batching is a bit of red-herring for me anyway, as I've never seen Unity batch more than 2, probably as most of my meshes are > 500 vertices. $$anonymous$$y GUI is probably going to be reasonably static and where it isn't I'll almost certainly resort to meshes. The texture sizes sorted my immediate performance issues though and for that, thanks!
Incidentally if you want to see the sort of scene I'm drawing, take a gander at my website for the project www.darkquadrant.co.uk
Answer by runonthespot · Oct 12, 2010 at 11:07 AM
Jessy, thanks for your comment, you were 100% correct. When I went into each texture and set everything at a minimum, despite having north of 20 draw calls, the gameplay experience was fast and perfectly smooth!
I currently have my gui drawn using GUITexture, which I understand adds drawcalls-- is this a big deal? Should I make the effort to move to EZ Gui or the likes, or will I not notice too much in the way of improvement?
Answer by noradninja · Oct 12, 2010 at 12:59 PM
If you are interested in reducing draw calls via atlasing, (giving you more calls for effects, etc), what you need to do is import the models for a particular atlas into a single file, adjust the UV's to match your atlas, then export each model to a single file, one for each model- in Maya, you can use File>Export Selected to do this (this will save the new UV layout for each model). Import the new models into Unity, make a shader with the atlas texture, and apply it to your newly UV'd models.
One texture to rule them all:)
Hi noradninja- I do understand the concept- the problem is the execution :) I purchased the models I used from a website- and don't have $$anonymous$$aya, only Blender and only the slightest amount of knowledge. I understand the concept of UVs but the only way so far I've been able to work out how to remap them is by doing it programmatically in Unity. It definitely worked, but PackTextures in Unity doesn't support PVTRC compression, so it kind of did more harm than good! I think when my game is finally completed, I will look again into remapping UVs and building the atlases in Gimp or Zwoptex. :)
There is a more time consumeing way of atlas using blender, basically any uv u export right down on a same size grid the position, then on next object do the same but place it next to the other object. Hence why you have to jot it down. Then import the uvs into a image editor like gimp and save as a single image, asign the image to both objects in blender and should be good to go.
Once the image is assigned you shouldnt have to open the object again as unity auto updates the image to the object. Unless of course you want to scale the size of one image in the atlas.
$$anonymous$$ay take a couple $$anonymous$$utes longer but you will have direct editing control over them