Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Shader Graph expensive on Mobile?

Discussion in 'Shader Graph' started by SeriouslyNot, Jul 2, 2020.

  1. SeriouslyNot

    SeriouslyNot

    Joined:
    Nov 24, 2017
    Posts:
    121
    I'm using URP and i have created the following shader that produces Arc (Electricity) effect and i'm using it in my game:



    I'm using Bloom (PostProcessing) when this shader is present to give it a real Electricity look.

    Now i noticed on older Android devices, the FPS gets down from 60 to 40 when this shader is present on screen.

    Any tips on how to make it cheaper?
     
  2. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    You could try baking the noise into a texture instead of generating it with math maybe?
     
    sterneck_moritz likes this.
  3. SeriouslyNot

    SeriouslyNot

    Joined:
    Nov 24, 2017
    Posts:
    121
    But i need to keep changing the Texture because the result Arc effect is not Static.
     
  4. SeriouslyNot

    SeriouslyNot

    Joined:
    Nov 24, 2017
    Posts:
    121
    Wow, it worked!, also is it expensive to use sine(time) instead of time?

    because when i use time, the shader stops working after like 15 minutes and i have no idea why!
     
  5. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    How significant did baking the textures affect performance?

    And what did you do to have a dynamic effect, multiple textures?
     
  6. SeriouslyNot

    SeriouslyNot

    Joined:
    Nov 24, 2017
    Posts:
    121
    I made a tall static noise texture and put it in the Graph instead of Simple Noise nodes, when you attach the Tiling and Offset output to the UV input of the Texture, it scrolls and i have the same effect.

    As for performance, i did not test yet.
     
  7. SeriouslyNot

    SeriouslyNot

    Joined:
    Nov 24, 2017
    Posts:
    121
    Nope :(
     
  8. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    That sucks, I'd really like some pointers from the shadergraph team related to performance
     
  9. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Are you using already half precision?
    I see in your graph that you are using Alpha. You know transparency and overdraw can be very critical especially on older phones. How much of the screen area does this effect cover at the worst case?
     
  10. SeriouslyNot

    SeriouslyNot

    Joined:
    Nov 24, 2017
    Posts:
    121
    Yes. but not on the Mater node, i set almost every node to half, should i set the Master to half too?


    I have to use alpha, because the Arc shader does this effect: (video screenshot)

     
  11. GiyomuGames

    GiyomuGames

    Joined:
    Jan 12, 2015
    Posts:
    80
    The bloom post effect may be the culprit here. Post effects on mobile are a bit costly (even simple ones like vignette).
     
    Last edited: Jan 11, 2021
  12. sterneck_moritz

    sterneck_moritz

    Joined:
    Mar 23, 2020
    Posts:
    8
    Holy Cow... that was it. Thanks!

    I had 2 different shaders which 'just' did some texture scrolling/noise magic on SpriteRenderers. But full closure: they were spanning over the whole screen, had Transparency and I'm on Mobile with the URP Bloom enabled. So not really the best setup to start with... Anyways, I would get juuust under 30fps, which was really strange considering I'm on a High-End Mobile (apparently) and there's not too much else going on in the screen except the things I described.

    Swapped the dynamic noise generation in the shadergraph via Gradient Noise Node to a static baked Noise Texture and damn all of a sudden it stays above 50fps!
     
    alexanderameye likes this.