Search Unity

Bad performance with Unity 2019.2b LWRP 2d point lights on mobile

Discussion in '2D' started by Yawnn, Jul 27, 2019.

  1. Yawnn

    Yawnn

    Joined:
    Jan 14, 2018
    Posts:
    2
    Hello,

    I have a bit problem. I'm using the new 2d lighting from the LWRP in 2019.2b. I'm making a game where two 2d point lights follows the player around, unfortunately this greatly decreases the performance of my game on mobile.

    I'm using two point lights, one for the enemys and player and one for the background (which is a bit less bright then the light for the enemys and players).

    Do you have any idea on how to increase performance, or can't you increase the performance?



     
    Last edited: Jul 27, 2019
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    This came up in the following thread a while ago:
    https://forum.unity.com/threads/2d-renderer-and-baking-lights.712475/

    Unity's replied with:
     
    Last edited: Jun 10, 2020
    DungDajHjep likes this.
  3. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    We've conducted some performance testing on some of the mobile devices we have, and found out we're mostly bound by GPU memory bandwidth. We have some tangible ideas on how we can improve, but for now try reducing the Render Texture Scale of the Light Blend Style you're using. That should give you noticeable performance boost.
     
  4. Scott-Steffes

    Scott-Steffes

    Joined:
    Dec 31, 2013
    Posts:
    59
    Have the performance characteristics of the 2D lights improved since the previous post?
    I'm considering using the 2D lighting system in a professional game, would you advise this?
     
  5. grolschie

    grolschie

    Joined:
    Nov 19, 2019
    Posts:
    3
    As of 6.9.2 (default settings), nope. Adding 2 lights (1x global, 1x point) and my game performance bottoms out.
     
    mGMM likes this.
  6. prabhukaran

    prabhukaran

    Joined:
    May 5, 2019
    Posts:
    17
    Is there any solution for this? I too experience low fps when deployed in android. LWRP looks promising but these issues made this sick.
     
    bas-interactive likes this.
  7. deckercj28

    deckercj28

    Joined:
    Sep 27, 2018
    Posts:
    4
    Hey, I'm also facing an issue with performance, and really hoping someone has a recommendation please!

    Right now, I'm in version 2019.2.18f1 but this same issue happens with 2019.3 as well.

    I have a scene where I'm using three 2D point lights but each have one or more target layers:

    1) The target layers are my ground, background and my player, and the range covers my entire scene.
    2) The target layer is the interior of a building, my player and the range just covers the building.
    3) The target layers are a secret passage and my player and the range covers the secret passage.

    I'm facing an issue that spawns when I add a combination of #2 and #3, or when I just add #1, or if I add all 3 point lights. What happens is the velocity of my character movement actually increases dramatically, but this only happens on mobile (I've only tested Android) and the velocity does not increase in the editor. Am I doing something wrong with how I should be handling this new light system in the pipeline? @yuanxing_cai would you know of any other workaround for this, or what I may be doing wrong?
     
    Last edited: Jan 30, 2020
  8. mnenad

    mnenad

    Joined:
    Dec 7, 2015
    Posts:
    18
    @yuanxing_cai Any news/updates on this topic? I have a scene with plenty 2d lights rendered on one or (rarely) more than one layer. I deployed it for iOS --> Pretty decent, no huge impact even on older iPhone models in fps after a little tweaking around with the target fps. But on Android I get huge performance knockdowns. It becomes unplayable basically.
     
    DungDajHjep likes this.
  9. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    The lights should have no impact at all on your character movement. They do potentially affect FPS, but your character movement should be FPS independent. Do you time your movement speed by Time.deltaTime in your character controller script?
     
  10. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Did it run badly on all Android devices you've tested, or just a few specific ones?
     
  11. mnenad

    mnenad

    Joined:
    Dec 7, 2015
    Posts:
    18
    @yuanxing_cai it did run badly on several, but I've also been using an excessive amount of 2d point lights that I've reduced massively now. Fact: The performance is getting better with each deactivated light source - but the performance hit it still fairly high.
     
    wlwl2 likes this.
  12. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    When you say an excessive amount, how many are we talking about exactly?
     
  13. marcola_gt

    marcola_gt

    Joined:
    Apr 19, 2017
    Posts:
    6
    I'm using here the General Renderer with 2D lights. I have a point light following my player (child game object), 6 freeform lights spread in the level (but only 2 close to each other) and a global light. Since I have put this lighting setup the game has FPS drop on a AMD 6300 (6 cores) 3.5GHz, 8GB RAM with an onboard video card (a friend testing the game). Before using the lights the game was playing smoothly in this setup. Is this supposed to happen?
     
  14. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    How many blend styles do you actively use and how many sorting layers do you have?
     
  15. mnenad

    mnenad

    Joined:
    Dec 7, 2015
    Posts:
    18
    @yuanxing_cai I was using 2 blend modes (default one and one where I lowered everything to a minimum to get the best performance out of it) and I, how I mentioned, had about 6 or 7 layers in use (usually a light was only affecting 1 layer)
     
  16. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Any chance you can reduce the number of sorting layers in use? Because each unique layer adds significant overhead to the system.
     
  17. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    202
    LWRP with post processing is x2 performance compared to URP, so maybe i will drop unity light2d. Why don't we have the independent 2D light package?
     
  18. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    You reposted this twice already. How about not littering threads everywhere with this?

    https://forum.unity.com/posts/5967317/
    https://forum.unity.com/posts/5967296/

    It won't help get your point across.
     
    DungDajHjep likes this.
  19. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    202
    Do you believe that ? I achieved> 60 fps on a mobile samsung s7 with LWRP and some 3d lights, and it works with tile map as well as sprite renderer, just set z position = -2.5. So URP still really bad.
     
  20. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    The 2D lighting system is not just 2D lights, there's also a big chunk of code on the render pipeline side that controls how the lights are rendered. That's why we can't have an independent 2D Lights package. The lighting system has to be part of the render pipeline.
     
  21. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    How much slower is it if you set up a similar scene with 2D lights and the 2D Renderer?
     
  22. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    202
    Project setup with 3 light point, 2 sprite renderer and one small tile map.

    URP: Without Multithreaded rendering and Graphics Jobs, its 2x-40 fps, and if enabled, it reaches 3x-55 fps, alway make phone warm, spend too more CPU.
    LWRP: (with light point 3d) is alway reaches 6x fps, not warm the phone and not spend too more CPU.

    P/s: The shadowcaster2d code still creates garbage in the "shadowncaster search from transform parent", and we really don't need to do that, or call it once.
     
    Last edited: Jun 15, 2020
  23. diego-vieira

    diego-vieira

    Joined:
    Mar 27, 2015
    Posts:
    32
    The performance of 2D Lights are REALLY bad and can't be used in a serious game, I have a MMORPG with a big map. I placed about 30 Lights over the map and it's just unusable on PCs! Can't even think about mobile! It's like even the lights outside the camera are rendering! I tried make a script to enable only the lights the players are seeing, but seems like the pipeline keep doing something even when the Light2D script are disabled.
     
    DungDajHjep likes this.
  24. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    The original post seems like a year ago. And this is still the problem.. oh man.. when can we expect some improvements and move on from this?
     
  25. Starsmiao

    Starsmiao

    Joined:
    Aug 14, 2019
    Posts:
    10
    In 2020.1 still having this problem,I think Unity forget the 2D Renderer...
     
    Last edited: Oct 13, 2020
    DungDajHjep likes this.
  26. rneeleshreddy

    rneeleshreddy

    Joined:
    Aug 3, 2019
    Posts:
    1
    i am still having issues in 2020.1, adding 2D renderer decrease my fps by 50%, anyone using 2d lights without any issues?
     
  27. stevenx

    stevenx

    Joined:
    Jun 7, 2015
    Posts:
    11
    I'm using unity 2019.4.14fc1 and yes the performance of 2D light is seriously BAD!
    My 2D game can only run on some high-end PCs at 60fps, if the target PC doesn't have a model graphics card(like 1060), the fps will just drop to 15!!
    Please do something, Unity team thanks!
     
    wlwl2 likes this.
  28. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Hi All! I want to let you know that we have implemented quite a number of performance improvements to the 2D Renderer for Unity 2021. One of them is optimized GPU memory bandwidth usage, which should help with frame rates on mobile devices.
     
    Starsmiao, wlwl2, NotaNaN and 3 others like this.
  29. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Will it also help platform such as Switch as well?
     
    frommars94 likes this.
  30. frommars94

    frommars94

    Joined:
    May 28, 2018
    Posts:
    8
    Good news!
    But unity ver. 2021.1 alpha (newest available at this time) support this new optimization features and improvements which u are talking about? Or this improvements will appear in later versions? If "yes" on first, i should test it, because returning to 3d lights is bad solution for me :(
     
    castor76 likes this.
  31. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I would VERY much like to know this as well.
     
    frommars94 likes this.
  32. killmark5550

    killmark5550

    Joined:
    Aug 30, 2020
    Posts:
    3
    I would like to know if the newest versions of Unity have this implemented yet. I am having a lot of issues on building 2D games on Mobile Platforms. 1x Global light and some Point lights really slow down the game to the point that it is unplayable on some devices.
     
    DungDajHjep, wlwl2 and frommars94 like this.
  33. wlwl2

    wlwl2

    Joined:
    Jun 17, 2018
    Posts:
    29
    @yuanxing_cai Is it possible to make the perf improvements backwards compatible to Unity 2019.4 LTS? :)
     
  34. Shuyin76

    Shuyin76

    Joined:
    Aug 1, 2014
    Posts:
    5
    I'm in search for some news about 2D lights and URP !
    Is the latest unity 2021 Beta release optimised with 2D light ?
    I'm creating a 2d game with background scrolling and one point light as well as some ponctual light points and the FPS of my game is just abnormally low...
    I'm using a lot of custom layers on my sprite for ease purpose. will the 2021 beta release solve my problem ?

    THanks a lot.

    Clément.
     
    frommars94 likes this.
  35. lorenzoteslermabe

    lorenzoteslermabe

    Joined:
    Dec 23, 2020
    Posts:
    24
    Please, I would also love to know what versions of Unity these optimizations will be available on! I'm desperately wanting to upgrade to URP, but am just waiting for the "green light"
     
    frommars94 likes this.
  36. andiB

    andiB

    Joined:
    Jan 13, 2013
    Posts:
    26
    Just switched my project to URP in order to use 2d lights and I also got major performance hits (about 40fs) when enabling 3 point lights in my scene. Are there any optimizations I could do out of the box?
     
  37. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    Are you trying on 2021? The latest iterations of the 2D Renderer have mobile performance improvements.

    The quickest thing to do is to reduce the size of the light's render texture scale - see the 2D Renderer asset.
     
  38. lorenzoteslermabe

    lorenzoteslermabe

    Joined:
    Dec 23, 2020
    Posts:
    24
    Same name ahah hello there.. Do you think I'm ok on 2020? I know that unity improved 2D lights quite a bit from 2019 -> 2020, but from the release notes it looks like 2020 -> 2021 brings equal if not greater 2D improvements. I'm likely targeting Nintendo switch at the lowest end so should be fine I would think (hope)
     
  39. VoodooDetective

    VoodooDetective

    Joined:
    Oct 11, 2019
    Posts:
    239
    Is the 2D Renderer safe to use with Unity 2019 in production yet?
     
  40. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    It was experimental in 2019 and is still experimental in 2021, so I would expect that if it does leave experimental status it will do so for the latest version of Unity and that's unlikely to be backported to years-old Unity versions (2019). It's 'safe' to use in that there aren't catastrophic bugs that I'm aware of, but you'd be better off if you can switch to the Unity version it's eventually released in, whenever that is.
     
  41. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am not sure what rendering pipeline takes .. 4+ years to be production ready.. and it is still not in my opinion.
     
  42. VoodooDetective

    VoodooDetective

    Joined:
    Oct 11, 2019
    Posts:
    239
    Ahh thanks very much! That settles that. I'd rather be safe than sorry :)
     
  43. felipemuniznet

    felipemuniznet

    Joined:
    Jun 5, 2018
    Posts:
    6
    Hello @diego-vieira are you resolved the problem with many lights in your mmorpg? i have the same problem in my game with a very large map, rendered in realtime, the information of map is sended from the server to the client, and i can have N individual lights in many tiles of map like this demo: upload_2024-1-4_19-39-30.png