Search Unity

Mobile Shader / Lightweight Rnder Pipeline FPS Comparison

Discussion in 'Shaders' started by Saturn1004, Aug 15, 2018.

  1. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    Test Summary:

    #Edit: I went back and toggled on MipMaps for the textures on the ships and got a massive performance gain... The same scene ran at 30 FPS+ with mip maps enabled that ran at 2 FPS without. I had no idea MipMaps were so important.

    I've been doing some real world tests of Unity's default Mobile Shaders and the new Lightweight Render Pipeline for an Android game I'm making and I figured I'd share the results since there are such drastic differences in FPS in my tests. Maybe it can help someone out.
    I will also test Non-Mobile Shaders and Legacy Shaders just to see how they compare.

    This is using unity 2018.2 and a Samsung Galaxy S4.

    Here's the test setup:

    24 Space Ships with around 10k polys each and 2048x2048 Textures / 2048x2048 Normals (on shaders that use normals) with a simple bobbing up and down animation.

    Everything remains the same in all tests except the shader used.
    All shaders have GPU Instancing enabled.

    The Data:

    Standard:
    Diffuse + NormalMap only, Specular highlights on, Reflections off - 12 FPS
    Diffuse + NormalMap only, Specular highlights off, Reflections off - 13 FPS

    Mobile Shaders:
    Mobile / Diffuse - 22 FPS
    Mobile / Bumped Diffuse - 15 FPS
    Mobile / Bumped Specular - 13 FPS (best performance with shininess)
    Mobile / Bumped Specular (1 Directional Lights) - 8 FPS (God this is what I was using before this test. WORSE than the Standard PC shader with specular highlights.)
    Mobile / Unlit - 15 FPS (How is it this bad?)
    Mobile / VertexLit - 26 fps! (Winner for best performance in my test, no Normalmap or shininess)
    Mobile / VertexLit (1 Directional Lights) - 13 FPS

    Unlit:
    Unlit / Texture - 16 FPS

    Legacy: (Didn't expect them to be good)
    Legacy Shaders / Bumped Diffuse - 10 FPS
    Legacy Shaders / Diffuse Fast - 24 FPS
    Legacy Shaders / Specular - 17 FPS (Surprisingly high)

    Digesting the results:

    One misconception I had was that the 1 Directional Lights versions of shaders were higher performance versions that didn't work with point lights or spot lights.
    I don't exactly know what these variants do under the hood, but in a real world scenario they get HALF the framerate of their non-(1 Directional Lights) variants. These were the shaders I was using in my game before these tests for this precieved performance gain in my 1 Directional Light only scene. Turns out I was losing FPS for no quality gain.

    I found Mobile/VertexLit to be the most performant of all the shaders I tested and will be using it for the things that don't need Normal Maps or shininess. I will also be using it for my lower LOD levels.

    I see zero reason for Mobile/Unlit's existence based on these results.

    Good thing I didn't automatically use Mobile/Unlit assuming "surely Unlit is more performant than VertexLit".

    Lightweight Render Pipeline:

    This one was a real shocker for me:
    Lightweight Render Pipeline (Standard) - 2 FPS

    Updated with tests from Simple LRP shader:
    Lightweight Render Pipeline (Simple with specular) - 5 FPS
    Lightweight Render Pipeline (Simple without specular) - 4 FPS
    Lightweight Render Pipeline (Standard Unlit) - 13 FPS

    So hang on a second... LRP gets 2 FPS on my phone but Standard gets 12 FPS?
    I thought the LRP was built to be MORE performant than Standard for VR and such?


    I assumed the LRP was a lot more mobile friendly than it is.
    My message to anyone thinking of upgrading to the lightweight render pipeline:
    Test both the mobile shaders and the LRP and see if LRP is a good idea.

    LRP does support a lot more options than mobile shaders which are quite basic, so if the FPS isn't a huge deal for you and your scenes are extremely basic you might be able to get by with LRP and better graphics. But I have to say I'm a bit disappointed in LRP's performance. Hopefully they'll improve it because it seemed like a huge step forward for unity on mobile and VR.

    Final Words:

    These tests obviously don't apply to all devices, but mine is a pretty standard albeit outdated mobile device in 2018.

    Also I guess don't assume something is more performant because it sounds like it would be.
    Test it.

    Here's the website for the game I'm doing these tests for in case anyone cares:
    https://nullreferencegames.com/exoplanets-online/
     
    Last edited: Dec 28, 2018
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    I was wondering if you could also profile and post the details :p
     
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    Which shader from LWRP did you use?
     
  4. Tonieh085

    Tonieh085

    Joined:
    Nov 25, 2016
    Posts:
    14
    Hi, I have a similar problem / question.
    I'm working in a toy game for mid-range to high-end phones. I tested with 20 bears (a lot of polys) and I thought that using my own Unlit material will increase the performance comparing to the LWRP standard material but it's exacly the same.

    Why I have this results? I thought that the Unlit material would be less expensive for the graphics.

    bears.png SHADER.png
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    The answer is: use the profiler to figure out what's happening.

    There are many possibilities here, one of them being "you're not fragment shader bound".

    EDIT: that's a highly likely reason for this behaviour, but only a profiler can tell you what is going on.
     
  6. Tonieh085

    Tonieh085

    Joined:
    Nov 25, 2016
    Posts:
    14
    The "Gfx.WaitForPresent" use arround 70-80%
    I'm testing with a mid-range phone (huawei p10 lite)
     
    Last edited: Aug 22, 2018
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    This just means that the GPU is taking a lot of time to complete a frame.

    Do you get 60 FPS if you reduce the amount of bears rendered?
    Or if you restrict the texture size to some small value (e.g. 256x256)?
    How many triangles do you have in your scene?
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    Judging by the FPS you got, you used the Standard (Physically Based) shader. It's not suited for old devices, such as the one you tested with.
    Try using the Standard (Simple Lighting) shader instead.
     
  9. Tonieh085

    Tonieh085

    Joined:
    Nov 25, 2016
    Posts:
    14
    The problem was the textures, my bad... didn't thought that the texture resolution affects the performance like that.
    Now I got 60fps with 100k triangles
    Thanks for all
     
  10. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    Yeah, I might have. I'll go back and test the simple lighting version and add the results to the original post.
    Edit after tests:
    Okay I ran the test again with LRP (Simple) with everything I know of turned to lowest possible settings. (Vertex lighting disabled, Depth texture disabled, Opaque texture disabled, Anti-aliasing disabled, dynamic batching enabled, shadows disabled) and I still got around 4 FPS...
    With standard unlit I got 13 FPS.

    Maybe LRP only runs better than Standard shaders on newer devices?
     
    Last edited: Sep 10, 2018
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    Not according to our tests.
    Can you please submit a bugreport?

    By the way, which Galaxy S4 are you testing on? There are several modifications with different GPUs.
     
  12. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    Model SCH-I545 UD
    Completely stock and relatively low hours used for it's age. I wish I had more devices to run the same test on but I don't... sorry.
    Just out of curiosity, I assume during your tests Mobile shaders (like mobile bumped diffuse) are still more performant than LRP (Simple Lighting, lowest settings) correct? Or during your tests is LRP actually more performant than mobile shaders? I would assume less performant since it can do more?
     
    Last edited: Sep 11, 2018
  13. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    Thanks!
    If you submit a bugreport, we can test it on more devices and see if this is specific to this device or not :)

    The Standard (Simplified Lighting) shader in LWRP is supposed to be a replacement for the regular Standard shader, and they will have the same functionality at some point. The LWRP shader will be faster than the regular Standard shader (with lowest settings).

    As for the legacy and mobile shaders, I suppose that turning some features off on the LWRP Standard shader can bring it close to them. When we do the next optimization pass, we can try squeezing more out of it :)
     
  14. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Hey @SaturnCO

    Thanks for sharing your results. Let me address some of your points

    Some of your numbers seem off. Take this as example, the only difference from (1 directional) is that it doesn't shade additional lights in SH/vertex. From what I can tell it should be equal if you only have a single directional light in your scene or better if you have more lights.

    When doing profiling on mobile remember to let the device cool off for a few minutes in between tests. The reason is that mobile devices don't have active cooling, the way the avoid overheating is by clocking down the CPU/GPU and this severely impact performance tests.

    It seems you are comparing LWRP (simple) vs Unlit which is not a fair comparison. Just the fact of having normal mapping on these old GPUs can consume lots of ms of your frame time.

    Like @aleksandrk said, we will definitely do another optimization pass on our Simple Lighting shader. Like you said there are a few extra option in the Simple Lighting than in the mobile ones. It's something we need to discuss.
     
  15. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    Alright, I'll submit a bug report I guess.
    I started this trying to be helpful, not to be complainy. =p

    I only had a single One-Directional Light in the scene when testing, so I'm not exactly sure why one directional variants performed worse than their non-one directional counterparts. Like you say it should be the same. (or better if there are directional lights.)
    Each test was so short and I did build and run between each test so heat shouldn't have played much of a role.

    When I said Standard Unlit I meant the Standard Unlit version of the LRP shader, sorry.

    When I tested Standard Shaders it was lit (Diffuse + Normal) and LRP (Simple, Diffuse + Normal only), both with a single one directional light, standard ran at 13 FPS and LRP (Simple) ran at 4 FPS. (same model, same textures) So I think that's a pretty fair test. Could just be device specific like @aleksandrk said. The S4 is getting pretty old now.

    Edit:
    The craziest thing to me is I toggled on MipMaps on the ship textures and my framerate jumped to 30 FPS+ for LRP and every other shader. I had no idea MipMaps helped that much...
    With MipMaps enabled, LRP (simple) (37 FPS) outperforms old Standard shader (29 FPS). Strange that without mipmaps LRP performs worse than standard, and with mip maps it performs better as you would expect.
     
    Last edited: Sep 13, 2018
  16. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    Mipmaps reduce memory bandwidth requirements, which helps a lot in many cases.
     
  17. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Hey @SaturnCO all feedback is welcome. Feel free to submit a bug report and we can investigate.
     
  18. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @SaturnCO thanks for testing. Would be great if you could update your original post with your new numbers with mipmaps - my takeaway after reading the whole discussion is "things work as one would expect - LWRP is faster than Standard", is that correct?
     
  19. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    When I first tested without mip-maps, LWRP actually ran slower than Standard Shader for whatever reason. (mobile)
    After enabling mip-maps however LWRP outperformed Standard Shader as expected.

    I guess the takeaway is:
    1: Mip-Maps for textures on 3D objects are a must-have.
    2: If you're aiming for super-performant mobile and don't care so much about quality you still might want to think about using Vertex-lit mobile shaders, or one of the mobile-diffuse shaders. (you can still add tint and stuff to these manually)
    If you want higher quality/lower performance than mobile shaders with more options built in, LWRP is more performant than the standard shader for mobile, and looks almost as good.

    I will probably be switching to LWRP at some point, but since all old custom shaders no longer work with the new render pipelines, that is one big downside. It will probably take some time for all the custom shaders in the asset store to be recreated in some fashion with shader graph for the new pipelines.
    (Specifically There's a planet shader I'm having a hard time recreating quite as well in shader graph for LWRP as the amplify shader version I'm currently using.)
    So, if you need unique custom LWRP shaders for your project you may be looking at making them yourself. (for now)
     
    tree_arb, AlanPT, ROBYER1 and 2 others like this.