Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Discussion Unity 5 to Unity 2024 android performance tips

Discussion in 'Android' started by UnityLighting, Oct 23, 2016.

  1. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,082
    For what concern the shadows, isn't better to bake all the shadows for static objects?
     
  2. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    1.Baking some objects like trees are not possible and the quality is too low
    2.Game apk size will be larger
    3. Realtime lights are more alive and shaders can have more properties
    4. Day time cycle
    5. I have a realtime terrain deformation system. Baked lighting can not be used because the holes must has shadows to be visible
     
  3. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,082
    Even for large environment? I have a 3x3 km outdoor off road environment where I planned to bake all lights for static objects.
     
  4. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    Shadows are depending on the distance of the shadows and the how many objects that has shadows

    note 1 : change shadow distance from URP asset
    or from Edit->Quality settings for built-in pipeline)

    note 2 : Disable cast shadows for non important models from mesh renderer component

    note 3 : Cull shadows for far and small objects using this class

    note 4 : Use shadow cascades method
     
  5. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    Soft shadows in high quality and distance 210 (URP high preset) :
    25% performance cost

    Post Effects (tonemapping, Color adjustment, lift gamma gain, Vignette):
    20% performance cost

    Bloom:
    2~3% performance cost

    So:
    When you turn on Shadows, your 30 fps will be ~23 fps
    When you turn on Color Grading, your 30 fps will be ~24 fps
    When you turn on Bloom, your 30 fps will be ~29 fps
    When you turn on all effects , your 30 fps will be ~17 fps
    When you turn on all effects on 50% resolution scale, you will get 30fps

    Target test device: Redmi 9A (100$ ~ 150$ phone) at native resolution
    RAM: 2gb GPU: PowerVR GE8320

    When you use the 50% of the resolution density, your fps will be 30 fps...
    So the best way to optimize game is using lower resolution

    Also i am working to upload a quality choose toolkit for free on the asset store

    Download and test the Demo APK on your own device


    3.jpg
    213.jpg
     
    Last edited: Feb 2, 2022
  6. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,082
    mmmh not sure I got why you dont suggest baking lights.. the only drawback I see is increase apk size.
     
  7. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    I Suggest the both... As i said you can use realtime light(only sun light) for some purposes as i said above

    As i said, my deformation system needs the realtime lighting to be visible
     
  8. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    Baked Lighting vs Realtime Lighting with shadows
    Redmi 9A in the built-in pipeline:
    Note: low fps is result of the 700.000 triangles. Your game must has less than 100.000 triangles for mobile platforms
    1.jpg
    2.jpg

    Gif Comparison:
    Baked vs Realtime.gif
     
  9. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,082
    So baked version is almost 50% faster than the real-time version
     
  10. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    Game Quality Settings for built-in pipeline:

    Download From Asset Store

    Game Quality Settings for URP pipeline:

    Download From Asset Store

    Note: Target is mobile devices

    Note: You must import post processing from package manager for built-in pipeline

    photo_2022-02-11_17-35-57.jpg
    photo_2022-02-11_17-36-01.jpg
     
  11. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    Unity Lightmap vs Realtime Lighting Performance
    Redmi 9A

     
  12. sivabalan12

    sivabalan12

    Joined:
    Jul 5, 2019
    Posts:
    11
    @UnityLighting hi, why soft shadows not working in mobile, i need this because, hard shadows at low resolution looks pixelated.
    And why post processing - ambient occlusion not working in mobile but works in editor (built-in pipeline)
     
  13. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    hi, just ell me the device model
     
  14. sivabalan12

    sivabalan12

    Joined:
    Jul 5, 2019
    Posts:
    11
    Infinix hot 8
     
  15. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    sivabalan12 likes this.
  16. sivabalan12

    sivabalan12

    Joined:
    Jul 5, 2019
    Posts:
    11
  17. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    Share the result
     
    sivabalan12 likes this.
  18. Brother_77

    Brother_77

    Joined:
    Feb 8, 2019
    Posts:
    241
    As this post comes first in the google search under "Optimize for mobile".

    This thread is very educational on its own ++

    would like to add:
    Unity's official blog on this topic, it also provides an even more detailed free e-book on the topic.

    I wish I found it many hours ago, hope this helps someone.

    https://blog.unity.com/technology/o...m1NtZxlV_wp7c6JuBK3nH9awpXpI6aYEQbXzOXVwgsTQQ



    + I recommend this free FPS counter

    https://assetstore.unity.com/packag...ate-fps-counter-stats-monitor-debugger-105778
     
    Last edited: Mar 8, 2022
    leandrovtd likes this.
  19. VoodooDetective

    VoodooDetective

    Joined:
    Oct 11, 2019
    Posts:
    239
    It seems like Screen.resolutions doesn't function on android devices. What's the best practice for deciding on a list of acceptable resolutions to present to players? Should we just generate a list based on the Display.main.systemWidth/height. 90, 80, 70, etc percent of normal? Is there a better way?
     
  20. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    I have a solution in my Quality Selection tools
    First save the original screen resolution in the first time running of game (save into the unity's playerprefs)
    Then divide it into the 1.0 , 0.7 , 0.5 , 0.3
     
  21. Hyperion90

    Hyperion90

    Joined:
    Dec 12, 2014
    Posts:
    14
    If I understood correctly, you are using a combination of the code mentioned in the first posts (the one with setting the resolution to a lower one), AND setting the Render Scale to some value below 1.0?

    Would my mobile game's performance benefit from a combination of these two, or do they actually do the same thing?
     
  22. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    I just reduce the render scale by my own code. This makes your game playable on any device
     
    tmonestudio likes this.
  23. Hyperion90

    Hyperion90

    Joined:
    Dec 12, 2014
    Posts:
    14
    Sounds good, thanks for answering. Also, congratulations and thank you for the extremely useful tips in this topic!
     
  24. jubaerjams8548

    jubaerjams8548

    Joined:
    Jun 8, 2020
    Posts:
    41
  25. AshwinTheGammer

    AshwinTheGammer

    Joined:
    Sep 23, 2016
    Posts:
    69
  26. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,913
    The best and easy to use LOD Maker is the Unreal Engine's model viewer...

    Tested on the UE 4.026 and UE 5.0.3

    Watch the video:




    _______________________________________
    How to bake normal map and OC map into the base map: