Search Unity

Question 2D Renderer using 3D lights

Discussion in '2D' started by paulg5682, May 15, 2023.

  1. paulg5682

    paulg5682

    Joined:
    Feb 14, 2016
    Posts:
    11
    I have tried to stack a 2d renderer camera on top of a 3d URP camera but unity says that is not allowed.

    How can I get 3d lighting in my 2d game. I don't need 3d lights to affect 2d objects, just the 3d objects in the game.

    Thanks.
     
  2. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Hey @paulg5682, thanks for the question! May I know what's your current default renderer?

    I'm guessing you are on the URP 2D Renderer as you mentioned it's a 2D game. If you already have 2D Lights working in your Scene, you can simply change your materials on your 3D meshes from Lit to Sprite-Lit-Default so that they get affected by 2D Lights too. That way, your 2D Lights would light up your 3D meshes just as fine too.

    If for some reasons, you want your 2D Lights to light up your 3D meshes only and not your 2D Sprites, you can also change your 2D Sprites materials to Sprite-Unlit-Default so the Sprites remain unlit by the 2D Lights.

    Else, if you have a strong preference to use the 3D Lights over the 2D Lights, then as far as I know, you might have to switch to the URP Universal Renderer to see the 3D Lights taking effect (while having the 3D meshes using the default Lit material).

    Hope this helps somewhat and hopefully offer you a free bump too. Happy creating! :)