Search Unity

Feedback Alpha vs More Vertices | Unity Performance Test

Discussion in 'General Graphics' started by FernandoMK, Apr 30, 2021.

  1. FernandoMK

    FernandoMK

    Joined:
    Feb 21, 2017
    Posts:
    178
    Hello everybody.

    This week I did a little performance test to better understand how an alpha texture affects a game's performance.

    Usually if you search on google, you will find lots of information that points out that in fact this is bad for the overall performance of any game, but I didn’t find any information about how it is affected in the SRP, so I decided to do the test myself to identify how I can correct this problem, and what was the worst use case for our team to try to avoid.

    The test below was done in version 2020.3.0f LTS. HDRP 10.3.2. with a gtx 1650 4GB.

    Vídeo:



    Control test (No objects in the scene except the camera and "floor") | 112 FPS

    (DINAMIC OBJECT)
    • TWO FACES AGAINST EACH OTHER (Represents the scenario where you add more vertices to the object to avoid using alpha) | 21 FPS
    • MATERIAL DOUBLE SIDE (Without alpha) | 31 FPS
    • TWO FACES AGAINST EACH OTHER + TEXTURE ALPHA (Represents the scenario where you add more vertices with the use of Alpha. In theory, this is the worst case scenario) | 26 FPS
    • MATERIAL DOUBLE SIDE + ALPHA TEXTURE (Common scenario for use with alpha) | 30 FPS
    (STATIC OBJECT)
    • TWO FACES AGAINST EACH OTHER (Represents the scenario where you add more vertices to the object to avoid using alpha) | 3 FPS
    • MATERIAL DOUBLE SIDE (Without alpha) | 30 FPS
    • TWO FACES AGAINST EACH OTHER + ALPHA TEXTURE (Represents the scenario where you put more vertices with the use of Alpha. In theory, it is the worst case scenario) | 4 FPS
    • MATERIAL DOUBLE SIDE + ALPHA TEXTURE (Common scenario for use with alpha) | 31 FPS

    The strange thing is that in the test I did not find any significant difference using or not using an alpha texture, something very curious that I did not expect.:eek:

    Another strange factor is that when I apply the static mode, the frame rate falls a lot on objects that have many vertices.

    But in general, this test showed that when using ALPHA, the performance may even drop a little bit, but somehow the SRP manages to stabilize that and maintain a consistent frame rate.:)
     
    Last edited: Apr 30, 2021
    valarnur likes this.
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    If you look at your stats window, this is showing the main thread showing insane numbers, but almost nothing on the render thread. This makes me think there's something else happening with that setup unrelated to rendering, like physics objects fighting or something else. I'd check the profiler to see what's taking up so much time.

    Also motion blur keeps working in all of these examples, which tells me this is alpha testing and not alpha blending. This is an important distinction, and Unity's HDRP uses some techniques to reduce the cost of a lot of overlapping alpha tested geometry.
     
    FernandoMK likes this.
  3. FernandoMK

    FernandoMK

    Joined:
    Feb 21, 2017
    Posts:
    178
    To keep the test "realistic", I decided to keep almost all the settings in the default (even those in the project tab, not least because few users know that it exists) And the blur property is activated by default... Maybe I should have removed this so as not to disturb the tests (But as this is part of HDRP by default, I chose to keep it activated)

    An important point is that I redid all of these tests in several environments (The video test was just one more of them ...) and I did the same test in an environment with the camera still, and yet this frame rate dropped. o_O
    And that happened only when I activated static, (maybe it's a bug) but to be sure I will check the profile of these examples in specific...

    But thank you very much for the answer, I didn't know that HDRP had these tricks under the hood... :D