Search Unity

Question Optimizing Real-time lighting in mobile (URP)

Discussion in 'General Discussion' started by Digitex1, Oct 31, 2022.

  1. Digitex1

    Digitex1

    Joined:
    Aug 28, 2017
    Posts:
    42
    Hi,

    I have a set-up with a first-person view character + a real-time light simulating a flashlight with a cookie (with no shadows)

    I noticed that the game frame rate drops noticeably on mobile. Apparently, due to lights calculations:



    Are there any particular tips to optimize this?
     
  2. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Unity's builtin shaders, even for URP which is meant to be a 'performance-first' pipeline, often need a lot of work to get them to a shippable state on mobile. How you optimize is up to you, but first thing would be to check what shaders you're using across all materials in your scene, check simple things like what resolution the game is natively rendering at, and you might find an easy solution.
     
  3. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    I don't use URP, just built in but in many tests with my game that uses a real time sky and a flashlight on mobile, the thing that affects performance the most is resolution.

    Not sure if the same would apply using URP but I think it will.
     
    Stardog likes this.
  4. Digitex1

    Digitex1

    Joined:
    Aug 28, 2017
    Posts:
    42
    Thanks @GoGoGadget and @derkoi for your answers, But I don't really understand what do you mean by resolution? Resolution of what? resolution of textures used in the environment?

    Where can I find this parameter you're talking about.
     
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,134
    Display resolution. That's what the rendering resolution is.
     
  6. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,912
    Activate Dynamic Resolution and adjust the resolution scaling with
    ScalableBufferManager.heightScaleFactor
    and
    ScalableBufferManager.widthScaleFactor
    .

    You could also set the base resolution using Screen.SetResolution to 80%. No phone needs to be rendering at native res. It's too many pixels.

    SetResolution to 50% will improve the frame rate more than ScaleableBufferManager to 50%, but it will affect the UI resolution also.
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    I disagree with this, but I do agree that reducing resolution is the easiest way to gain performance when using Unity's features on mobile.