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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

2D lights and Sort group Issue

Discussion in '2D' started by jcibarra, May 23, 2022.

  1. jcibarra

    jcibarra

    Joined:
    Nov 19, 2015
    Posts:
    3
    Hello,
    Looking to Achiveve: Each character to have their own 2d lights and have a correct render order in the scene

    Setup: we have a sprite 2d player character with their own proper 2d lights independ of the scene general 2d lights and each enemy have their own 2d lights all characters are prefabs, with shaders for lighting and each one with their own lights and sorting layer. (Player and Enemy, boss, etc sort layer)

    Problem: characters render order in the scene we fix using sort group and URP transparency sort axis, but the 2d lights of each characters get lost when applying the sort group and the sprite doesnt respect their shaders. Other issue if we put all charactes lights in the same sort layer the player light can change enemy light or viceversa.

    Lights: We use point light 2d

    Any advice on how we can achieve this purpose. Thank you.
     
  2. jcibarra

    jcibarra

    Joined:
    Nov 19, 2015
    Posts:
    3
  3. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    254
    Sorry I'm a little confused so I hope my reply is relevant to your question.

    It looks like from the video that sprites are on their own layers (Box and Circle) and you add them to a sorting group on a third layer (Sort), then change the lights to target Box and Sort, and Circle and Sort? (not sure as the drop downs don't show in the video)

    Because of how sorting groups work, when you do this, the Box and Circle sprites are no longer on their original layers but are automatically assigned to the Sort sorting layer by the sorting group.

    My expectation of what would happen would be that a light targeting Sort would light both objects in the group.

    Is this what is happening?
     
  4. jcibarra

    jcibarra

    Joined:
    Nov 19, 2015
    Posts:
    3
    Yes that is happening and we are looking for to maintain the 2d lights to each specific sprite and at the same time to have a correct render order sprites with z-index using URP transparency sort axis.
     
  5. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    254
    Currently, we only support lighting by layer. So it's likely not possible to do what you want to do.