Hi all,
First I’d like to thank to Away3D team for really awesome work! I’ve been using it for some ongoing projects and look & feel that can be achieved with it is really great!
Now I’m making a mobile app, for Android and iOS devices.
It’s not my first time to make mobile app (I’m also OpenGL/C++ developer) and I did Android (Java/C++) and iOS (ObjC/C++) dev, so I’m aware of mobile restrictions, amount of memory, limitations of OpenGLES, potential issues etc.
I’m trying to optimize AS3 code to get most performance out of Away3D on mobile.
I have 2 questions for A3D experts:
1) Lighting on materials slows down performance quite noticeably.
One detail I’ve noticed is that adding light picker to a material is drastically reducing performance. Although I know that per-pixel-lighting, having specular reflection of a point light etc. do require several more pixel shader lines, dot product etc, I wonder is there a way to somehow optimize it in A3D so on mobile will still keep somewhat similar performance as if not having light picker?
2) Binding texture makes “chop” in performance.
In my scene I have some “dynamic” objects that appear and disappear. I say “dynamic” because they are all already created and added to the scene in app initialization, and are just switched on/off by changing visible property. Each has it’s own material (since there is some fade in-out involved which is different for each object), but they do share textures. Textures are also created in app initialization, and not during app performance. There are in total 4 textures, size 512x512 RGBA.
What happens is that once object starts fade-in, I see performance drop from 30fps to eg 6fps for very short period, then goes back up. And every time object starts fade-in, with texture that was not shown before in the scene, I see this drop. Texture contains framed animation. This animation is “played” by object, which, instead of animating UV coords, has internal “slide show” of planes, each with predefined UV coords. UV coords are the same for all objects, as these textures all have same animation frame order, size etc.
Once all objects are faded in, performance goes back up to 30fps.
Objects are covering small screen space area (eg 10-15% each object), and there are 4-5 objects visible at one time.
So my guess is that texture binding to GPU is the bottleneck (as it is usual bottleneck in any GPU programming).
I have also tried with simple cube objects (without framed animation, so I eliminate this as a factor) and I can still see same performance drop.
Can someone advise me on what approach is good for texture/material/objects organization to prevent this from happening?
Notice: both of the above issues are only on mobile, and I’ve seen them on both iPhone 4 and Samsung Galaxy S1 (Android 2.2).
On desktop/laptops there are no such issues, everything works like a charm.
Even if someone can confirm:
“I can add/remove objects with different textures from the scene without performance drop on mobile platform” will be great answer as it will at least give me some directions where to look - into my own code, or in A3D
Just to notice: when I run test in FlashDevelop4, and not on mobile, it all works great. So it’s something that happens only on actual device.
Thanks!!!!