Search Unity

How to get good performance with realtime lighting on mobile

Discussion in 'General Graphics' started by Vefery, Apr 27, 2019.

  1. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    26
    Hi, I'm developing low-poly 3d side scroller on mobile. Now I have one realtime dir. light and both realtime lighting and mixed lightning disabled in lightning settings. Scene isn't big, no terrain, since it's low poly, every object use the same material, so everything batched. And still I can get 60 fps only on lowest settings in HD resolution. On medium settings in FHD (my phone's native resolution) fps drops to 30 and on Ultra with shadows and FHD it drops to ~25.
    But my phone had snapdragon 625, which is quite powerful CPU. I can run games such as CASE: Animatronics on Ultra with FHD, GTA SA in Ultra, etc.
    I don't use backed lighting because of size problem, the game suppose to have 50+ levels and baking light for every level wouldn't be effective.
    Does anyone have experience in developing realtime lighting mobile games?
     
  2. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,006
    Mobile devices are normally capped at 60 fps.

    Unless you want to turn the phone to a heater and drain the battery really fast, you should target 30 fps or lower instead. Newer phones feature something named thermal throttling, means if you run your game at 60 fps, it becomes really warm and then the performance is throttled to lets say 20 fps. Nothing you can do against, thus you want to avoid running in thermal issues.

    Running games at 30 fps or lower where possible it what mobile games often do. You still want to optimize the hell out of it to be able to run at 60 fps in theory, but then limit it to 30 fps instead. This way your game is 50% in idle and hopefully won't cause the device to heat up. Epic did this with Fortnite mobile, see video below.

    Lectures of interest...


     
    Vefery likes this.
  3. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    37
    Reltime shadows?
     
  4. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    26
    Thanks for reply!
    I didn't mean that I want more than 60 fps, I want stable 60 fps on low-medium settings
    Also I've never seen 3d games capped at 30 fps, it usually runs at 60
     
  5. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    26
    Only on the highest quality settings
     
  6. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    37
    Realtime shadows and standard shader are most often cause performance problems on mobile.
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,453
    I've been doing mobile games since 2010 so some experiences:
    • baking lightmaps for every level is the correct way to do mobile. crunch and other compression strategies reduce lightmaps to almost nothing, especially if you use small lightmaps or light using lightprobes (saves even more).
    • transparency is OK on mobile but attempt to reduce overlaps (few big is better than lots of small) and ensure the shader for any transparent rendering is kept very, very simple - just vert/frag minimal.
    • Post effects should either be custom or made by yourself.
    • I did this app with full spec with my own pbr invention just by multiplying combined maps together with some made up math. Stripped down custom shaders are the best for performance. Vignetting is 4 meshes in the corners with vert colouring:
     
  8. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    26
    Thanks for tips! Could you share your experience about lightmap baking? Because I've tried to bake level with progressive lightmaper, lowest settings, compressed lightmap and awful result, I've got 17mb lightmap. It's too big for 50+ levels game
     
  9. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    26
    Forgot to mention - I use Mobile/Diffuse shader
     
  10. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,006
    Why don't you just connect a CPU and GPU Profiler to your game and let those tools tell you exactly what is causing this performance issue?
     
  11. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    26
    Because it shows me that rendering image uses almost nothing, about 5% of all power. But in built I can see the opposite
     
  12. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,006
    Can you elaborate on this?

    You connect those Profiler tools to your game, that is running on the target device (phone) and it reports 5% is spent in "rendering image"? 5% where, CPU or GPU? Where are the remaining 95% being spent? Where do you get those "opposite" numbers from?