Search Unity

Question How to disable lights per camera in URP? Or prevent Inl_ScriptableRenderer.SetupLights being called?

Discussion in 'Universal Render Pipeline' started by Stephen1701, Dec 9, 2022.

  1. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    Hello,

    I have 2 cameras in my scene, one camera to display everything in the game, and a second camera to only display dots tracking each game object, which I display to a render texture to act as a radar)

    I noticed in the profiler that this radar camera is calling Inl_ScriptableRenderer.SetupLights, and it's taking a lot of time to do so. So it appears that this camera is trying to render lights that it cannot see. I've set culling on the camera so it can only see the dots. I've even set up light layers so that the dots don't get lit up, and I've set them as an Unlit shader, but it doesn't help.
    As long as there are lights in the scene Inl_ScriptableRenderer.SetupLights will get called on the camera
    In the screenshot below you can see nearly 2ms is being used by this camera calling SetupLights, when then objects it sees aren't being affected by any lights.

    I could just use less lights, but I'd still like to know if this is possible, as I use 3 cameras in my game scene and I don't want them spending time on lights they can't see.

    Thanks
    upload_2022-12-9_13-10-31.png
     
    F11BOT likes this.
  2. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    Can anyone at Unity help out with this? Thanks
     
    F11BOT likes this.
  3. F11BOT

    F11BOT

    Joined:
    Sep 17, 2014
    Posts:
    7
    It would be a nice solution that we could use different render pipeline assets per camera to disable so that we can customize settings per camera :(

    But it's scary no one has answered this in so long...