Home Unity

iOS - alpha blend vs. test vs. none?

About to start a mobile iOS project, curious if anyone knows the perf impact of using alpha for environment objects?

Foliage, mountain mists (cards), water, etc.

When I worked on a Wii game a couple years ago, alpha blend was too expensive for us except in limited ways (water surfaces mostly), alpha test was OK but we had to cut the meshes close in to minimize the amount of tested area (foliage, particles). And even then we had to be careful.

Any insights would be great.

Replies

  • kio
    Online / Send Message
    kio polycounter lvl 16
    to my knowledge alpha test is pretty expensive on the pvr architecture. So you're better off using alpha blend (yes this feels counter intuitive). maybe this has changed over the years im not sure.

    but well - alpha is just pretty expsensive and overdraw and fillrate are severly limited on mobile if you want to ship on a broad range of devices.

    so, in the end just do the regular optimization thingies like keeping drawcalls low, keep overdraw low etc..
  • Farfarer
    Yeah, on the tile based chips (most mobile chips) alpha blend is actually far more efficient than alpha test. Alpha test can be pretty crippling to performance.

    Overdraw is a problem for either, but there's something about alpha test that makes the entire til tile need an extra pass.
  • Eric Chadwick
    Ok, thanks for the insights, really appreciate this.

    I've worked with the PVR sdk a little, wondering if Unity takes care of everything, or if it helps to get down n dirty. Like I remember cube maps had seams in PVRTC, needed border padding pre-pro to fix.

    Well, I've got a bit of testing to do, will try to share any results.
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    On the iPad Air 2 I haven't yet experienced any alpha test performance issues.
  • kio
    Online / Send Message
    kio polycounter lvl 16
    well - thats no wonder as its pretty new hardware isnt it.. as always the problem on mobile arent the latest devices these are actually quite powerful, but once you want to hit a broader audience youll have to include lower end devices.
  • DLoud
    Offline / Send Message
    DLoud polycounter lvl 15
    Full screen alpha test seems to have a moderately large performance impact. We've been trying to avoid using it in areas where it can take up a large portion of the screen. Multiply or Additive blending are our preferred methods if we can get away with it. Alpha test can work if used sparringly.
  • Eric Chadwick
    Thanks Dana. How about standard lerp alpha blend? I wonder if this would be slower than additive or multiply blending.

    I'm thinking about foliage mostly, but also decals.

    IIRC PVR used to have tile-based sorting, which had virtually no alpha sorting errors. I wonder if the iPhone chipsets still have that?
  • DLoud
    Offline / Send Message
    DLoud polycounter lvl 15
    It's my understanding (I could be wrong) that alpha blend is is cheaper than alpha test. I believe it's because there is no native hardware support for alpha test. That's what the graphics guys tell me ;). It does seem a bit counter intuitive, I admit.

    Ultimately, I think it depends on the type of game you're making and the camera angle. Isometric camera is probably more forgiving given that there are relatively few assets on screen that it would need to sort. First person views of a horizon with foliage would result in lots of overdraw. I suspect that would be problematic using alpha test.

    I'd be interested to see what kinds of things you've run into Eric
  • Eric Chadwick
    Well I have nothing to show just yet, we're just trying to plan for imminent work. We're doing 3D iso, so that's good. One idea was to have a battle in a field of wheat, an overdraw nightmare in 1st person, but hopefully not too bad in iso. Will post results if I can.
  • Vailias
    Offline / Send Message
    Vailias polycounter lvl 18
    More technical info: https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Performance/Performance.html

    "Instead of using alpha testing or discard instructions to kill pixels, use alpha blending with alpha set to zero. The color framebuffer is not modified, but the graphics hardware can still use any Z-buffer optimizations it performs. This does change the value stored in the depth buffer and so may require back-to-front sorting of the transparent primitives."

    More info in the link under the heading "Use Hidden Surface Removal Effectively"


    Regarding a wheat field: looks like you've similar concerns to the wii, but you should have a lot more vertex processing power available.
    If you're doing an isometric thing, consider actually making polygon wheat rather than alpha cards. With mesh batching it might wind up faster than dealing with that much overdraw.


    can always just whip up a test and profile it. :)
Sign In or Register to comment.