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 Light not working

Discussion in 'Universal Render Pipeline' started by Bloodsys, Mar 28, 2020.

  1. Bloodsys

    Bloodsys

    Joined:
    Oct 29, 2014
    Posts:
    5
    I've created a new URP project upload_2020-3-28_23-21-25.png

    upload_2020-3-28_23-22-39.png
    Created
    > Rendering > Universal Render Pipeline > 2D Renderer (Experimental)
    and
    > Rendering > Universal Render Pipeline > Pipeline Asset (Forward Renderer)
    Then deleted an auto-created "UniversalRenderPipelineAsset_Renderer"
    Then drag'n'dropped my UniversalRenderPipelineAsset to the Project Settings > Graphics > Scriptable Render Pipeline Settings
    But still can't add a 2D Light
    upload_2020-3-28_23-25-4.png
    If I try to add a Light 2D component, I get this warning: upload_2020-3-28_23-29-34.png

    Also, I've tried this repo: https://github.com/Unity-Technologies/2d-renderer-samples
    and it works, but I've compared everything in Project Settings/Pipeline and Renderer assets/Main Camera component/URP version.
    Everything is equal, but it works in Unity Sample Project and doesnt work in mine.
     
  2. Bloodsys

    Bloodsys

    Joined:
    Oct 29, 2014
    Posts:
    5
    upd.
    Also, I've checked several official and unofficial tutorials about setting up 2D Light/Renderer/Pipeline, but every time there were a step to add a Light 2D object via "GameObject" menu option, I got a disabled list of different Light 2D objects while they were enabled in every tutorial.
     
  3. el_nanog

    el_nanog

    Joined:
    Jul 1, 2017
    Posts:
    1
    Try adding the new 2d renderer to UniversalRenderPipelineAsset. After deleting the auto created one, it is likely empty. upload_2020-4-4_16-59-40.png
     
    nathanfosborn likes this.
  4. Bloodsys

    Bloodsys

    Joined:
    Oct 29, 2014
    Posts:
    5
    nope, it is filled :>
    still not working
     
  5. BFyre

    BFyre

    Joined:
    Feb 13, 2018
    Posts:
    1
    In case you or anyone else has this problem, you need to change the autogenerated renderer. After you create UniversalRenderPipelineAsset, remove the generated UniversalRenderPipelineAsset_Renderer and add a custom one: Create > Rendering > Universal Render Pipeline > 2D Renderer (Experimental). Then drag and drop it into Renderer list in UniversalRenderPipelineAsset.
     
  6. Goplit

    Goplit

    Joined:
    Jul 12, 2016
    Posts:
    2
    In case you are still have this problem, it seems that you also have to assign pipeline in Quality settings to every quality level
     
  7. Unity-Artcraft

    Unity-Artcraft

    Joined:
    Jul 28, 2018
    Posts:
    85
    It's not working for me, absolutely zero changes, no pink textures, nothing black, absolutely nothing
     
    Raduzhnik likes this.
  8. zeitweise

    zeitweise

    Joined:
    Aug 12, 2013
    Posts:
    7
    I had also to click the menu item Edit->Render Pipeline->Universal Render Pipeline->Scene Materials to 2D Render Materials. Then my materials went black and I could use 2D Lights.

    Another caveat: Some lights seem only to work in orthographic camera mode.
     
  9. Anjum-Shakeel-Janjua

    Anjum-Shakeel-Janjua

    Joined:
    May 1, 2014
    Posts:
    2
    For anyone still facing this issue, I just changed my Main Camera from current (Orthographic) to Perspective and then back to Orthographic. Don't know what the issue was but it solved my problem. I am able to use 2D Lights now.
     
  10. Mathi2721

    Mathi2721

    Joined:
    Aug 28, 2019
    Posts:
    1
    For anyone still having this problem, you have to change the material on the Sprite Renderer to URP's Sprite-Lit-Default material, so that the sprite is affected by lighting.
     
  11. caiotoon

    caiotoon

    Joined:
    Apr 16, 2023
    Posts:
    11
    I'm still having the same issue, double checked everything on this post. Also, videos are mostly outdated and I'm not quite sure I clicked the right options on version 2021.3.22f1. Any other ideas of why nothing is happening?
     
  12. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    If this is a new project, the easiest thing to do is start from the URP 2D template within Unity Hub.

    If converting, you need:
    • Create 2D RendererPipeline asset (right click in Project > Create > Rendering).
    • Create Renderer2DData asset (right click in Project > Create > Rendering).
    • Render2DData asset plugged into RendererPipeline
    • RendererPipeline plugged into Graphics
    • Converted materials to Sprite-Lit-Default (in most cases)
    • Light 2D global light. This is not a global light like in Built-In/URP. It's an option on Light2D!
    • Plug Renderer2DData asset into Camera. The camera has a property called Renderer. If your data asset is unavailable from this dropdown, your pipeline is wrong or it's not plugged in to Graphics.
    Caveats:
    • There's also a places in Quality to plug the RendererPipeline. But it's usually best to keep this null unless needing different pipelines per quality level.
    • It may be possible to continue using the UniversalPipeline instead of the 2D Renderer Pipeline. This will disable some convenient features, like defaulting the material to Sprite-Lit-Default, iirc, but maybe you need Universal for some project-specific reason that overrides that convenience. For a normal project, use the 2D Renderer Pipeline.
     
    Last edited: Apr 24, 2023
  13. caiotoon

    caiotoon

    Joined:
    Apr 16, 2023
    Posts:
    11
    I can't find a documentation for this behaviour, but basically, if I remove the global light, the whole lighting system shuts off. If I add a global light with intensity 1 it works fine, and I'm back at the original graphics.

    Is this behaviour documented anywhere?
     
  14. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    Not documented. On your version that's how it works. On later versions, that behavior changed to treat an absence of a global light 2d as a black global light. For your case, have a global light 2d, any intensity, optionally black if you want to just use spot lights or something.
     
  15. tmendez

    tmendez

    Joined:
    Oct 12, 2015
    Posts:
    39
    Perhaps it's a bug? I'm running 2022.2.16f1 and am running into the same problem as OP and have done all these steps a couple of times to make sure I wasn't crazy. Came here when they weren't working and found everything I've tried. The weirdest part is the URP is all hooked up, and Sprite-Lit-Default mats applied, and nothing goes black even without a light
     
  16. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    Double check your camera. That's an easy one to mess up.
    I forget when the behavior changed, but put a global light 2d in there and give it a red color to see if working. You might also throw a few light2Ds into the scene, and check the Frame Debugger. Do they get drawn? Compare that to working project started with the 2D Template in the Unity Hub, which will be set up correctly automatically. Otherwise, maybe there's a bug.
     
  17. tmendez

    tmendez

    Joined:
    Oct 12, 2015
    Posts:
    39
    omg I'm an idiot - I was using create -> point -> light -> point light instead of a 2D light. I wish I could banish options so I could hide the 3D stuff while I'm working in 2D. I'm used to working in 3D so I was on autopilot.
     
  18. McGurke322

    McGurke322

    Joined:
    Jun 21, 2020
    Posts:
    1
  19. GB2102

    GB2102

    Joined:
    Jul 8, 2018
    Posts:
    7
    If you are sure that you have set every necessary details right, there's one trick you need to check: remember to toggle on the scene light, which is a lamp icon, at the right up corner of scene view. right beside the 2d/3d switch button.

    if you have toggled it off, unity seems to add auto light to the scene(not component), so the sprite won't be affected by the 2d light.
     
    Last edited: Aug 29, 2023
    P_e_t_a_c_h_e_k likes this.