Search Unity

Standard Shader Vs Mobile Diffuse Shader

Discussion in 'Shaders' started by siddharth3322, Mar 26, 2019.

  1. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    As per current mobile devices configuration which shader is better to use? I am losing framerates as per my current gameplay setup so I am thinking and applying different approaches to get better performance in the game.

    So in this process, one thing I noticed that all models by default using Standard shaders and I was using them to run on mobile devices.

    circuit_road_standard_shader.png

    Like this way, I got all models with by default materials and standard shader attached. Each scene contains so many low poly models those in the combine generate a stadium, city streets and mountain environments.

    At present, I was getting 30 FPS around on multiple android devices. Whether shader will create any improvement, if I switch to Mobile diffuse shader?

    Here is game profile data:
    car_game_profiler_data.png

    Please give me some suggestion on this so I can improve game performance.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You're looking at CPU times. What shader you use will have little impact on the CPU times since they run on the GPU, unless the CPU times are spiking because it's waiting on the GPU. Look at the profiler to see if Gfx.WaitForPresent is at the top. If so, a shader change might help, or you might just be rendering too much stuff, which a shader change won't help too much with.
     
    siddharth3322 likes this.
  3. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    Above profile data get generated using this environment rendering.
    car_game_city_env.png

    Still, 10 low poly cars were moving on the track, one controlled by a human player and other driven by AI.
    This kind of detailing exists in cars 3d models.

    car_detailing.png

    Please provide me more information so I can improve game performance.
    At present, all 3d objects have default shader and material applied when I imported within the Unity game engine.
     
  4. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    Also, I am not sure, whether its number of polygons that affecting the performance or shader !!
    So I have above attached my car overall polygons details and environment layout.
    Total 3 different environments, I have in the game but it's mostly of the same type.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Poly count will, for the most part, not be a factor here regarding CPU time usage while rendering. A mesh with 65k triangles takes the CPU just as long as a mesh with 2 as it is just telling the GPU which already uploaded mesh to use. Again, look at the profiler to see what is taking time.

    In the profiler screenshot you posted the render thread is spinning on "Gfx.WaitForCommands". That means the CPU is doing something, which is stalling everything else. Could be garbage collection, could be you've got some massively inefficient gameplay code that occasionally spikes, could even be the OS itself is stealing CPU cycles on something unrelated and making your timings look terrible, no idea what, but the rendering side feels like a red herring.
     
    siddharth3322 likes this.
  6. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    So as per your suggestion, shaders and number polygons are not an issue for me.
    Something running other in code or any other kind of effects related things - that is causing a performance problem for the game. Am I right?

    I have 3 environments for gameplay and I have setup them as a prefab to load during every gameplay, rather than using 3 different scenes within the game. I have kept a single scene and loaded different game environments using their prefab. Also, all 10 cars having their skid effect, their smoke particles and their collision blinking animation too.
    What do you think? these impact in game performance...
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    No idea. Look at the profiler.
     
  8. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    I don't know what is meaning of profiler data!!
    Which thing is pointing towards which issue...
     
  9. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Change the bottom window from timeline to heirarchical, sort by time, look at what's taking the most time, search on Google.
     
    siddharth3322 likes this.
  10. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    Yes thank you for giving me the guidance :)
     
    SeanSmith01 likes this.
  11. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    @bgolus
    Updating renderer bounding volumes taking too much time so what is the cause behind this?
    I can't able to sort out the meaning of this!!


    update_renderer_bounding_volumes.png

    Another Canvas Build Batch is showing so many big spikes:
    canvas_build_batch.png
     
    Last edited: Mar 29, 2019
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Crazy high spikes like that in otherwise consistent processes without anything obvious happening elsewhere (like spawning a few thousand objects for one frame) likely means something on your PC completely unrelated to Unity is causing the problem. Could be hardware, could be software, no idea. My off the cuff guess is your RAM or power supply is dying
     
  13. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    But I am using iMac with i5 processor, 12GB of RAM and 1 GB graphics card and 512GB SSD installed.
    So I don't think, external things can generate a problem for me.

    By reading above statistics, can you give me idea about the problem?
     
  14. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    siddharth3322 likes this.
  15. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
  16. juelzsantana123

    juelzsantana123

    Joined:
    Feb 28, 2019
    Posts:
    17
    Mark objects static and bake light. Realtime light may cause drop performance. So you have 2 direct light in your scene.