Are GUITextures with opacity (or color.a) = 0 GPU costly?

i am making a kind of flight simulator where a white screen (a fullscreen GUITexture) fades in when you come close to the boundary radius of the flying area (your plane will then be turned around so that you fly towards the center again and the white screen fades away soon). When being inside the area the screen’s opacity is 0.
Now i wonder if this invisible uses a lot of GPU power (since the iphone is anyway weak with transparent layers). and if i should better switch the GUITexture completely off?
Or does a GUITexture not matter when it’s opacity is 0. Or is the iphone intelligent with this anyhow? So i could save a lot of complicated code (cause the situation is a bit more complicated than described).

You should definitely turn it off when not in use, as filling the screen with a transparent quad can’t be good for the fill rate. As long as it’s active, it’s always rendered regardless of alpha value.

–Eric

Depending on the device you’re doing that on, you can literally halve your frame rate doing that.

I would do a check, if you pull the alpha under say, 5, turn that guitexture off (gameobject.enabled = false sort of thing)

i made a test app to find answers.

  • First of all. Yes a GUITexture with and color.alpha-value of 0 is the same GPU costly as one with a value of 0.5.
  • A GUITexture geneally is not sooooooo GPU-expensive. Five layers os RGBA, PVRTC4 cost about one frame (in my test setup).

my test setup:
on Ipod touch 2G (PowerVR MBX Lite 3D graphics processor, like ipod touch 1G, orig. Iphone, and iphone3g).
3 Pointlights and 100.5k Tris (acc. to Stats.) in the scene to bring down the fps to 22 fps.
a 512er RGBA, PVRTC4 texture
fps are accumulated over 1 sec, and screenshots taken from ipod at most representative values.

hope my setup makes sense and i didn’t miss anything important.

test 0: no GUITextures, fps ca. 22.2

test 1: one GUITexture with alpha of 0, fps ca. 22.3
test 2: one GUITexture with alpha of 0.1, fps ca. 22.3
test 3: one GUITexture with alpha of 0.5, fps ca. 22.3

test 4: five GUITextures with alpha of 0, fps ca. 21.5
test 5: five GUITextures with alpha of 0.1, fps ca. 21.5
test 6: five GUITextures with alpha of 0.5, fps ca. 21.5

test 7: ten GUITextures with alpha of 0.0, fps ca. 20.0
test 8: ten GUITextures with alpha of 0.5, fps ca. 20.0

My conlcusion is that (in this case) i don’t write extra code to switch off currently full transparent GUITextures (since they are ony two in my case). And Unity rocks!!!

Thanks man, that’s kinda handy to know, I just figured that an alpha of 0 would have been the same as turning it off (enabled = false).
It. Still seems to run okay though.
One thing though, is your alpha covering the whole screen there?

yeah it’s hard to see a difference with only one texture. That’s why i tested it with ten with alpha = 0 (test 7).
the GUITexture in test 3 covers the whole screen (pos 0.5, 0.5, … and scale 1,1,1). But i moved the other textures a bit apart from one another to better see what’s going on which leaves free edges.

So, did you test this on a device? With 100,000+ triangles? And you got 22fps? With 3 lights?

This sounds erroneous.

Secondly, that frame rate isn’t acceptable anyway.

Yes i extra installed it as app on an ipod touch G2.
The scene contains 40 (unity-)spheres (using a diffuse shader, without texture). The scene has it really easy with the fill rate.
100.7k tris according to stats. The stats also counts ‘degenerate’ tris. Whatever this is. And i also don’t know how much more they are in contrast to desktop GPU (where ‘degenerate’ tris are not counted). I would have to test it.
this is how the stats looks in the editor:

371160--12859--$screen_capture_198.png

100,000 triangles… On a 2nd gen. at 22fps? While you have a full-frame (or two) alpha blended component on top?

Turn on the app profiler when you run it and paste the debug output. I’m running <10,000 vertices on a 3GS and if they’re not treated properly, you’ll only get 50fps if you’re lucky.

thanx for keeping correctness! Ok yes, 100k tris sounds not realistic. And it’s indeed strange. I found it has to do with the number of lights. I still use Unity Iphone1.7 (cause i decided to wait for the final release).
So here is what i did:

  1. open a new scene with a camera in it and switch on the stats.
  2. i added a sphere to the scene (GameObject/Create other/Sphere).
  3. i duplicated it (select the sphere and press 39 times Command + D) ==> then the stats says: Tris: 34.3k
  4. i added a Point light (GameObject/Create other/Point light) ==> then the stats says: Tris: 68.6k
  5. i duplicated the Point light. ==> then the stats says: Tris: 100.4k
  6. i duplicated the Point light again ==> then the stats still says: Tris: 100.4k
    Actually i didn’t see the impact of the 3rd light on the iPod but that may have spacial reasons or it just does 2 Point lights. I don’t know yet i have to test again.

Anyway but now you know how i got to the over 100k tris and you can test it yourself.

Are you reading this frame rate from the device, or from the unity window?

130 drawcalls? On a gen 2? You’d be lucky to get 5fps.

the frame rate is displayed on the device. The screenshots were taken from the device (by shortly pressing both buttons simultaneously) completely unplugged from the computer (the stats is a screenshot taken from the editor). The material of the spheres have no texture and the meshes are a fairly dense pile of polygons so thats an easy job to fill them.
i attached the project folder (i cleared the iphone bundle identifier in the player settings). so you can install it on your device and see yourself. (maybe unity3 shows different stats). Maybe i really missed something.

i have to move on now. Maybe you can clarify the poly count/frame rate issue. that would be nice and thank you. Otherwise i would warn everybody that there might be something wrong with my numbers.

My original issue was the impact of GUITextures on the frame rate. And my conclusion is that it is so low that it’s not worth to panic around if you don’t switch them off when they are fully transparent (as long as they are not to many).

thank you very much!

371576–12871–$performancetest_153.zip (1.81 MB)

Agree…no way those stats are right on any current iPhone or iPod hardware.

As for 22fps not being “acceptable”…man…you are an FPS SNOB lol

Aim so high that even if you fail, you’re probably still better off than anyone else :slight_smile:

Yes, very interesting!

OK here are the right numbers: 42.0k tris and 42 draw calls.
They indeed look a lot different. But it’s absolutely the same project folder only opened with Unity3beta.

374819--12960--$screen_capture_124.png

Sorry for posting again, but i thought it to be important.
I installed exactly the same test app on an iPad. I was shocked because on the iPad (first Geneation) transparent GUITextures have a way more dramatic impact on the frame rate than i ever would have expected.
So when targeting ipad it’s good to always switch off GUItextures when they are not needed (like Eric proposed). Especially when they cover the whole screen.

The performance is also weak with transparent 3D-geomerty. But it seems to be strong with opac polygons.

So what i said (it’s OK to not worry about GUITextures) IS MEANT FOR THE LOWRES-DEVICES ONLY!!!

In my TestApp:
test: 0 (no GUITexture, fps 30)
test: 3 (one GUITexture, fps 27) costs ca. 3 frames
test: 6 (five GUITextures, fps 16) cost ca. 14 frames
test: 8 (ten GUITextures, fps 10) cost ca. 20 frames

the pic shows screenshots taken from Ipad (first Generation) (the image is scaled down 50%)