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

2D lights not working in overlay camera

Discussion in 'Universal Render Pipeline' started by voronwe13, Mar 1, 2022.

  1. voronwe13

    voronwe13

    Joined:
    Feb 23, 2017
    Posts:
    5
    I'm working on a 2D game (in perspective mode) that has some 3D elements mixed in, and my goal is to have 2D lights on my sprites, and 3D lights on 3D objects. To do this, I'm using stacked cameras, with the base camera using a normal URP renderer, and an overlay camera using the 2D renderer. I can get the 2D and 3D to intermix correctly, and each camera is showing its view correctly when I look at the camera view, but when they actually get rendered in the game view, the 2D lighting is gone. Am I missing something in how to set this up, or does the overlay camera not render 2D lighting?

    Here's the base camera view:
    mainCamera.png
    Here's the 2D Camera view (showing sprite with spotlight and dark global light):
    2DCamera.png
    And here's what the game view looks like:
    GameView.png

    As you can see, the 2D lighting is completely missing in the game view. I've played with every setting I can think of in both the cameras and the renderers, and nothing seems to fix the issue.

    I'm using Unity 2021.2.13f1 in Windows. I have not tried it in Unity 2022.1 yet.
     
    blue-Assassin17 likes this.
  2. blue-Assassin17

    blue-Assassin17

    Joined:
    Feb 17, 2020
    Posts:
    5
    This is happening in 2021.3.5f1 Windows Editor too. Both my base and overlay cameras use 2D URP. The global light works on the object rendered with the overlay camera (my layer: 3d) in the Scene view but not in the Game view (turns dark).
    Here are my settings:
    - Global Light, Base, and Overlay Cameras are all under a single Transform with z: -10

    **********Base Camera*********
    upload_2022-10-20_17-8-8.png

    **********Overlay Camera*********
    upload_2022-10-20_17-9-46.png

    **********Global Light*********
    upload_2022-10-20_17-10-28.png

    **********On Play*********
    upload_2022-10-20_17-15-51.png

    Updated: Solved by changing the Layer of the Global Light GameObject too!

     
    Last edited: Oct 20, 2022
  3. blue-Assassin17

    blue-Assassin17

    Joined:
    Feb 17, 2020
    Posts:
    5
    Solution: Change your Global Light game object's layer too
    Example:
    upload_2022-10-20_17-46-42.png
     
  4. Flying_Banana

    Flying_Banana

    Joined:
    Jun 19, 2019
    Posts:
    26
    Great solution! The light is not being rendered if it's not on the camera's culling mask!