Search Unity

2D Light issue with Camera Stack in URP

Discussion in '2D' started by trcdev, Sep 9, 2020.

  1. trcdev

    trcdev

    Joined:
    Sep 18, 2018
    Posts:
    5
    Unity Version 2019.4.9f1 Personal
    URP Version 7.4.3

    Hello everyone,

    I am currently working with the new 2D light system from the Lost Crypt Demo and stumbled over an issue when it comes to stacking multiple cameras.

    I have 2 cameras set up in my game.

    1) Base Camera that renders just the environment (similar to the one from Lost Crypt) with some 2D lights in it.
    2) Overlay Camera that renders some UI stuff above it and is registered in the camera stack of cam1

    Cullin masks of the cameras are setup in that way that cam1 just renders the layer "environment" and cam2 just the layer "ui". Both cameras are orthographic and have the same size and position.

    The problem is that the 2D light from the environment is also rendered by the overlay camera.
    This is noticable when moving the camera1 in the scene.

    Even if I set the culling mask to nothing there is still the light displayed.

    To reproduce issue:

    1) Open Lost Crypt Demo
    2) Add a new Camera as in the screen below. Set culling mask to nothing

    img2.png

    This produces following output where the light from the scene is also rendered by the overlay camera.

    img3.png

    This effect is a lot more visible when setting the culling mask of the base camera also to nothing.
    Even if there shouldnt be anything visible there is still the light displayed by the overlay camera.

    img1.png

    I have tried many things and searched for similar issues on the forum but wasn't able to find any help.

    I would appreciate any help or hint how to solve the issue.

    Thanks a lot and best regards.
     
    nicmarxp likes this.
  2. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Do the new 2d lights have a layer setting? (Target)
    Is it possible this is on both?
     
  3. trcdev

    trcdev

    Joined:
    Sep 18, 2018
    Posts:
    5
    Thanks for you replay.
    In the 2D lights I can specify a sorting layer, however this is unrelated to the culling mask of the cameras.
    I just seem to appear that 2D light is rendered by every camera which has its viewport in the area of the light.
     
  4. thelosev

    thelosev

    Joined:
    Feb 13, 2014
    Posts:
    4
    I've just found myself in the same situation in my own project.
    Have you been able to find any solution to this @trcdev ?
     
  5. KoolGamez

    KoolGamez

    Joined:
    Apr 11, 2020
    Posts:
    29
    Please someone provide a solution as I am facing this issue as well
     
  6. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    I just got this error too, it took a while before I realized the overlay camera was causing it.
    The overlay camera culling mask is set to a specific layer, and the 2d lights are definitely not in that layer... @trcdev any solution to it? I'm on 2020.1.4 for now.
     
  7. Bish0pdev

    Bish0pdev

    Joined:
    Oct 14, 2017
    Posts:
    1
    Hey guys! I found the solution to this problem if you are still searching for it, 2d Lights apparently render on the default layer so just set your culling mask to render default and change all the other objects to a different layer, its a bit of a hassle but its the only solution I found
     
  8. BoyceCecil

    BoyceCecil

    Joined:
    Oct 18, 2021
    Posts:
    2
    I don't think so where did you find it? I disable another layer and my 2D light disappear.