x


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

more ▼

asked Oct 09 '10 at 09:22 PM

runonthespot gravatar image

runonthespot
514 19 21 36

Draw calls aren't your problem. Reduce the VRAM your textures use, via size change or more compression.

Oct 09 '10 at 09:52 PM Jessy

Will do. That's very interesting- are drawcalls not such a big deal any more?

Oct 11 '10 at 08:22 AM runonthespot

Jessy, if you cut'n'paste your comment as an answer, I'll mark it as answered, thanks.

Oct 12 '10 at 11:08 AM runonthespot

No, thank you! ;-)

Oct 12 '10 at 05:03 PM Jessy
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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.

more ▼

answered Oct 12 '10 at 05:15 PM

Jessy gravatar image

Jessy
15.7k 72 95 198

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. My 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!

Oct 12 '10 at 08:25 PM runonthespot

Incidentally if you want to see the sort of scene I'm drawing, take a gander at my website for the project http://www.darkquadrant.co.uk

Oct 12 '10 at 08:26 PM runonthespot
(comments are locked)
10|3000 characters needed characters left

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?

more ▼

answered Oct 12 '10 at 11:07 AM

runonthespot gravatar image

runonthespot
514 19 21 36

(comments are locked)
10|3000 characters needed characters left

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:)

more ▼

answered Oct 12 '10 at 12:59 PM

noradninja gravatar image

noradninja
805 17 23 41

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 Maya, 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. :)

Oct 12 '10 at 08:22 PM runonthespot

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.

May take a couple minutes longer but you will have direct editing control over them

Apr 03 '12 at 12:51 AM reptilebeats
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2279
x2028
x119
x115
x64

asked: Oct 09 '10 at 09:22 PM

Seen: 5554 times

Last Updated: Apr 03 '12 at 12:51 AM