Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Performance Problems with URP & 2D Lighting/Shadow on Mobile Devices

Discussion in '2D' started by UWSUMUT, Dec 17, 2020.

  1. UWSUMUT

    UWSUMUT

    Joined:
    Jul 14, 2020
    Posts:
    8
    Hello,
    I'm currently using 2021 alpha version. I'm currently developing a 2D mobile game and testing on Galaxy S6(Android) as my base device. I'm using OpenGL ES3. I was using the built-in render pipeline but switched to URP to use 2D lighting and shadows. With built-in RP I can get a stable 60 fps while URP reduces it to 20fps. I have a global light and two point lights, also several objects have 2D shadow caster script on them. But the shadows are limited inside the same sorting layer. I've read that sorting layer count reduces performance greatly, I have 10 atm. I also have one custom shader graph for swaying plants, that's all. But then again, they say 2021 version has increased performance with mobile devices but I didn't see that performance difference.

    Should I give up using URP for Android and continue with built-in RP? Should I add fake lighting and shadows via sprite shapes to have smooth gameplay on mobile? URP does wonders visually, I would really like to solve this performance problem and use it.
     
  2. Djayp

    Djayp

    Joined:
    Feb 16, 2015
    Posts:
    114
    I suggest you try to customize the package locally and wait for some update to land. There's a really simple optimization to perform on ShadowCaster2D.cs.
    This GetComponent should be in Awake. It's the most significant lag from ShadowCasters.
     
    mochakingup likes this.
  3. UWSUMUT

    UWSUMUT

    Joined:
    Jul 14, 2020
    Posts:
    8
    I finally found the culprit, it was HDR and the global light in the scene. Currently, I can use URP with stable 60fps and It's even more smooth and more performant than SRP but even though I don't have any shadow casters in the scene, I can't use any form of 2D lighting due to performance problems. Maybe I should play with render pipeline asset values a bit more.