Search Unity

Question Transparent vs Opaque Sprites with more triangles

Discussion in 'General Graphics' started by Raial, Jul 18, 2020.

  1. Raial

    Raial

    Joined:
    May 2, 2017
    Posts:
    24
    Hi!

    When dealing with pixel-perfect sprites, you can adjust the outlines for rendering them with or without transparent zones:

    Normal Outline -->
    without-outline.PNG

    Fitted Outline -->
    with-outline.PNG


    When outlining correctly the sprite, I can use a non-transparent shader (better performance) for rendering it, but at the cost of more triangles drawn (80 triangles vs 12 triangles for the transparent sprite):

    triangles.PNG

    What option is better for mobile performance or performance in general?
     
  2. Bosozuki

    Bosozuki

    Joined:
    Dec 19, 2013
    Posts:
    63
    Sadly the answer is "It depends"

    As a side note there is a video on the unreal engine learn portal that goes into detail of this specific topic that is general for all 3D engines. There is a visual profile tool they have that shows what happens. There may be something similar in the frame debugger for unity but I have not looked.

    Questions you have to ask:

    Are you using deferred or forward?

    How many of these sprites will overlap? This is important for deferred

    How many of these sprites will be on the screen at one time? 5, 10000, 1 million?

    Are these sprites animated?

    If the sprites overlap do you have cases were there is no overlap and then lots of sprites overlap very quickly?

    Probably the next step would be to test on your lowest supported platform and profile some simple extreme cases with both types of sprites to give you an idea of performance.