Search Unity

Tile Based Rendering Optimization 3 Years Later / Alpha Cutoff Optimization into the Future...

Discussion in 'Android' started by astracat111, Nov 9, 2019.

  1. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    Hey there guys, I wanted to ask about something...

    Basically, the way I had designed pretty much all of my projects graphically was to use an incredible amount of transparency/alpha cutoff, so back even 2 years ago this posed a kind of problem with my Samsung S6, even though I was using all pixel art, I believe it demanded 4 times the CPU if I remember correctly.

    I haven't really got a good android phone myself, but now I haven't yet tested my game on a Snapdragon 845+ or so, like the Galaxy 8 or higher. Where I would try to keep my draw calls down to 50-100, I've since given that up and allowed my draw calls to go up to 300-700 or so on average, sometimes higher, as I've decided there are certain things graphically, like lush grass and dense forests, that I just can't sacrifice.

    While I'm still practicing optimization, I'm wondering what some of your opinions might be on making heavy use of alpha cutoff when using Android these days? Do you think it even will matter anymore, say, 1 or 2 or 3 years from now considering how powerful the iPhone 11 and the Samsung Galaxy 10+ are? Just wondering what your thoughts are...

    Here's a screenshot of what I've been dealing with:
    https://tinyurl.com/yysehtyr

    As you can see every single one of those trees uses alpha cutoff, and at this point in development I'm just not willing to change it, but my thought is that phones are getting powerful enough now to run lots of screen effects and race through the alpha cutoff/tile-based rendering problem.

    P.S - as you can see from this chart:
    https://www.androidbenchmark.net/phone.php?phone=Samsung+Galaxy+S6+(Various+Models)

    The Samsung S9 is even 3 times faster graphically than the S6 and I'd imagine the S10+ could even be 4 times faster.
     
    Last edited: Nov 9, 2019
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Cutout / discard / alpha test is bad on all tiled mobile hardware. I mean, you can do it, but it's slow because it will stall the gpu for that tile until it's resolved.

    Where possible you'll get a speed gain just changing them to transparent blended, but that's a problem for triangle sorting.

    I am not aware of cutout helping CPU performance though. In any case the game looks simple, why not try it, profile go from there...
     
  3. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    @hippocoder My thought was that these days and as mobile phones get more powerful, it should become less so of a problem, especially for something that's mostly just a bunch of low-res textures. I mean, my point is, that if you're using something like an iPhone 11 Pro surely it can't hiccup THAT much these days, and certainly wouldn't be as slow as the Samsung S6 that I used years back?

    I'd still assume that far into the future tile-based rendering will still be used for mobile due to it being able to optimize most 3D games well though at a lower wattage.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,741
    Low res textures doesn't play that much role, it's mostly how much actual pixels they use on screen that's the issue, so it can be a low res texture, but if you're viewing it up close and it's full screen then it might be an issue.

    This page explained it clearly : https://developer.apple.com/library...ProgrammingGuide/Performance/Performance.html

    I can't find the equivalent page for metal (if one exists), but I'm fairly sure the same principles apply.
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Really doesn't work like that :D

    It's about triangles that overlap an invisible grid of tiles. For each triangle rendered with cutout, it'll basically do the tile all over again to resolve it, causing the gpu to opt out of hardware optimisations.

    As you say it's probably acceptable on a modern phone (but still costing performance / battery life) but it will definitely impact older devices. Why not test it?

    You could possibly consider tweaking the shader to fix it. Judging by your screenshot, your art is probably separate quads which means it's simple to change cutout to alpha blend, and modify the fragment shader so that the alpha channel for each image is tighter.

    I don't know enough about your game, but getting some testers would probably put your mind at ease. If you're looking for a direct answer about cutout well, it will work, but it is slower than transparency. So the choice is yours.
     
  6. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    Well, we'll see how it goes. I was definitely surprised as to how fast the technology actually advanced, the phones I think are more than 3 times faster now, so my thought was that development into the future I could get it all working on like an iPhone 11 now and in years to come that phone won't be considered as powerful.
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Sure, it'll be fine, just limit it to devices it will run well on (if android).
     
  8. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    I think that's the most important part. Also, for mobile, developing for mobile I would think would be easier on iOS since they don't have a variety of gpus being used.